Hi! I need to get all the data of a city (including its boundaries) with the overpass API and use Overpass Turbo. I did the query like this:

[out:xml]; ( node(48.2315, 17.9596, 48.3909, 18.2497); <; ); out;

within this bounding box is the city Nitra (slovakai).

after downloading the data as an .osm-file I generated a SpatiaLite-DB in QGIS and afterwards I generated Points-, Lines-, and Polygonlayers in QGIS. BUT I CANNOT FIND THE TAG "BOUNDARY" IN THE DATASET, what am I doing wrong?

asked 02 Oct, 14:06

sim_93's gravatar image

accept rate: 0%

Hi @sim_93. If you use the vector tools menu from QGIS you can only get points, lines and polygon layers thus no relations (multipolygons and boundaries). Instead, you can use the ogr2ogr command to generate a Spatialite *.db file and then connect to it in QGIS and you'll get relations (multilines and multipolygons along with boundaries).

This is a sample command:

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES dbfile.db osmfile.osm
permanent link

answered 05 Oct, 11:13

Privatemajory's gravatar image

accept rate: 0%

Hi @Privatemajory ! Thanks for your answer :) i'm a total beginner and have no idea how to handle it.. i have the .osm-file and QGIS, can you tell me how to go through it in detail? it would be such a great help!! :) btw if its relevant, i have a mac... greetings

(05 Oct, 13:56) sim_93

I have never used a Mac but all I know is that ogr2ogr is part of GDAL. If you have QGIS then GDAL should already be installed as well. If not, install it. You can try running the command above on a terminal and see what it gives. Regards

(05 Oct, 15:20) Privatemajory

@ Privatemajory, thanky a lot, i've installed GDAL now, but when i try to run the command i get the answer "Unable to open datasource `nitra.osm' with the following drivers. -> PCIDSK -> netCDF -> ... " what did i wrong? regards

(10 Oct, 07:49) sim_93

@sim_93 I don't know why it doesn't work but you can still check if your GDAL version is not too old (better use the newest version possible). Or maybe it's the format of your OSM file (I don't know about formats generated by Overpass API as I have only tested this on a OSM file exported directly from OpenStreetMap's site using their Export tool). May someone experimented come to help you as I don't know this well.

(10 Oct, 09:27) Privatemajory

@Privatemajory ok, but thanks for your help anyway! :) i hav the newest version of GDAL and the standard ism-file... i will see if i find a way.. thanks!

(12 Oct, 07:40) sim_93

Your Overpass API query only queries nodes in the area of interest. Ways and relations are retrieved by your use of the recurse up feature (the < sign). This returns only ways which use one of the nodes and relations which use one of the nodes.

boundary=* is used on relations (for areas) and often on unclosed ways (the boundary line).

The boundary relation you queried might not contain any your area of interest because the only nodes boundary relations contain are admin centre nodes and sometimes labelling hints (as nodes).

The correct query would be

rel(48.2315, 17.9596, 48.3909, 18.2497)->.rels;
  way(r.rels)(48.2315, 17.9596, 48.3909, 18.2497);
  node(r.rels)(48.2315, 17.9596, 48.3909, 18.2497);
  way(48.2315, 17.9596, 48.3909, 18.2497);
  node(48.2315, 17.9596, 48.3909, 18.2497);
.rels out;
.nonrels out;
.nonrels >->.nonrelsreferred;
.nonrelsreferred out;

If you need all members of all relations in the result set, use the following (slower) query:

  rel(48.2315, 17.9596, 48.3909, 18.2497);
  way(48.2315, 17.9596, 48.3909, 18.2497);
  node(48.2315, 17.9596, 48.3909, 18.2497);
.result out;
.result >->.recurseresult;
.recurseresult out;

I suggest you to use the Slovakia extract from Geofabrik instead and extract your area of interest using either osmconvert or the Osmium tool (command extract).

Please keep in mind that many programs expect OSM data to be sorted by type (first nodes, then ways, then relations) and the objects in these three sections ascending by ID. Osmosis can sort OSM files.

permanent link

answered 13 Oct, 10:57

Nakaner's gravatar image

accept rate: 0%

@Nakaner Thanks for the info! but don't have a way and a relation contains nodes anyway? so why can't i do this with the recurse up feature?

and does the geofabirik-file include all features? because you can often read that at the geofarbik-files there are often missing multipolygons and relations.. regards simon

(yesterday) sim_93
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 Oct, 14:06

question was seen: 144 times

last updated: yesterday

powered by OSQA