anon.for
anon.for

Reputation: 57

How to extract part of huge osm.pbf in python?

I have a huge osm file (>3 Gb), which doesn't run in jupyter

from pyrosm import OSM
from pyrosm import get_data
path=r"\*.osm.pbf" 
osm = OSM(path)
drive_net = osm.get_network(network_type="driving")
drive_net.plot()

(memory error when i tried osm.get_network(network_type="driving")).

So I have lat-lon coordinates set and I want to choose an area that would include all these coordinates and a little bit around them.

Is there way to extract area in python for next work with this data (final goal is route between this coordinates)?

Upvotes: 1

Views: 1560

Answers (1)

Alex
Alex

Reputation: 35138

If it does not need directly to be in Python, you can use Osmosis CLI to pre-process the data and then feed it into your jupyter Notebook.

Extract area from OpenStreetMap

(written in Java, so it will not be directly usable in Python I think).

An alternative with similar feature is Osmium which has Python Bindings.

As for building up the area, you could use them as the points of a polygon and extrude the resulting polygon. See also here: https://docs.osmcode.org/osmium/latest/osmium-extract.html

Upvotes: 2

Related Questions