[GRASS-user] get ESRI polygon shape with v.out.ogr

Moritz Lennert mlennert at club.worldonline.be
Thu Nov 27 04:30:54 EST 2008


On 27/11/08 03:06, Hamish wrote:
> christian Brandt wrote:
>> I would like to export a vectorized raster theme as a ESRI
>> polygon shape from GRASS 6.3.
>>
>> After vectorization of the raster with r.to.vect I get a
>> vector theme with categories. Within this GRASS-layer, it is
>> also possible to fill areas.
>>
>> Hence I run v.out.ogr using the boundary and area option as
>> well as the ESRI shape option. At the end of the process,
>> GRASS tells me that no categories are written. Visualizing
>> the result within another GIS-software, there is just a line
>> theme and thus no way to display filled areas.
> 
> 
> see the example in the v.out.ogr help page.
> 
> in most vector modules features without category are skipped.
> areas are a virtual feature type made up of a centroid + a boundary.
> in most vector maps boundaries are without category, as centroids hold those.
> 
> no idea why type=boundary,area would fail when type=area works.

This is because boundaries are considered as lines in GRASS and are 
exported as ARC. Areas are exported as POLYGONS. You cannot mix 
different types of features (e.g. lines and polygons) in the same shapefile.

Normally, there should have been a warning. main.c, lines 189ff:

     if (((GV_POINTS & otype) && (GV_LINES & otype)) ||
         ((GV_POINTS & otype) && (GV_AREA & otype)) ||
         ((GV_POINTS & otype) && (GV_FACE & otype)) ||
         ((GV_LINES & otype) && (GV_AREA & otype)) ||
         ((GV_LINES & otype) && (GV_FACE & otype))
         ) {
         G_warning(_("The combination of types is not supported"
                     " by all formats."));


During the export the lines (boundaries) apparently get exported first, 
and then you cannot add the polygons (areas). Here's the full message I 
get when I try this:

GRASS 6.4.svn (nc_spm_06):~ > v.out.ogr kkk type=boundary,area dsn=./ 
layer=testATTENTION: The combination of types is not supported by all 
formats.
Exporting 5 points/lines...
  100%
Exporting 2 areas (may take some time)...
ERROR 1: Attempt to write non-linestring (POLYGON) geometry to ARC type 
shapefile.
  100%
ERROR 1: Attempt to write non-linestring (POLYGON) geometry to ARC type 
shapefile.
4 features written
ATTENTION: 4 features without category were written

The ERROR message seem to be from ogr, not from GRASS.

Conclusion: If you want polygons, use type=area.

Moritz


More information about the grass-user mailing list