Skip to content

Commit

Permalink
clarify projection warning now that we are not adding lat-lon attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Mar 13, 2024
1 parent a6eda88 commit 9de6b89
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions osmnx/_osm_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,14 @@ def _save_graph_xml(
else:
gdf[col] = gdf[col].fillna(value)

# warn user if graph is projected then remove lat/lon gdf_nodes columns if
# they exist, as x/y cols will be saved as lat/lon node attributes instead
# warn user if graph is projected
if projection.is_projected(G.graph["crs"]):
msg = (
"Graph should be unprojected: the existing lat-lon node attributes will "
"be discarded and the projected x-y coordinates will be saved as lat-lon "
"node attributes instead. Project your graph back to lat-lon to avoid this."
"Graph should be unprojected: the existing projected x-y coordinates "
"will be saved as lat-lon node attributes. Project your graph back to "
"lat-lon to avoid this."
)
warn(msg, category=UserWarning, stacklevel=2)
for col in set(gdf_nodes.columns) & {"lat", "lon"}:
gdf_nodes = gdf_nodes.drop(columns=[col])

# transform nodes gdf to meet OSM XML spec
# 1) reset index (osmid) then rename osmid, x, and y columns
Expand Down

0 comments on commit 9de6b89

Please sign in to comment.