How do I extract the polygon of an administrative boundary from an OSM file? asked 04 Oct '11, 09:32 fhedberg aseerel4c26 ♦ |
Here is an online tool to do that : http://polygons.openstreetmap.fr/index.py Give it the id of the administrative relation (or whatever polygon relation), it outputs result in .poly, WKT (Gis format) and a nice image to view it ;-) It also offers geometry simplification and extended buffer. It supports pyramidal relation answered 06 Nov '12, 00:35 sly THANK YOU! It is a great tool!
(28 Feb '14, 09:13)
exec
|
One more addition: http://overpass-api.de/api/interpreter?data=(rel(8638);>;);out; is even faster than the api/.../full call and preferable, because then api/full call causes significant load on the main api. answered 01 Nov '12, 19:02 Roland Olbricht 1
... and see http://wiki.openstreetmap.org/wiki/Overpass_API about more documentation for overpassAPI
(04 Nov '12, 17:38)
stephan75
|
You could use this Perl script: http://svn.openstreetmap.org/applications/utils/osm-extract/polygons/rel2poly.pl It requires a "full" extract of the administrative boundary relation on input and has some limitations (see comments at the top of the file). There's also a much more complex script that extracts all boundaries from a given OSM extract and can optionally write polygons: http://svn.openstreetmap.org/applications/utils/gary68/boundaries.pl If you intend to use the polygon for making extracts, it may be wise to simplify it before use as extracting may take very long if the polygon is too big. Simplifying the polygon might, however, clip off bits, and you might want to look for a simplification algorithm that guarantees that the simplified polygon contains the original polygon. answered 04 Oct '11, 09:40 Frederik Ramm ♦ In addition to Frederick's suggestions above, I used http://osm2mp.googlecode.com/svn/trunk/getbound/getbound.pl to create a boundary polygon for my local district. I didn't simplify it though, and the speed comparisons mentioned at http://wiki.openstreetmap.org/wiki/Tendring(Essex_District)#Data_Extracts suggest polygon vs bbox is over 20 times slower in my case.
(04 Oct '11, 09:47)
EdLoach ♦
|
How I've done it:
I have never tested rel2poly.pl script. I haven't found a scripted way for merging the ways (deleting the tags is possible with osmosis by using a tagtransform filter). I've used successfully this method several times. Hope that helps… answered 04 Oct '11, 09:55 NicolasDumoulin There is a "poly" plugin for JOSM that lets you save your data directly as a .poly file.
(23 Jul '18, 15:23)
Frederik Ramm ♦
|
It depends, of course, of the format you want. Convert as written above.
Repeat Select+Merge as many times as needed
A new layer is useful to display only the data you want to edit or save. Example with your boundary:
With new layer active,
If your admin_level relations contain admin_level+x relations as subareas (a very good idea), you can download whole chunks of boundaries going from one to the parent or child.
BEWARE BEWARE If you delete something aesthetically in a layer, DO NOT File>Update data in that layer, JOSM would actually delete that something from the real data. It is especially important to SAY NO to update suggestions when you close (Delete) a layer, or File>Exit JOSM, or reload a saved file where such condition exists. You might carelessly delete huge amounts of data that way. !!! Always carefully check what JOSM says it's going to do when updating the server. answered 27 Feb '13, 22:19 GentilPapou |
Tried to use http://polygons.openstreetmap.fr/index.py but it doesnt seems working properly with inner rings. Eg. try to look at relation 62657, you will see that it generates WKT with 2 polygons, where both are outer. It can be easily checked here: https://clydedacruz.github.io/openstreetmap-wkt-playground/. So there is web scraping service with geo functionality, which has free tier so can be freely used for conversion. If you need to convert more than 5000 relations, you can compile scraper to run on your local computer / server without limitations. Below is a code for the scraper that do conversion job:
There is nore geo functionality available, you can read documentation answered 23 Jul '18, 12:49 Jako2008 1
OpenStreetMap's data is primarily released as raw data, and only secondarily in the form of web pages. Why anyone would want to scrape web sites using a third party tool instead of just using the data that is readily published, is beyond me.
(23 Jul '18, 15:22)
Frederik Ramm ♦
|
I tried to implement on the maps on the website www.przymorzu.pl administrative outlines for individual towns, but without success :( answered 06 Jan '22, 12:33 Przymorzu |