Answer the question
In order to leave comments, you need to log in
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
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);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question