[GRASS-user] Pygrass vector package: write geometric feature in a specific layer

Laurent C. lrntct at gmail.com
Tue Dec 2 07:41:01 PST 2014


Hello all,

I'm writing a GRASS module with pygrass to import data from a text file
into a new vector map.
Those data have topological relationships: they are nodes and links of a
sewer network. But those objects may have different types of attributes.
For example a link could be a pipe or a pump.
Therefore I think that the use of vector layers is the right way to store
those data.

With pygrass I managed to set DB links and import the attributes in
different tables.
But the only way I've found to change the layer of geometric features is
with .open(mode='w', layer=X). This works well for one layer, but I've to
write different objects in different layers.
I tried to close the map and re-open it with another layer, but if I pass
mode='rw', the map refuse to open because the layer not yet exist, and with
mode='w', it overwrite the existing map.

I know there is a way to create a new map for each layer and then use
existing GRASS modules to "merge" them into a single map, but I feel that
this is overly complex.

So my question is: Is there a way to decide which layer to write new
objects, and change this layer during the import process?

I'm using grass70-svn with the following version of libgis:
libgis Revision: 62395
libgis Date: 2014-10-26 18:17:27

Thanks for you help.

Regards,
Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20141202/cc3567ae/attachment.html>


More information about the grass-user mailing list