[Gdal-dev] converting lines to polygones with ogr

Frank Warmerdam warmerdam at pobox.com
Mon Jul 31 09:28:56 EDT 2006


C.Strobl at dlr.de wrote:
> hi all,
>  
> is there a possibility to convert with ogr lines to polygones, for example like
>  
> ogr2ogr -f  "ESRI Shapefile" -nlt POLYGON c:\home\dat_poly.shp c:\home\dat_line.shp
>  
> or does somebody know another open source solution for this task.
>  
> thanks for your help and greetings from munich
> christian

Christian,

There is no direct way to convert lines to polygons with ogr2ogr.
However, there is a demonstration python script for doing this at:

   http://www.gdal.org/srctree/pymod/samples/assemblepoly.py

This particular example assumes polygons are being built from a bunch
of edges.  In your case you are presumably building them from a single
linestring.  So basically you would only want to pass one linestring in
the argument to BuildPolygonsFromEdges.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org




More information about the Gdal-dev mailing list