[OSM-talk] Overpass API / Overpass QL: center (and centroid) function?

Stefan Keller sfkeller at gmail.com
Thu Jul 24 14:30:35 UTC 2014


Thanks again - I think I got it - including a bug:
GeoJSON is still returning polygons! But with XML it works.
E.g. replacing "[out:json]" with [out:xml] or exporting as XML.

--Stefan

2014-07-24 15:48 GMT+02:00 Pierre Béland <pierzenh at yahoo.fr>:
> Stefan,
>
> In your example, the parenthesis are making a union of the two requests. and
> the greater then ( > ) is doing a recurse request.
>
> This example below is working. It extract independantly nodes and ways,
> calculating the centroid for the ways.
>
> [out:json]
> [timeout:25]
> ;
>
>   node["shop"~"dairy"]
> (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
> out meta;
>   way["shop"~"dairy"]
> (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
> out meta center qt;
>
> Pierre
>
> ________________________________
> De : Stefan Keller <sfkeller at gmail.com>
> À : Pierre Béland <pierzenh at yahoo.fr>
> Cc : Talk Openstreetmap <talk at openstreetmap.org>
> Envoyé le : Jeudi 24 juillet 2014 9h44
> Objet : Re: [OSM-talk] Overpass API / Overpass QL: center (and centroid)
> function?
>
> Salut Pierre
>
> Thanks - But this doesn't parse (see below). I'm getting:
> Error: line 4: static error: Element "print" cannot be subelement of
> element "union".
>
> -- Stefan
>
> [out:json]
> [timeout:25]
> ;
> (
>   node["shop"~"dairy"]
>   (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
>   way["shop"~"dairy"]
>   (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
>   out meta center;
> );
>>;
> out meta qt;
>
> 2014-07-24 15:20 GMT+02:00 Pierre Béland <pierzenh at yahoo.fr>:
>> Stefan,
>>
>> In your request, you make a recursive query that loads nodes from the way.
>> In this example, the node and way queries are independant. For the way,
>> the
>> center command is used.
>>
>> [out:json]
>> [timeout:25]
>>
>> ;
>>
>>  node["shop"~"dairy"]
>> (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
>> out meta;
>>
>>  way["shop"~"dairy"]
>> (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
>> out meta center qt;
>>
>> Pierre
>>
>> ________________________________
>> De : Stefan Keller <sfkeller at gmail.com>
>> À : Talk Openstreetmap <talk at openstreetmap.org>
>> Cc : Roland Olbricht <roland.olbricht at gmx.de>
>> Envoyé le : Jeudi 24 juillet 2014 8h19
>> Objet : [OSM-talk] Overpass API / Overpass QL: center (and centroid)
>> function?
>>
>> Hi,
>>
>> I'm trying to get a list of point features only (as GeoJSON or XML).
>> This could serve as input e.g. to uMap. The problem is that the query
>> returns points but also areas. This is actually correct - but I want
>> these areas converted to point geometries too (centered, like
>> ST_Centroid).
>>
>> I then found the modifcator/keyword "center" in the Overpass QL [1].
>> But I still get polygons. See the query [2] below.
>>
>> Any ideas?
>>
>> --Stefan
>>
>>
>> [1] http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL
>>
>> [2] http://overpass-turbo.osm.ch/ oder http://overpass-turbo.eu/
>>
>> *** Dairy (Käserei) Query ways/areas only... ***
>>
>> [out:json]
>> [timeout:25]
>> ;
>> (
>>  node["shop"~"dairy"]
>>
>> (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
>>  way["shop"~"dairy"]
>>
>> (45.70234306798271,5.8831787109375,47.864773955792245,10.590820312499998);
>> );
>> out meta center qt;
>>>;
>> out meta center qt;
>>
>> _______________________________________________
>> talk mailing list
>> talk at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/talk
>>
>>
>
>



More information about the talk mailing list