Changes between Version 4 and Version 5 of FAQVector


Ignore:
Timestamp:
Oct 15, 2007, 12:33:54 PM (17 years ago)
Author:
warmerdam
Comment:

add splitting geometry types into separate shapefiles example

Legend:

Unmodified
Added
Removed
Modified
  • FAQVector

    v4 v5  
    3737}}}
    3838
     39== How do I translate a mixed geometry file to shapefile format? ==
     40
     41Some formats (such as ESRI Shapefiles) only allow one type of geometry in
     42a layer, while other formats (such as DGN, MapInfo, GML) allow a mixture of
     43geometry types within a single layer.  Direct attempts to translate result
     44in errors like this:
     45
     46{{{
     47% ogr2ogr out.shp mixed.dgn
     48ERROR 1: Attempt to write non-linestring (POLYGON) geometry to ARC type shapefile.
     49ERROR 1: Terminating translation prematurely after failed
     50translation of layer elements
     51}}}
     52
     53The first step in dealing with such a problem is to discover what
     54geometry types exist in the source file.  For a DGN file called
     55mixed.dgn, with a layer called elements this can be accomplished
     56using the following OGR SQL command (see
     57[http://www.gdal.org/ogr/ogr_sql.html OGR SQL] tutorial for details):
     58
     59{{{
     60% ogrinfo -ro mixed.dgn -sql 'select distinct ogr_geometry from elements'
     61INFO: Open of `mixed.dgn'
     62      using driver `DGN' successful.
     63
     64Layer name: elements
     65Geometry: Unknown (any)
     66Feature Count: 1
     67Layer SRS WKT:
     68(unknown)
     69ogr_geometry: String (0.0)
     70OGRFeature(elements):0
     71  ogr_geometry (String) = LINESTRING
     72
     73OGRFeature(elements):1
     74  ogr_geometry (String) = POLYGON
     75
     76OGRFeature(elements):2
     77  ogr_geometry (String) = POINT
     78}}}
     79
     80This file has point, line and polygon geometries.  Each will need to be
     81translated to a separate output file. 
     82
     83{{{
     84% ogr2ogr out_point.shp mixed.dgn -where 'ogr_geometry = "POINT"'
     85% ogr2ogr out_line.shp mixed.dgn -where 'ogr_geometry = "LINESTRING"'
     86% ogr2ogr out_poly.shp mixed.dgn -where 'ogr_geometry = "POLYGON"'
     87}}}
     88
     89
     90