NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am trying to export as GeoJson the boundary of the regions of Ghana. My simple query is the following:

out geom;

My challenge is that when exporting it to GeoJson I do not only get the contour but also a point or two in each region. Is there a way to get rid of it in the query? Right now, my only workaround is to remove it manually which is very slow.

asked 11 Nov '22, 20:42

gmacia's gravatar image

accept rate: 0%

Those points are the administrative centre of each region and the label of each region. The first are nodes with role admin_centre, and the second are nodes with the role label. See this wiki page for more info about type=boundary relation members.

You have to use recurse statements to get rid of those two nodes. One query that works is the following one, but there might be simpler ones:

//We put the 16 regions relations in the .allRelations set:
//We get only the ways members of the relations, that means, the border ways of the regions,
//and we put them in the .relationWays set:
//And now we get all the nodes of those border ways, and put them in the .waysNodes set:
//Now we get the union of all the three sets (relations, their ways and those ways nodes):
//And we output all data:
out meta;

Note 1: You can't use out geom; here, because out geom; adds, among others, a sequence of "nd" members with coordinates to all relations, and therefore you would get those nodes you want to get rid of.

Note 2: We could use out body; instead of out meta; if we are not interested in metadata, like version of objets, changeset id, timestamp, and the user data of the user that last touched the object.

See this wiki page section for more info about the out standalone statement.

permanent link

answered 07 Jan '23, 18:39

edvac's gravatar image

accept rate: 15%

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]( "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: 11 Nov '22, 20:42

question was seen: 784 times

last updated: 07 Jan '23, 18:39

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum