[GRASS-user] two questions: snap and close lines

Markus Metz markus.metz.giswork at googlemail.com
Fri Jan 27 12:53:10 EST 2012


On Fri, Jan 27, 2012 at 1:02 PM, Paolo Cavallini <cavallini at faunalia.it> wrote:
> Il 26/01/2012 20:41, Markus Metz ha scritto:
>> On Mon, Jan 23, 2012 at 8:00 PM, Paolo Cavallini <cavallini at faunalia.it> wrote:
>>> Hi all.
>>> A couple of issues I ran into today:
>>> - I have a layer with some good and some bad polygons; how do I import it into GRASS
>>> letting the bad ones snapping onto the good ones, and not vice versa?
>>
>> You could try v.edit, otherwise it will be hand-editing with a digitizer.
>>
>> With topological vectors, snapping one set of polygons to another set
>> of polygons does not make sense, because there are no polygons in
>> topological vectors, only shared boundaries. That is probably the
>> reason why this functionality is not available in grass.
>
> Hi Markus M,
> thanks for your reply. Let me explain better my use case:
> - I have a shapefile, with (almost) adjacent polygons
> - if I import them, I can snap the almost adjacent lines, and get common boundaries
> - the problem is that I cannot control which of the two adjacent lines stay fixed,
> and which one moves to it
> - I know that of the two polygons, one is good (certified), the other is not; so I
> want the first to remain fixed, and have the other snap to it.
> Did I explain myself better?

The only two options I can think of is giving v.edit a try, otherwise
hand-editing.
>
>> For contour lines, you would need to patch the vector with contour
>> lines with a vector created with v.in.region type=line, then break
>> lines at intersections, convert lines to boundaries, add centroids.
>> This assumes that not closed contour lines have endpoints exactly at
>> the extents of the vector, e.g. if the western edge of the contour
>> vector is 30 and there is an open contour line ending at say
>> 29.99999999, this will not work. If the contour lines were produced
>> with r.contour, this should work.
>
> In practice:
>
> #set the region around contour
> v.in.region output=region_line type=line
> v.patch input=contour,region_line output=patched
> v.clean input=patched at paolo type=line tool=snap thresh=1 output=patched_1
> v.clean input=patched at paolo type=line tool=break output=patched_break
> v.type input=patched_break at paolo output=patched_break_boundaries type=line,boundary
> v.centroids input=patched_break_boundaries output=polygons
>
> It mostly works, but apparently breaking does not (only closed rings become different
> polygons).

Why does breaking not work? Maybe you need remove duplicates and clean
small angles at nodes. You could try
v.clean input=patched at paolo type=line tool=snap,break,rmdupl,rmsa
thresh=1,0,0,0 output=patched_1
or in grass 7
v.clean input=patched at paolo type=line tool=snap thresh=1 output=patched_1 -c

Markus M


More information about the grass-user mailing list