-
Notifications
You must be signed in to change notification settings - Fork 830
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
Improve OSM XML file saving #1135
Conversation
As a tangential aside, it would be nice someday to replace all the OSMnx XML read/write functionality with PBF read/write functionality instead and outsource it to a dedicated third-party library. See also pyrosm/pyrosm#228. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v2 #1135 +/- ##
==========================================
+ Coverage 97.93% 98.01% +0.07%
==========================================
Files 25 25
Lines 2427 2422 -5
==========================================
- Hits 2377 2374 -3
+ Misses 50 48 -2 ☔ View full report in Codecov by Sentry. |
@gboeing I think its safe (and advisable) to hardcode |
Thanks @stl-maxgardner . Did this change above also make sense:
If we make the function always operate as though |
Yes I think so! |
@stl-maxgardner one more question for you. In 54170cd I proposed that we remove the The The Does that all make sense and seem reasonable to you? |
Some timings comparing this import osmnx as ox
ox.settings.all_oneway = True
G = ox.graph.graph_from_place(place, network_type="drive", simplify=False)
%%timeit
ox.io.save_graph_xml(G, filepath="./test.xml") The
|
An XSD schema file was added in 06edb3d and successfully validates a variety of test OSM XML files saved by OSMnx, exported from Overpass turbo, and exported from OpenStreetMap directly. |
@mxndrwgrdnr and @davidmurray you have both contributed to OSMnx's XML-saving functionality in the past. Would you be willing to review this PR before it's merged later this week? Short story: the |
Added quality-of-life improvements, warning, and additional tests for saving projected/consolidated graphs as OSM XML in ca9744b. |
The first pre-release OSMnx v2 beta has been released. Testers needed! See #1123 for details. |
Targeting the forthcoming OSMnx v2.0.0 release (see also #1106), this PR wholly refactors the
_osm_xml
module and fixes several bugs, significantly speeds up thesave_graph_xml
function, and streamlines the function's signature.The PR does the following:
save_graph_xml
function runtime by a factor of 5x or so, depending on graph size.node_tags
,node_attrs
,edge_tags
, andedge_attrs
parameters from thesave_graph_xml
function in favor of using thesettings
module directly.oneway
,api_version
, andprecision
parameters from thesave_graph_xml
function in favor of hard-coded sensible defaults. See also Improvements to save_as_xml function #917 and improvements to osm_xml module #961merge_edges
parameter from thesave_graph_xml
function and instead always operate as though this were True.encoding
parameter to thesave_graph_xml
function to configure file encoding and make it consistent with the other file saving functionssave_graph_xml
function'sdata
parameter toG
and its argument type tonx.MultiDiGraph
instead ofnx.MultiDiGraph | tuple[gpd.GeoDataFrame, gpd.GeoDataFrame
(that is, the function no longer accepts a tuple of GeoDataFrames: you can only pass a MultiDiGraph).save_graph_xml
function'sedge_tag_aggs
parameter toway_tag_aggs
and its argument type todict
instead oftuple
.osm_xml_node_attrs
,osm_xml_node_tags
,osm_xml_way_attrs
, andosm_xml_way_tags
settings because they are either unnecessary or redundant (see Improve OSM XML file saving #1135 (comment))Deprecate these now-removed function params and settings (with FutureWarning) for v1 in #1138.