R
R
Rodion Yurchenko2017-04-10 21:43:19
JavaScript
Rodion Yurchenko, 2017-04-10 21:43:19

How to programmatically get the coordinates of a polygon (area) from OSM?

Good afternoon
Is there an API for OSM that can return the coordinates of a polygon by its name?
For example, I give Kyrgyzstan Ivanovka - and the coordinates of the Ivanovka polygon are returned to me (OSM has them =)) - no matter in what format?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rodion Yurchenko, 2017-04-11
@aassdds

Found the answer
If anyone is interested - then here is the source code

$q = "Киргизия ивановка";
        $url = "http://nominatim.openstreetmap.org/search?q=".urlencode($q)."&format=json&polygon_geojson=1";
        $ch = curl_init($url); // such as http://example.com/example.xml
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $data = curl_exec($ch);
        curl_close($ch);
        $a = json_decode($data);

P
pfg21, 2017-04-10
@pfg21

overpass-turbo dig. It made a search and selection of OSM elements in a certain area (you will need to at least know approximately where to look). output format is configurable by osm json etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question