[GRASS-dev] OGR write access

Martin Landa landa.martin at gmail.com
Fri Oct 16 05:00:17 EDT 2009


2009/10/16 Markus Metz <markus.metz.giswork at googlemail.com>:
>> I am thinking how to implement direct write access to OGR datasources
>> from the user point of view. One approach would be to implement global
>> flag '--u' for updating existing vector map (i.e. OGR datasource).
>> E.g.
>> v.out.ogr input=test dsn=. type=point -n
>> v.external dsn=. layer=test output=test
>> v.random out=test n=1000 --u
> Not sure if I understand right: updating an existing vector map, be it OGR
> or native, works for some but not all modules. Some modules first copy all
> or selected primitives from input to output, then modify output, then write
> output support files. That could cause duplication of all primitives and a
> bogus result for some modules like e.g. v.generalize, v.clean, v.select.

I was speaking about empty vector maps. Anyway '--u' could be useful
also for non-empty vector maps. Then you could use e.g. v.select
without need to patch maps. E.g.

v.select ain=imap1 bin=imap2 out=omap12 ope=within
v.select ain=imap3 bin=imap4 out=omap34 ope=contains
v.patch in=omap12,omap34 out=map

with '--u' flag.

v.select ain=imap1 bin=imap2 out=omap12 ope=within
v.select ain=imap3 bin=imap4 out=omap12 ope=contains --u

Of course you can get bogus (duplicate categories, etc.) with --u, it
depends on the data you are working with. Generally '--u' should
implement 'append' mode instead of just overwriting files. Of course
there are some modules which basically cannot support update mode.

>> this could work also for native format
>> v.edit map=test tool=create
>> v.random out=test n=1000 --u
>> Or to add new parameters 'dns/format' which would be used only for OGR
>> format, not for the native one.
>>  v.random out=test n=1000 format=ESRI_Shapefile dns=.
> How about a slight modification of Radim's suggestion:
> v.random out=./shapefiles/@OGR,layer=test,format=ESRI_Shapefile
> or something similar so that the out option can easily be parsed?

yes, anyway it requires adding 'format' modules to the all vector
modules which have 'output' parameter defined and modifying
Vect_open_new() to pass format parameter, etc.



Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

More information about the grass-dev mailing list