[GRASS-user] converting lines to polygons

Micha Silver micha at arava.co.il
Fri Sep 24 08:31:53 EDT 2010


On 09/24/2010 12:45 AM, Bryan Keith wrote:
>>
>>      
>> Orange boundaries are duplicates - overlapping lines - that GRASS
>> topology doesn't allow.
>> You should be able to get rid of these with:
>> "v.clean in=... out=... tool=break,bpol,rmdupl"
>> But I've never had good luck with this.
>> The alternative that might work better for you:
>> Re-import the layer from the original shapefiles (or where ever they
>> came from) but use the "type=line" option to v.in.ogr. (No centroids
>> will be created)
>> Now do v.clean on this new GRASS vector, using tool=snap,break,rmdupl.
>> Next use
>> "v.type ... type=line,boundary"
>> to convert the (cleaned) lines to boundaries, and then
>> "v.centroids ... opt=add"
>> to create area centroids inside each closed boundary.
>>      
> Micha,
>
> Yes, thank you, that worked!  Here's what I did:
>
>    
Cheers.
Although I think I misled you a bit. I was mistaken about the orange 
line color in the digitizer. It simply indicates a boundary that is 
wholly shared by two adjacent areas. *Not* a topological error.
In any case, importing polygon shapefiles first as lines (not 
boundaries), doing the topology cleanup, and then convert to boundaries 
and add centroids seems to be the smoother way to go.
-- 
Micha
> v.in.ogr -o dsn=C:\path\to\shapefile\test_ln.shp output=testm_ln type=line
> v.clean input=testm_ln output=testmclean_ln tool=snap,break,rmdupl
> thresh=0.2,0,0
> v.type input=testmclean_ln output=testmclean_bnd type=line,boundary
> v.centroids input=testmclean_bnd output=testmclean_py option=add
>
> Thanks for all the help.
>
> Bryan
> -- 
>    
Micha Silver
Arava Development Co. +972-52-3665918
http://surfaces.co.il




More information about the grass-user mailing list