[GRASS-user] Appending a map to another

tommaso tommasodb at googlemail.com
Thu Dec 25 22:22:42 PST 2014


Thanks for the reply. I noticed the appending maps with sample data works  
without problems.
By the way, the step with v.category option=sum to change the categories  
of the patched map and avoid overlapping categories - as described here:  
http://grass.osgeo.org/grass64/manuals/v.patch.html - is not needed. This  
seems to be done automatically by v.patch.

My problem is, that the whole does not work with my data.
Basically I'm using Grass to polygonize a line set. I want to import the  
lines, polygonize, set a attribute in order the distinguish later the  
data, and than export the polygons. Unfortunately the attribute of the  
output map are messy.

I uploaded on dropbox a script with test data:
https://dl.dropboxusercontent.com/u/18796392/test_grass.zip

I tried with grass6.4 and grass7.0, but same result.

Regards, Tommaso

On Tue, 09 Dec 2014 08:24:28 +0100, Markus Metz  
<markus.metz.giswork at gmail.com> wrote:

> On Mon, Dec 8, 2014 at 2:37 PM, tommaso <tommasodb at googlemail.com> wrote:
>> Hello, I'm trying to simply append a map to other map, without any sort  
>> of
>> geometric operations as merge or intersects, just the original  
>> geometries
>> with theirs original attributes.
>> I'm using grass 6.4 on ubuntu 14.04, sqlite driver
>> This is what I already tried:
>>
>> # input maps are poly2 and poly3
>> # First, I change the categories of one of the maps (poly3) to avoid
>> categories conflicts:
>> # see http://grass.osgeo.org/grass64/manuals/v.patch.html
>> v.category in=poly3 option=sum cat=10000 out=poly3_category --overwrite
>
> To be safe, you should specify the feature type: v.category  
> type=centroid.
>
>> g.remove vect=poly3
>> g.rename vect=poly3_category,poly3
>> # I update the cat column of the table as well (why this is not done
>> automatically by v.category??)
>> v.db.update poly3 col=cat qcol="cat+10000"
>>
>> # now the to maps are patched together
>> db.droptable -f table=polygons
>> v.patch -e input=poly2,poly3 output=polygons --overwrite
>>
>> # export to result as geojson:
>> v.out.ogr in=polygons olayer=polygons format=GeoJSON  
>> dsn=/tmp/polygons.json
>> type=area
>
> This exports all features, with and without category. That means holes
> in areas are converted to true polygons without categories. Use the -c
> flag to export only true areas with ctegories.
>
>>
>> The geometries of the result map polygons.json look good, but the  
>> attributes
>> are messy: I can not distinguish which records come from poly2 and which
>> ones from poly3.
>
> The records with cat >= 10000 should come from poly3. Is the cat
> attribute not available in the json export?
>
>> Many records have only empty attributes. What I'm doing
>> wrong?
>
> See above, v.in.ogr -c should help.
>
> Markus M


More information about the grass-user mailing list