Skip to content

Commit

Permalink
6th commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianKriger authored Mar 9, 2024
1 parent 3e74c2a commit 0e40abe
Showing 1 changed file with 63 additions and 33 deletions.
96 changes: 63 additions & 33 deletions CityJSONspatialDataScience.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 54,
"id": "5dd597d7",
"metadata": {
"id": "a4ea1fcc"
Expand Down Expand Up @@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 55,
"id": "5557ef08",
"metadata": {
"id": "529536e5"
Expand All @@ -86,7 +86,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 56,
"id": "d9717ddd",
"metadata": {
"id": "c45a674c"
Expand All @@ -98,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 57,
"id": "0360987e",
"metadata": {},
"outputs": [
Expand All @@ -124,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 58,
"id": "f8e0fa63",
"metadata": {
"id": "c7ec404d"
Expand Down Expand Up @@ -190,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 59,
"id": "a44108b5",
"metadata": {
"id": "9b5be780",
Expand Down Expand Up @@ -398,7 +398,7 @@
"[2 rows x 53 columns]"
]
},
"execution_count": 24,
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -409,7 +409,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 60,
"id": "1c87ffcf",
"metadata": {},
"outputs": [],
Expand All @@ -429,7 +429,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 61,
"id": "842acc96",
"metadata": {
"id": "1bc556e3"
Expand All @@ -442,7 +442,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 62,
"id": "68c33745-1f3b-4997-9825-d69c6a4073be",
"metadata": {
"scrolled": true
Expand Down Expand Up @@ -649,7 +649,7 @@
"[2 rows x 53 columns]"
]
},
"execution_count": 27,
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -660,7 +660,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 63,
"id": "6c372e69",
"metadata": {
"id": "7f0a4fe5",
Expand All @@ -673,7 +673,7 @@
"1874"
]
},
"execution_count": 28,
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -702,39 +702,59 @@
"**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",
"</div>"
]
},
{
"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)"
]
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -985,7 +1015,7 @@
"[2 rows x 57 columns]"
]
},
"execution_count": 30,
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1000,7 +1030,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 67,
"id": "ce47ce5e",
"metadata": {
"id": "6d44d125",
Expand Down Expand Up @@ -1029,7 +1059,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 68,
"id": "e0abe768",
"metadata": {
"id": "c98dafa0",
Expand Down Expand Up @@ -1069,7 +1099,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 69,
"id": "5007fded-ae76-4431-8035-5b9d48aad0f5",
"metadata": {},
"outputs": [],
Expand All @@ -1079,7 +1109,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 70,
"id": "9b2362c8",
"metadata": {
"id": "6b913de3",
Expand Down Expand Up @@ -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. </div>"
"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`. </div>"
]
},
{
Expand Down

0 comments on commit 0e40abe

Please sign in to comment.