I am using overpass api to get the OpenStreetMap data. I have a following query:

[out:json][timeout:25];
// gather results
(
  // query part for: “"Land Use"”
  way["landuse"](around:1000, 49.058008 , 2.275715);

);
// print results
out body;
>;
out skel qt;

Try it out here: http://overpass-turbo.eu/s/mOu

The problem is that it always returns LineString instead of Polygons. I would like to convert LineString to Polygon in order to use this data for intersection analysis of different Polygons. Is there a way to convert LineString to Polygon(e.g. with geoJSON library ), or should I change my query for this?

Thanks you in advance

asked 18 Feb '17, 18:57

tivalex's gravatar image

tivalex
21223
accept rate: 0%

edited 20 Feb '17, 07:22

SimonPoole's gravatar image

SimonPoole ♦
38.7k13287614

Even-though it is a crosspost neither community has given an answers so far.

(18 Feb '17, 19:54) tivalex

@tivalex: but, please, if you really need to crosspost, mention and link both. Also keep them in sync.

(19 Feb '17, 20:37) aseerel4c26 ♦
1

I found the question a bit confusing: after a while I realised it was because you provide a link to Overpass-turbo from which one can save polygons. However that is not true of the Overpass API. Overpass-turbo uses https://github.com/tyrasd/osmtogeojson

(19 Feb '17, 22:43) SK53 ♦

Sorry for confusing you. Does your answer means that I can query raw OSM data and then convert it to a POLYGON or any other type of shape using osmtogeojson?

(20 Feb '17, 07:56) tivalex
1

Should be yes. There are similar queries on GIS Stackoverflow.

(20 Feb '17, 13:07) SK53 ♦
showing 5 of 6 show 1 more comments

OSM only knows nodes, ways and relations. Ways can be closed in which case they form an area. So when you export a landuse via OverPass, you get a closed way. Isn't a polygon just another word for closed way ?

permanent link

answered 19 Feb '17, 19:54

escada's gravatar image

escada
17.8k16153283
accept rate: 21%

Thanks a lot for you answer. Indeed, it is a polygon,when it is a closed way and when the line does not intersect itself. Otherwise it is a more then one polygon. I would like to compute the area of these polygons. The problem is that I am not sure that it is possible, unless it is a polygon. I am using python shapely or gdal for this. So I started to think about conversion of the strngline to polygon.

(19 Feb '17, 20:31) tivalex
1

Since OSM does not know polygons, in which programming language are you working ? To find out whether an OSM way is a closed way, you could test whether the first and last point are the same, not ? So it is up to your processing software to determine whether a way is closed and if it is closed, calculate the area.

(20 Feb '17, 06:34) escada

It is totally make sense. However, I tought that there is some kind of a way to define a shape in the query. Or automatically convert Linestring to Polygon with help of some library. And I query only type of data that should be a polygon eg. landuse or building. Like described here: https://wiki.openstreetmap.org/wiki/Overpass_turbo/Polygon_Features Most likely I don't need to check whether it is a polygon or not. Asking to your question: I use Python for this.

(20 Feb '17, 08:07) tivalex
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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:

×355
×169
×74

question asked: 18 Feb '17, 18:57

question was seen: 2,643 times

last updated: 20 Feb '17, 13:07

powered by OSQA