Closed TheStarAlight closed 6 months ago
Hi @TheStarAlight How do you download the file and in what format do you have it?
Hello! I downloaded it using the overpass API: https://overpass-api.de/api/map?bbox=118.4862,29.3295,119.2937,29.7644
, and it is an osm file. I tried to parse it into GeoDataFrame and pass to the plot function and it failed as expected...
g = ox.graph_from_xml("Qiandaohu.osm")
df = ox.graph_to_gdfs(g, nodes=False, edges=True)
plot = prettymaps.plot(df)
Sorry, new to GIS and I know nothing about it :(
Will look into it, thanks for the good description! Not sure it will be added to the package as a function, but I was recently also thinking I'd love to have big local OSM file e.g. for a country and use the code anywhere for that country without the osmnx download.
@chrieke Thank you~🥰 But plotting a country's map seems very time-consuming, maybe we also need a scale level in the function argument.
Hehe yeah sure, no I got what you want to achieve. It's just a related thought.
Hey finally got around to check this out. It's actually pretty simple. I haven't added it to the library yet, but here is a working example:
Install prettymapp directly from the current repo code to test this:
pip uninstall prettymapp
pip install git+https://github.com/chrieke/prettymapp.git
We can then slightly adjust creating the aoi from the provided coordinates, and creating the dataframe directly from the xml file:
from shapely.geometry import box
from osmnx.features import features_from_xml
from prettymapp.osm import get_osm_tags, cleanup_osm_df
def get_osm_geometries_from_xml(xml_filepath, aoi):
tags = get_osm_tags()
df = features_from_xml(xml_filepath, polygon=aoi, tags=tags)
df = cleanup_osm_df(df, aoi)
return df
aoi = box(118.4862,29.3295,119.2937,29.7644)
df = get_osm_geometries_from_xml(xml_filepath="Qiandaohu.osm", aoi=aoi)
print(df.shape)
The rest of the code is just like the example code:
from prettymapp.geo import get_aoi
from prettymapp.osm import get_osm_geometries
from prettymapp.plotting import Plot
from prettymapp.settings import STYLES
fig = Plot(
df=df,
aoi_bounds=aoi.bounds,
draw_settings=STYLES["Peach"]
).plot_all()
The result is rectangular, as the example above doesn't use the get_aoi
function from the regular example.
Havent integrated it yet, happy for any feedback if you have any before doing so. I'm curious if you know if any OSM xml would be like yours, or if that is just specifically via the overpass-api.
wow! That's really nice! I'll have a try on it :D btw,
I'm curious if you know if any OSM xml would be like yours, or if that is just specifically via the overpass-api.
I actually can't catch your meaning? Could you pls explain it further?
I actually can't catch your meaning? Could you pls explain it further? What I meant is if all "OSM XML" files have this same formatting. To answer my own question after a bit more googling, yes, it's the standard, e.g. when exporting directly from openstreetmap.org.
Added this functionality in release 0.3.0, see the new example in the Readme. Thanks again for the idea! Closing this thread.
Hi! The prettymapp & prettymaps are great projects that plot impressive maps 🥰 Now I need to make a map plot using prettymapp, and I prefer to download the osm file in advance, because the network is not good and I prefer making all the resources local, also, the osm file I want to plot is very big (~80 MB). I wonder if prettymapp can add an interface to pass in the osm file path and parse it offline? Or, may I know the walkaround in current situation? Thank you!