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

gridcell dustin.sampson at timberline.ca
Tue Oct 28 13:46:09 EDT 2008


I'm going to resurrect this post because I think I was unclear on what I
wanted as a result from the process.  So I thought I would try this again
with an example.

Problem:
I have a table in PostgreSQL/PostGIS where some polygons are overlapping, as
illustrated in the picture below in the dark colored areas.  We need to run,
for example, area summaries on polygons so we cannot have overlapping
polygons. 

Overlapping Polygons:

http://www.nabble.com/file/p20212397/overlaps.png 


"Clean" Polygons

http://www.nabble.com/file/p20212397/no_overlaps.png 

Since this is an automated process, I need the process to be robust and
ensure proper results, i.e. why I'm using GRASS and the topological data
model for data processing.  After the layer has been imported and
topologically "cleaned" in GRASS, I need to export the GRASS layer back to
PostgreSQL/PostGIS.  If I export layer 1 to PostgreSQL/PostGIS I get the
result as above.  I want to be able to export out layer 2, so there is not
any overlapping polygons, export the attributes out GRASS with the result
being three tables as follows:

1) Geometry Table:

     gid SERIAL

     the_geom geometry


2) Join Table:

     sp_id INTEGER

     att_id INTEGER


3) Attribute Table:

    gid SERIAL 

    description varchar(200)

    ...


http://www.nabble.com/file/p20212397/table_rel.png 


I've tried using Point in Polygon in PostGIS to relate the attributes and
the geometry to build the table relationship illustrated above but I have
run into some problems with PostGIS's ST_PointOnSurface function not working
in some cases.  Does anyone have any suggestions on a possible process to
create the process above with a combination of GRASS and PostgreSQL?  I
prefer to do most of my geometry related processing in GRASS because of the
robustness.

Thanks for any help,
Dustin



hamish_b wrote:
> 
> Moritz Lennert wrote:
>> 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.
> 
> I just added that to a new PostGIS wiki page, it would be great if
> findings could be summarized there by an expert.
> 
>  http://grass.osgeo.org/wiki/PostGIS
> 
> 
> Hamish
> 
> 
> 
>       
> 
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
> 
> 

-- 
View this message in context: http://www.nabble.com/Export-To-PostGIS-%28with-attributes%29-tp19405378p20212397.html
Sent from the Grass - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20081028/e01f5775/attachment.html


More information about the grass-user mailing list