[GRASS-user] Export To PostGIS (with attributes)

Moritz Lennert mlennert at club.worldonline.be
Wed Sep 10 12:02:29 EDT 2008


On 10/09/08 16:25, gridcell wrote:
> What I have been currently doing is...
> 1) v.in.ogr (import only geometry column from postgresql/postgis)
> 2) v.clean
> 3) v.out.ogr (layer 2)
> 4) In postgresql I run a point in polygon (PIP) on the table created in step
> 3)
> 5) Use the ST_Contains function with the original ("dirty") table to create
> another table of attributes, which includes the unique id from the spatial
> table.
> 
> My result in the case of two polygons that partially overlap...
> 
> Spatial Table                            Attribute Table
> 
> gid   wkb_geometry              sp_id   gid   parcel_name ....
> 1       XXXXXX                       1       1       Tom's Parcel          
> 2       XXXXXX                       2       2       Jane's Parcel
> 3       XXXXXX                       2       3       Tom's Parcel
>                                           3       4        Jane's Parcel

What exactly do you want to make happen in the case of overlaps. There 
is a fundamental difference between the PostGIS format which is 
non-topological and the internal GRASS format which is topological and 
which, thus, does not really allow for overlapping polygons. You can 
digitize them, but they are not really useful...

> I was hoping that all the processing could have been done in GRASS rather.


You cannot directly process a PostGIS table in GRASS. GRASS has its own 
internal vector format. If you want to do everything in GRASS, you have 
to stop after step 2. You can link a GRASS layer to a PostgreSQL table, 
though.

Moritz


More information about the grass-user mailing list