Skip to content

Commit

Permalink
Merge branch 'main' into add_worldpop_agesex_classes
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqi-tori authored Oct 9, 2024
2 parents c010e55 + ecede70 commit 659ff6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion city_metrix/layers/open_street_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import geopandas as gpd
import pandas as pd

from .layer import Layer
from .layer import Layer, get_utm_zone_epsg


class OpenStreetMapClass(Enum):
Expand Down Expand Up @@ -71,4 +71,7 @@ def get_data(self, bbox):
keep_col.append('lanes')
osm_feature = osm_feature.reset_index()[keep_col]

crs = get_utm_zone_epsg(bbox)
osm_feature = osm_feature.to_crs(crs)

return osm_feature
4 changes: 3 additions & 1 deletion city_metrix/layers/overture_buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import subprocess
from io import StringIO

from .layer import Layer
from .layer import Layer, get_utm_zone_epsg


class OvertureBuildings(Layer):
Expand All @@ -24,6 +24,8 @@ def get_data(self, bbox):
if result.returncode == 0:
geojson_data = result.stdout
overture_buildings = gpd.read_file(StringIO(geojson_data))
crs = get_utm_zone_epsg(bbox)
overture_buildings = overture_buildings.to_crs(crs)
else:
print("Error occurred:", result.stderr)

Expand Down
10 changes: 5 additions & 5 deletions city_metrix/layers/smart_surface_lulc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ def get_data_esa_reclass(esa_world_cover):


# Open space
open_space_osm = OpenStreetMap(osm_class=OpenStreetMapClass.OPEN_SPACE_HEAT).get_data(bbox).to_crs(crs).reset_index()
open_space_osm = OpenStreetMap(osm_class=OpenStreetMapClass.OPEN_SPACE_HEAT).get_data(bbox).reset_index()
open_space_osm['Value'] = 10


# Water
water_osm = OpenStreetMap(osm_class=OpenStreetMapClass.WATER).get_data(bbox).to_crs(crs).reset_index()
water_osm = OpenStreetMap(osm_class=OpenStreetMapClass.WATER).get_data(bbox).reset_index()
water_osm['Value'] = 20


# Roads
roads_osm = OpenStreetMap(osm_class=OpenStreetMapClass.ROAD).get_data(bbox).to_crs(crs).reset_index()
roads_osm = OpenStreetMap(osm_class=OpenStreetMapClass.ROAD).get_data(bbox).reset_index()
if len(roads_osm) > 0:
roads_osm['lanes'] = pd.to_numeric(roads_osm['lanes'], errors='coerce')
# Get the average number of lanes per highway class
Expand Down Expand Up @@ -130,7 +130,7 @@ def get_data_esa_reclass(esa_world_cover):
)

# get building features
buildings = OvertureBuildings().get_data(bbox).to_crs(crs)
buildings = OvertureBuildings().get_data(bbox)
# extract ULU, ANBH, and Area_m
buildings['ULU'] = exact_extract(ulu_lulc_1m, buildings, ["majority"], output='pandas')['majority']
buildings['ANBH'] = exact_extract(anbh_1m, buildings, ["mean"], output='pandas')['mean']
Expand Down Expand Up @@ -181,7 +181,7 @@ def classify_building(building):


# Parking
parking_osm = OpenStreetMap(osm_class=OpenStreetMapClass.PARKING).get_data(bbox).to_crs(crs).reset_index()
parking_osm = OpenStreetMap(osm_class=OpenStreetMapClass.PARKING).get_data(bbox).reset_index()
parking_osm['Value'] = 50


Expand Down

0 comments on commit 659ff6e

Please sign in to comment.