[GRASS-user] extract a "dinamic" vector layer
Moritz Lennert
mlennert at club.worldonline.be
Thu Aug 1 02:04:16 PDT 2013
[Please keep discussions on the list]
On 01/08/13 09:33, Ing. Pierluigi De Rosa wrote:
> Il giorno mer, 31/07/2013 alle 14.10 +0200, Moritz Lennert ha scritto:
>> On 31/07/13 10:27, Ing. Pierluigi De Rosa wrote:
>>> Dear all,
>>>
>>> I know this problem could be sorted easily using statialdb but I'm
>>> asking if is possible to do the same think in grass.
>>>
>>> I have a vector layer that store db in posgtres.
>>
>> So GRASS vector layer with attributes in PostgreSQL ?
> Yes, exactly.
>>
>>> I'm able to extract
>>> (v.extract) vector feature from this using sql query based on data
>>> stored into an other table 2 into the postgres db.
>>> The question is that if I change a value into the table 2 the vector
>>> extracted does not reflect this changes but I have to run again
>>> v.extract
>>>
>>> Dou you have any suggestion?
>>
>> Depending on the module that you use to treat the result of the
>> v.extract, you might be able to not do a v.extract at all, but just use
>> the 'where' parameter of the module (MarkusM has started integrating
>> that parameter in more vector modules in GRASS 7 [1])
>
> here below is the code I'm using
>
> v.extract -t input=layer_input output=frane_da_visitare type=area
> where="cat in (select table1.cat from table2, table1 where
> table2.idfrana = table1.idfrana) " --o
>
> So, if I understand, as the v.extract is based on a where sql I don't
> have to run this command if some changes in table2 appears?
>
No. v.extract creates a new vector map that will not change if you
change table2 after having run v.extract.
What I meant is : what do you do with frane_da_visitare after having run
v.extract ? If the modules you use to treat the data afterwards have a
where parameter, you could skip v.extract and just use your SQL in the
where clause of the respective modules.
>> If you can use the where parameter, the you can create a view in your
>> database connecting the attribut table of the map with your table 2,
>> then use v.db.connect to connect your map to that view and then use
>> 'where' to work on the features that meet your criteria.
>
> Yes, this is what I do now.
>
Actually, with your solution of 'cat in (select ...)' you don't even
need to create a view.
Moritz
More information about the grass-user
mailing list