Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update osm and overture to return data in utm projection #82

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading