[GRASS-user] Select specific layer when copying vector map

Johannes Radinger johannesradinger at gmail.com
Tue Aug 9 06:39:44 PDT 2016


Indeed, v.extract using the layer option did the job!
Thank you Moritz!

Probably, I can then use v.category option="chlayer" to change the layer
Nr. 3 to Nr. 1!?


On Tue, Aug 9, 2016 at 2:23 PM, Moritz Lennert <mlennert at club.worldonline.be
> wrote:

> On 09/08/16 13:48, Johannes Radinger wrote:
>
>> Hi,
>>
>> I'd like to create from an existing GRASS vector map that has 3 layers
>> (with three attribute tables) a new vector map that has only one
>> layer and its associated attribute table (here the information related
>> to layer 3).
>>
>> What I am doing so far (in python):
>>
>> # First copy the map to a new one and copy table (that of layer 3)
>> # that I want to re-connect to new map
>> grass.run_command("g.copy",
>> overwrite=True,
>> vector="oldmap,newmap")
>> grass.run_command("db.copy",
>> overwrite=True,
>> from_table="table_layer3",
>> to_table="table_layer3_copy")
>>
>> # Second delete all tables of the newmap
>> for i in [1,2,3]:
>> grass.run_command("v.db.droptable",
>> flags="f",
>> map="newmap",
>> layer=i)
>>
>> # Third reconnect a table to the newmap
>> grass.run_command("v.db.connect",
>> overwrite=True,
>> map="newmap",
>> table="table_layer3_copy")
>>
>> When I check in the attribute table manager, there is only one layer
>> listed (layer 1).
>> Similarly, v.db.connect reports:
>> v.db.connect -p map=newmap
>> Vector map <newmap> is connected by layer <1/table_layer3_copy> table
>> <table_layer3_copy> in database [...]
>>
>> However, in d.vect I can still select from all three layers that were in
>> the old map (-1,1,2,3),
>> and all of them can be displayed (with -1 specified)?
>> So does may newmap have three layers or only one?
>>
>
> 3. Layers are defined by category values, not by attribute tables.
>
>
>> How can I make the third layer the default layer 1 and remove all other
>> layers?
>> Or is there a way to copy a vector map with just a single layer and its
>> associated table specified as default?
>>
>
> Try v.extract instead of g.copy.
>
> Moritz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160809/dd8448f0/attachment.html>


More information about the grass-user mailing list