[gdal-dev] MULTILINESTRING to MULTIPOLYGON using ogr2ogr

Joaquim Luis jluis at ualg.pt
Mon Nov 26 09:53:48 PST 2012


GMT5 has a tool called gmtstitch that could perhaps help doing the job, 
but I never played enough with it to be more positive about its capacities.

Joaquim

> I want a command line tool to do the same thing that "Feature to 
> Polygon" of ArcGIS or Polygonizer plugin of Quantum GIS does. Is there 
> any tool for this?
>
> 2012/11/26 Peter Halls <p.halls at york.ac.uk <mailto:p.halls at york.ac.uk>>
>
>     Alisson, Hugo,
>
>          I think a reason for the lack of response is that the operation
>     you need is a tad more involved than is supported by ogr2ogr - which
>     performs simple geometrical operations but is really designed to
>     perform format translations.
>
>         To go from a spaghetti of lines to polygons requires the
>     identification of each future polygon boundary, the assembly of the
>     polygon boundary, ensuring that it closes and writing out the new
>     polygon.  This much ogr2ogr does.  To go to multipolygons, however,
>     requires the further assembly of the related polygons into a combined
>     polygon - for example, islands in a lake.  All of this relies on the
>     existence of attribute values to identify what belongs to what.
>     Further complication is involved if the resultant polygons overlap and
>     it is required that these overlaps be identified, although this is not
>     required for a polygon shapefile.
>
>         As this process may require intelligence based upon more complex
>     attribute relationships, it is probably the case that a program
>     (Python, Java, C++, etc) is required to implement the specific logic
>     required.
>
>         If you want to read up on the operations involved, one of the most
>     approachable texts is 'GIS Basics' by Steve Wise (Taylor & Francis,
>     2002).  The good news is that there are calls in the OGR API to
>     implement each of the steps involved.
>
>     Best wishes,
>
>     Peter
>
>     On 26 November 2012 12:24, Hugo Benicio <hbobenicio at gmail.com
>     <mailto:hbobenicio at gmail.com>> wrote:
>     > I'm facing a similar problem when trying to convert a shapefile
>     containing
>     > lines to a shapefile containing polygons.
>     > No progress.
>     > If you solve it, please, let me know!
>     >
>     > Thanks in advance.
>     >
>     >
>     > On Mon, Nov 26, 2012 at 8:47 AM, Alisson Barbosa
>     <alisson.uece at gmail.com <mailto:alisson.uece at gmail.com>>
>     > wrote:
>     >>
>     >> Can anybody help me?
>     >>
>     >>
>     >> 2012/11/23 Alisson Barbosa <alisson.uece at gmail.com
>     <mailto:alisson.uece at gmail.com>>
>     >>>
>     >>> Hi friends,
>     >>>
>     >>> I would like to transform a shape with multilinestring in a
>     shape with
>     >>> polygons using ogr2ogr.
>     >>>
>     >>> Polygon to multilinestring, I use:
>     >>> ogr2ogr -f "ESRI Shapefile" -overwrite
>     "C:/Users/Alisson/Basins3.shp"
>     >>> "C:/Users/Alisson/Basins2.shp" -sql "SELECT * FROM Basins2"
>     -skipfailures
>     >>> -nlt MULTILINESTRING
>     >>>
>     >>> This works.
>     >>>
>     >>> Multilinestring to multipolygon, I use:
>     >>> ogr2ogr -f "ESRI Shapefile" -overwrite
>     "C:/Users/Alisson/polygon.shp"
>     >>> "C:/Users/AlissonContorno30.shp" -sql "SELECT * FROM Contorno30"
>     >>> -skipfailures -nlt MULTIPOLYGON
>     >>>
>     >>> But, this error appears:
>     >>> ERROR 1: Attempt to write non-polygon (LINESTRING) geometry to
>     POLYGON
>     >>> type shapefile.
>     >>>
>     >>> Can you help me?
>     >>>
>     >>> Best regards,
>     >>> --
>     >>> Alisson Barbosa
>     >>> Systems Analyst - FUNCEME
>     >>> M.Sc. in Computer Science - MACC
>     >>> Graduate in Computer Science  - UECE
>     >>>
>     >>>
>     >>
>     >>
>     >>
>     >> --
>     >> Alisson Barbosa
>     >> Systems Analyst - FUNCEME
>     >> M.Sc. in Computer Science - MACC
>     >> Graduate in Computer Science  - UECE
>     >>
>     >>
>     >>
>     >> _______________________________________________
>     >> gdal-dev mailing list
>     >> gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
>     >> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>     >
>     >
>     >
>     > _______________________________________________
>     > gdal-dev mailing list
>     > gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
>     > http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>     --
>     ----------------------------------------------------------------------------------------------------------------
>     Peter J Halls, GIS Advisor & Team Leader Applications Support and
>     Training,
>                    Information Directorate, University of York
>     Telephone: 01904 323806     Fax: 01904 323740
>     Snail mail: Harry Fairhurst Building, University of York,
>                     Heslington, York YO10 5DD
>     This message has the status of a private and personal communication
>     ----------------------------------------------------------------------------------------------------------------
>
>
>
>
> -- 
> Alisson Barbosa
> Systems Analyst - FUNCEME
> M.Sc. in Computer Science - MACC
> Graduate in Computer Science  - UECE
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20121126/a62ccee3/attachment-0001.html>


More information about the gdal-dev mailing list