From 0e40abeb7bab81f9f96a72785315c4b7e9c05a7e Mon Sep 17 00:00:00 2001 From: Adrian Kriger <59996720+AdrianKriger@users.noreply.github.com> Date: Sat, 9 Mar 2024 08:21:03 +0200 Subject: [PATCH] 6th commit --- CityJSONspatialDataScience.ipynb | 96 +++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/CityJSONspatialDataScience.ipynb b/CityJSONspatialDataScience.ipynb index 14a7279..039a4c6 100644 --- a/CityJSONspatialDataScience.ipynb +++ b/CityJSONspatialDataScience.ipynb @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 54, "id": "5dd597d7", "metadata": { "id": "a4ea1fcc" @@ -70,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 55, "id": "5557ef08", "metadata": { "id": "529536e5" @@ -86,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 56, "id": "d9717ddd", "metadata": { "id": "c45a674c" @@ -98,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 57, "id": "0360987e", "metadata": {}, "outputs": [ @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 58, "id": "f8e0fa63", "metadata": { "id": "c7ec404d" @@ -190,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 59, "id": "a44108b5", "metadata": { "id": "9b5be780", @@ -398,7 +398,7 @@ "[2 rows x 53 columns]" ] }, - "execution_count": 24, + "execution_count": 59, "metadata": {}, "output_type": "execute_result" } @@ -409,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 60, "id": "1c87ffcf", "metadata": {}, "outputs": [], @@ -429,7 +429,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 61, "id": "842acc96", "metadata": { "id": "1bc556e3" @@ -442,7 +442,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 62, "id": "68c33745-1f3b-4997-9825-d69c6a4073be", "metadata": { "scrolled": true @@ -649,7 +649,7 @@ "[2 rows x 53 columns]" ] }, - "execution_count": 27, + "execution_count": 62, "metadata": {}, "output_type": "execute_result" } @@ -660,7 +660,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 63, "id": "6c372e69", "metadata": { "id": "7f0a4fe5", @@ -673,7 +673,7 @@ "1874" ] }, - "execution_count": 28, + "execution_count": 63, "metadata": {}, "output_type": "execute_result" } @@ -702,8 +702,8 @@ "**Furthermore:** \n", " - `building:apartment` harvests the `building:flats` *'key:value'* pair *(the number of units)* to calculate `*3` people per apartment. \n", " - ***Student accomodation***: \n", - "> - On-site: is tagged `building:dormitory` and harvests the `beds` *'key:value'* pair.\n", - "> - Off-site: is tagged `building:residential` with `residential:student` and then harvests the `building:flats` *'key:value'* pair *(the number of units)* to calculate `*1` people per apartment; if `level: > 1` else `*3` people in a house share.\n", + "> - On-site: is tagged `building:dormitory` with `residential:university` and harvests the `beds` *'key:value'* pair.\n", + "> - Off-site: is tagged `building:residential` or `:dormitory` with `residential:student` and then harvests the `building:flats` or `:rooms` *'key:value'* pair *(the number of units)* to calculate `*1` people per apartment; if `level: > 1` else `*3` people in a house share.\n", " \n", "**The tagging scheme and numbers is based on *how your community is mapped* and local knowledge**\n", "" @@ -711,30 +711,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "id": "dc7c0efc", "metadata": { "id": "93750cce", "outputId": "69350a81-445e-44d0-adb9-d52b7057b988" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The estimated population is: 10497\n" + ] + } + ], "source": [ "def pop(row):\n", - " if row['combine'] == 'house':\n", + " #- formal house\n", + " if row['osm_building'] == 'house':\n", " return 6\n", - " if row['combine'] == 'apartment':\n", - " return row['flats'] * 3\n", - " if row['combine'] == 'residential': #here should be an additional: and row['res'] == 'informal':\n", + " #- formal apartment\n", + " if row['osm_building'] == 'apartment':\n", + " return row['osm_building:flats'] * 3\n", + " #- in this case informal structure\n", + " if row['osm_building'] == 'residential': #here should be an additional: and row['res'] == 'informal':\n", " return 3\n", - " if row['combine'] == 'residential' and row['res'] == 'student':\n", - " if row['levels'] > 1:\n", - " return row['flats'] * 1\n", + " #- off-site student residence\n", + " if row['osm_building'] == 'residential' and row['osm_residential'] == 'student':\n", + " if row['osm_building:levels'] > 1:\n", + " return row['osm_building:flats'] * 1\n", " else:\n", " 3\n", + " if row['osm_building'] == 'dormitory' and row['osm_residential'] == 'student':\n", + " if row['osm_building:levels'] > 1:\n", + " return row['osm_rooms'] * 1\n", + " else:\n", + " 3\n", + " #- on-site student residence\n", + " if row['osm_building'] == 'dormitory' and row['osm_residential'] == 'university':\n", + " return pd.to_numeric(row['osm_beds'])\n", "\n", - "gdf['pop'] = gdf.apply(lambda x: pop(x), axis=1)\n", + "gdf_pop['pop'] = gdf_pop.apply(lambda x: pop(x), axis=1)\n", "\n", - "est_pop = gdf['pop'].sum()\n", + "est_pop = gdf_pop['pop'].sum()\n", "print('The estimated population is:', est_pop)" ] }, @@ -765,7 +785,17 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 65, + "id": "538cc014-8002-4f1c-8b92-77890f4bed8c", + "metadata": {}, + "outputs": [], + "source": [ + "#gdf_pop.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, "id": "94d28d52", "metadata": { "id": "d9a75295", @@ -985,7 +1015,7 @@ "[2 rows x 57 columns]" ] }, - "execution_count": 30, + "execution_count": 66, "metadata": {}, "output_type": "execute_result" } @@ -1000,7 +1030,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 67, "id": "ce47ce5e", "metadata": { "id": "6d44d125", @@ -1029,7 +1059,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 68, "id": "e0abe768", "metadata": { "id": "c98dafa0", @@ -1069,7 +1099,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 69, "id": "5007fded-ae76-4431-8035-5b9d48aad0f5", "metadata": {}, "outputs": [], @@ -1079,7 +1109,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 70, "id": "9b2362c8", "metadata": { "id": "6b913de3", @@ -1124,7 +1154,7 @@ "These are LoD1 3D City Models and works well in these types of areas. \n", "LoD2 would offer a more representative BVpC [(Ghosh, T; et al. 2020)](https://www.researchgate.net/publication/343185735_Building_Volume_Per_Capita_BVPC_A_Spatially_Explicit_Measure_of_Inequality_Relevant_to_the_SDGs) value; when the complexity of the built environment increases. \n", "\n", - "Think about a `house` with living space in the roof structure, so called *'attic living'*, or an `apartment` / `residential` building with different levels, loft apartments and/or units in the turrets of a building. " + "Think about a `house` with living space in the roof structure, so called *'attic living'*, or an `apartment` / `residential` building with different levels, loft apartments and/or units in the turrets of a `building`. " ] }, {