From 72aa7b33da169782940f882fd0d49da105e13e15 Mon Sep 17 00:00:00 2001 From: Gareth Simons Date: Tue, 19 Nov 2024 15:38:18 +0000 Subject: [PATCH] fixes projection for marking footways --- pyproject.toml | 2 +- pysrc/cityseer/tools/io.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 96c0fdd0..623f65a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cityseer" -version = '4.16.0b12' +version = '4.16.0b13' description = "Computational tools for network-based pedestrian-scale urban analysis" readme = "README.md" requires-python = ">=3.10, <3.14" diff --git a/pysrc/cityseer/tools/io.py b/pysrc/cityseer/tools/io.py index eb524588..a825b20b 100644 --- a/pysrc/cityseer/tools/io.py +++ b/pysrc/cityseer/tools/io.py @@ -366,11 +366,13 @@ def osm_graph_from_poly( osm_response = fetch_osm_network(request, timeout=timeout, max_tries=max_tries) # build graph graph_wgs = nx_from_osm(osm_json=osm_response.text) # type: ignore - # cast to UTM - if to_crs_code is not None: - graph_crs = nx_epsg_conversion(graph_wgs, 4326, to_crs_code) - else: - graph_crs = nx_wgs_to_utm(graph_wgs) + # extract CRS code if necessary + if to_crs_code is None: + # need CRS code so do this manually + nd_key = list(graph_wgs.nodes())[0] + to_crs_code = util.extract_utm_epsg_code(graph_wgs.nodes[nd_key]["x"], graph_wgs.nodes[nd_key]["y"]) + # project + graph_crs = nx_epsg_conversion(graph_wgs, 4326, to_crs_code) graph_crs = graphs.nx_simple_geoms(graph_crs) graph_crs = graphs.nx_remove_filler_nodes(graph_crs) if simplify: @@ -383,6 +385,7 @@ def osm_graph_from_poly( }, ) park_area_gdf = _extract_gdf(parks_gdf) + park_area_gdf = park_area_gdf.to_crs(to_crs_code) # plazas plazas_gdf = ox.features_from_polygon( geom_wgs, @@ -391,6 +394,7 @@ def osm_graph_from_poly( }, ) plaza_area_gdf = _extract_gdf(plazas_gdf) + plaza_area_gdf = plaza_area_gdf.to_crs(to_crs_code) # use STR Tree for performance parks_buff_str_tree = STRtree(park_area_gdf.buffer(5).geometry.to_list()) plaza_str_tree = STRtree(plaza_area_gdf.geometry.to_list())