[OSM-dev] Extracting polygons from planet.osm - take 2
Keith Sharp
kms at passback.co.uk
Fri Mar 16 09:32:57 GMT 2007
On Thu, 2007-03-15 at 22:39 +0100, Frederik Ramm wrote:
> Hi Keith,
>
> > - Takes input from a text file defining a polygon or polygons as a
> > sequence of longitudes and latitudes.
>
> It would be great if there was some sort of mechanism by which a polygon
> could be loaded from an external data source. However geonames only has
> bounding boxes, not exact border polygons, and the web site I used for
> my original script didn't lend itself well to automation (getting the
> file was a multi-step process). So that you could specify
> "--country-borders=ie" and get Ireland, or whatever.
I am not sure what you mean here? Once we have a location in SVN for
the polygon files I could make the script check online for pre-defined
areas such as GB, Germany, France, Europe, etc. Something like:
extract-polygon.pl -a Germany
which would cause the script to fetch:
http://svn.openstreetmap.org/utils/polygons/germany.poly
Is that what you had in mind, or were you thinking about accessing other
websites to obtain polygons?
> > - Can optionally reduce the number of points in a polygon to improve
> > performance, at the expense of accuracy.
>
> The formula I have used in my script, and which you have copied, is
> quite crude. What I did is reduce a polygon of "n" points to
> (n+2*sqrt(n))/3 points, and furthermore drop all polygons which didn't
> exceed a certain size (to get rid of uninhabited micro-islands which
> were included in my source set of polygons).
>
> It is probably not a good idea to use this simplification as-is. Maybe
> you should offer a flag "-c<number>" where number is a "point reduction
> percentage" and then do $pol->simplify($pol->nrPoints*(100-$number)/100)
> - that way the user could specifiy the degree of simplification
> required. And perhaps make sure that only polygons in excess of 100
> points or so are ever simplified.
Thanks for the suggestion. I've updated the code:
- Specify the reduction of points as a percentage on the command line.
- Reduction only works for polygons of >= 100 points.
- No longer drops very small polygons, you get everything you define.
The new version is available in the same place:
http://www.passback.co.uk/maps/extract-polygon.pl
> > I would appreciate it if people could try this out and let me know if it
> > works, and is accurate! If people think this is valuable I would like
> > to create directory in SVN for both the script and a collection of
> > polygon files, I am happy to oversee this. I would also like to create
> > a Wiki page describing the script usage and polygon files.
>
> +1 from me.
Anyone else for or against? How do I get an SVN account?
Thanks,
Keith.
More information about the dev
mailing list