[GRASS-user] Export Centroids

Moritz Lennert mlennert at club.worldonline.be
Wed Oct 8 04:24:01 EDT 2008


On 07/10/08 17:48, gridcell wrote:
> Is there a way to export centroids (v.out.ogr) from a GRASS layer?
> 
> I have a layer that was originally overlapping polygons in a shapefile.  I
> imported the shapefile into GRASS and build/clean geometry, resulting in 4
> polygons.  I want to export the centroids of these polygons, and was hoping
> to have returned the polygon's attributes and a point geometry representing
> the centroid (4 features).   I tried the following but the command never get
> any results....
> 
> v.out.ogr input=blk at PERMANENT type=point,centroid 'dsn=PG: host=localhost
> user=postgres dbname=test' olayer=blk layer=1 format=PostgreSQL 
> 
> I get the following in my output...
> 
> 6 Boundary(ies) found, but not requested to be exported. Verify 'type'
> parameter.
> 
> Exporting 9 points/lines...
> 
> ERROR 1: INSERT command for new feature failed.
> ERROR:  geometry requires more points
> 
> Command: INSERT INTO "blk" (wkb_geometry , "cat", "comments") VALUES
> (GeomFromEWKT('SRID=32768;LINESTRING (1361422.480504325358197
> 586604.790284495218657)'::TEXT) , 1, 'Polygon 1')
> ERROR 1: INSERT command for new feature failed.
> ERROR:  geometry requires more points

This seems to be an issue with ogr's conversion to PostGIS. You could 
try exporting to a shapefile and importing that to PostGIS...

Moritz


More information about the grass-user mailing list