You are not logged in.

Announcement

*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***

#1 2021-07-08 16:53:17

DarylR
New Member
Registered: 2021-07-08
Posts: 1

Extract Node Lat/lon from .osm.pbf file in python

Hi guys,

So i've download my great britain .osm.pbf file and all i want to be able to do is within python extract all nodes and their relevant lat/lon and then store this in python to lookup.

Cheers,

Offline

#2 2021-07-09 15:54:52

SomeoneElse
Member
Registered: 2010-10-13
Posts: 1,601

Re: Extract Node Lat/lon from .osm.pbf file in python

I'm not sure what "store this in python" means - Python is a programming language rather than a database.  You might also want to rethink "all the nodes" since there are a lot of them, and most of them will just be part of ways.

However, if you follow one of the https://switch2osm.org/serving-tiles/ options you'll get a  postgresql/postgis database that you can then query (including from Python).  If you don't want to create a map you can ignore anything map-related ("Shapefile download" onwards), although a map is sometimes the easiest way to look at data smile

The OSM tags that cause objects to actually go into the database is determined by the "openstreetmap-carto.style" file, essentially a list of "things that you define that you are interested in".

Offline

#3 2021-07-09 16:42:09

Tordanik
Moderator
From: Germany
Registered: 2008-06-17
Posts: 2,840
Website

Re: Extract Node Lat/lon from .osm.pbf file in python

A database is probably unnecessary if the goal is just to read all the nodes (or perhaps all nodes with tags) from a medium-sized .osm.pbf file, which is how I would interpret the question.

I would look into a library for reading .osm.files, like pyosmium.


OSM in 3D: OSM2World

Offline

#4 2021-07-09 22:55:34

Tordanik
Moderator
From: Germany
Registered: 2008-06-17
Posts: 2,840
Website

Re: Extract Node Lat/lon from .osm.pbf file in python

Turns out the same question was also asked on StackOverflow, and I've provided an answer over there.


OSM in 3D: OSM2World

Offline

Board footer

Powered by FluxBB