This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Overpass API to PostgreSQL ?

0

Hello again,

I would like to know how can i use the overpass api of pyhton to store information into my Postgresql database (i have a PostGIS extencion) . My idea was to get the "id" of the nodes and then creating an "id" camp on the database gather the information of the tags in question.

Thank you again for all the help,

Francisco Costa

asked 03 Nov '15, 10:09

FrancisCosta's gravatar image

FrancisCosta
0121213
accept rate: 0%


2 Answers:

3

Hi, You can use the overpass API to get data from OSM and then OGR to write it to PostgreSQL. You can do it on the command line or within Python. The intermediate format can be the native OSM XML format, or you can change to JSON.

Example on command line:

wget 'http://overpass-api.de/api/interpreter?data=way["highway"="residential"]["name"](41.8942593,12.4812841,41.9030756,12.4945021);out;' -O rome.osm 
osm2pgsql -H localhost -s -U geobox -d geotuga -c rome.osm

answered 04 Nov '15, 11:10

Jorge%20Gustavo%20Rocha's gravatar image

Jorge Gustav...
673
accept rate: 0%

0

Maybe you can try QGIS for this task?

QGIS has a plugin called QuickOSM where you can query for OSM data via overpassAPI.

And QGIS has an interface to Postgresql databases, or not? But I have no clue whether that interface is a oneway connection just to load data from database in QGIS.

Have NOT tried that on my own.

answered 03 Nov '15, 16:35

stephan75's gravatar image

stephan75
12.6k556210
accept rate: 6%

I regularly pull GEOJSON from Overpass into QGIS & push to PostGIS: but this is a distinctly non-automated approach.

(04 Nov '15, 11:50) SK53 ♦

@SK53: just to clarify your statement: I guess you mean "pull GeoJSON from overpass turbo"? The difference is quite important, as Overpass API doesn't provide GeoJSON out of the box. It provides some custom JSON format only, which doesn't really qualify as GeoJSON.

(04 Nov '15, 12:03) mmd