[GRASS-user] Importing vectors (polygons) without building topology

Tom Russo russo at bogodyn.org
Sun Jun 25 15:08:00 EDT 2006


On Fri, Jun 23, 2006 at 12:44:13AM +0200, we recorded a bogon-computron collision of the <hernan.deangelis at glocalnet.net> flavor, containing:
> Dear list,
> 
> I have a bunch of PostGIS layers (polygons) that I want to import into GRASS. 
> These polygons represent palaeogeographic features and therefore they 
> necessarily overlap over some regions (different entities are distinguished 
> by attributes in the attribute table). Since v.in.ogr automatically builds 
> topology by default, a secondary layer is generated during import where the 
> the overlapping sectors of the polygons are cut and stored. Whereas this 
> might be useful for a wide range of applications it is certainly not 
> desirable in my case, since it destroys the palaeogeographic representation. 
> My question is therefore: how can I import these shapefiles and avoid topology 
> building at the same time? I understand that exporting the tables as text and 
> importing them using v.in.ascii might be an option, but I would rather prefer 
> to preserve the carefuly designed attribute tables as they are, without 
> having to regenerate them.

If it were me, I think I would probably do it in stages by using the GDAL tool
"ogr2ogr" to make separate files of non-overlapping polygons before attempting
to pull them into GRASS.  That is, pull out files filled only with
polygons representing the same type of entity using an SQL-like select on
the attributes.  Once you have such things, each should be easily importable
into GRASS as separate vector files.

I don't use PostGIS, so am not familiar with the correct way to specify
PostGIS layers in OGR commands.  If the layer were already in a shapefile
format, you'd do something like this, assuming for example that the
distinguishing attribute was called "entity_type" and had string values:

ogr2ogr -where 'entity_type="SomeParticularType"' reduced.shp original_full.shp

which would produce a new shapefile reduced.shp containing only features with 
entity_type having value SomeParticularType.

You could construct considerably more complex "where" clauses to taste, so
long as when you do so you're only selecting non-overlapping polygons.  Doing
this you should be able to import all your data without having GRASS impose
topological restrictions on it, but also without having to resort to skipping
the topology building.

Naturally, you'll wind up with many different polygon vector files instead of
just one, but each will only represent one type of entity.

-- 
Tom Russo    KM5VY     SAR502  DM64ux         http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236  SKCC#2002
"And, isn't sanity really just a one-trick pony anyway? I mean all you get is
 one trick, rational thinking, but when you're good and crazy, oooh, oooh,
 oooh, the sky is the limit!"  --- The Tick




More information about the grass-user mailing list