[GRASS-user] Export Centroids

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@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

Command: INSERT INTO "blk" (wkb_geometry , "cat", "comments") VALUES
(GeomFromEWKT('SRID=32768;LINESTRING (1361632.899105372838676
586307.90450647752732)'::TEXT) , 2, 'Polygon 2')

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 (1361538.573653233936056
586446.606141098076478)'::TEXT) , 1, 'Polygon 1')
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 (1361538.573653233936056
586446.606141098076478)'::TEXT) , 2, 'Polygon 2')

4 features written

http://www.nabble.com/file/p19861164/blocks.png

--
View this message in context: http://www.nabble.com/Export-Centroids-tp19861164p19861164.html
Sent from the Grass - Users mailing list archive at Nabble.com.

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@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

I've already tried to shapefile. It builds a shapefile and tries to add
linestrings. I'm guessing its a bug in v.out.ogr. I think I have a
temporary work around until this is fixed. I use v.type centroid to point
and then use v.out.ogr. Seems to work but I'm still testing.

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@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

Command: INSERT INTO "blk" (wkb_geometry , "cat", "comments") VALUES
(GeomFromEWKT('SRID=32768;LINESTRING (1361632.899105372838676
586307.90450647752732)'::TEXT) , 2, 'Polygon 2')

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 (1361538.573653233936056
586446.606141098076478)'::TEXT) , 1, 'Polygon 1')
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 (1361538.573653233936056
586446.606141098076478)'::TEXT) , 2, 'Polygon 2')

4 features written

http://www.nabble.com/file/p19861164/blocks.png

--
View this message in context: http://www.nabble.com/Export-Centroids-tp19861164p19879641.html
Sent from the Grass - Users mailing list archive at Nabble.com.