[GRASS-user] converting lines to polygons
Markus Metz
markus.metz.giswork at googlemail.com
Mon Sep 27 14:29:34 EDT 2010
Micha Silver wrote:
> 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.
I object because
1. you would need to replicate the cleaning steps done by v.in.ogr
which has, amongst others, a snapping option
2. adding centroids will add centroids to all areas, also those that
where holes in polygons provided by OGR, e.g. a waterbodies shapefile
with lakes and islands in lakes: the islands are not waterbodies and
should not get a centroid
3. you will loose attributes because there is no (easy) way to link
any attributes coming with the shapefile to newly generated centroids,
e.g. land cover/land use shapefiles
Markus M
>>
>> 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
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
More information about the grass-user
mailing list