Osmosis/Polygon Filter File Format

From OpenStreetMap Wiki
Jump to: navigation, search
Help
Available languages
Deutsch English

The Osmosis polygon filter file format is supported by Osmosis, osmchange, mapsplit, pbftoosm and osmconvert, as a way of defining extraction polygons.

For OSM Polygons, see Multipolygon relation.

Contents

Example

australia_v
1
     0.1446763E+03    -0.3825659E+02
     0.1446693E+03    -0.3826255E+02
     0.1446627E+03    -0.3825661E+02
     0.1446763E+03    -0.3824465E+02
     0.1446813E+03    -0.3824343E+02
     0.1446824E+03    -0.3824484E+02
     0.1446826E+03    -0.3825356E+02
     0.1446876E+03    -0.3825210E+02
     0.1446919E+03    -0.3824719E+02
     0.1447006E+03    -0.3824723E+02
     0.1447042E+03    -0.3825078E+02
     0.1446758E+03    -0.3826229E+02
     0.1446693E+03    -0.3826255E+02
END
!2
     0.1422483E+03    -0.3839481E+02
     0.1422436E+03    -0.3839315E+02
     0.1422496E+03    -0.3839070E+02
     0.1422543E+03    -0.3839025E+02
     0.1422574E+03    -0.3839155E+02
     0.1422467E+03    -0.3840065E+02
     0.1422433E+03    -0.3840048E+02
     0.1422420E+03    -0.3839857E+02
     0.1422436E+03    -0.3839315E+02
END
END

Bounding-polygon task

Example command to extract a polygon using such a file (if was named country.poly, for Osmosis):

osmosis --read-xml file="planet-latest.osm" --bounding-polygon file="country.poly" --write-xml file="australia.osm"

If using osmchange (program):

cat planet-latest.osm | osmchange -B=country.poly >australia.osm

If using mapsplit:

mapsplit europe.osm.pbf /tmp/output -p=country.poly

If using pbftoosm:

pbftoosm -i=europe.osm.pbf -B=country.poly >switzerland.osm

If using osmconvert:

osmconvert europe.osm.pbf -B=country.poly --out-o5m >switzerland.o5m

In the osmosis code see http://svn.openstreetmap.org/applications/utils/osmosis/trunk/areafilter/src/org/openstreetmap/osmosis/areafilter/common/PolygonFileReader.java

Premade polygon files

CloudMade offers polygon files for countries in their downloads service.

Some files for Germany and Austria are in SVN (via TRAC or via SVN).

Files for Russia, Russia's first level administrative regions (buffered and not) and some surrounding countries are here (also includes the description for QGIS extension to generate such files): http://gis-lab.info/qa/osm-poly.html (RU)

Converting to/from POLY format

SVN (via TRAC or via SVN) contains a number of scripts to convert to/from POLY files. These include:

Poly ↔ OSM, GPX is a web tool that uses polyconvert.pl to convert OSM XML, GPX or WKT (via file or pasting) to a POLY file.

getbound.pl will convert a boundary relation into a POLY file [1].

GPX-to-POLY from geocaching-dresden.de is a web tool to convert an uploaded GPX file to a POLY file.

Buffering the Polygon file

Using Quantum GIS

This tutorial shows how to create buffered POLY files using Quantum GIS and the OSM Poly Export plugin. The example uses a country border shape file, but the technique can be applied to any feature you can load into Quantum GIS.

Command line

In case you would like to use a Polygon file of an area with a certain buffer distance, it is possible to use the tool 'polybuffer.py', which can be found here: [2]. For the buffering PostGIS is being used. Requirements:

The instructions can be read by typing "./polybuffer -h" on the command prompt.

Personal tools
Namespaces
Variants
Actions
site
Toolbox