<div dir="ltr"><br><br>On Sat, Aug 25, 2018 at 10:56 AM Micha Silver <<a href="mailto:tsvibar@gmail.com">tsvibar@gmail.com</a>> wrote:<br>><br><div>> I think I have a series of steps that will allow you to separate the "inner" boundaries and generalize only those. The idea is based on using the v.to.db module, with the "sides" option to add the cat number of each area to the left and right of each boundary. Outer boundaries will have "-1" (nothing on that side) for the left or right sides. Then you can split out the inner boundaries with a v.extract using a "where" clause.</div><div><br></div><div>nice approach, but it could be simplified because v.generalize has a where option, i.e. no need for v.extract:<br></div>><br>> Somewhat convoluted, but here you are as regular grass command, not in python.<br>><br>> (My example below is from the sample nc_basic_spm_grass7 location. I tested with the geology map.)<br>><br>> # Make a copy and add cats to the boundaries in layer 2<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > g.copy vect=geology,my_geol<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.category my_geol layer=2 type=boundary option=add output=my_geol2<br>><br>> # Add attribute columns for the left and right sides in layer 2, and populate from the areas in *layer 1*<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.db.addtable my_geol2 layer=2 column="left integer,right integer"<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.to.db my_geol2 layer=2 option=sides column=left,right query_layer=1<br><div><br></div><div>generalize inner boundaries</div><div>GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.generalize input=my_geol2 method=douglas output=my_geol2_smooth thresh=1000 type=boundary layer=2 where="left > -1 and right > -1" --o</div><div><br></div><div>done</div><div><br></div><div>Markus M</div><div><br></div><div>></div>> # Now use the left and right cat value to separate the inner and outer boundaries<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.extract my_geol2 layer=2 out=inner_bndry type=boundary where="left<>-1 and right<>-1"<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.extract my_geol2 layer=2 out=outer_bndry type=boundary where="left=-1 or right=-1"<br>><br>> # Convert inner boundaries to lines for smoothing, and run generalize<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.type input=inner_bndry out=inner_lines layer=2 from=boundary to=line<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.generalize inner_lines method=douglas output=inner_lines_smooth thresh=1000 --o<br>><br>> # Convert back to boundary and merge back with the outer boundary and recreate area centroids<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.type inner_lines_smooth out=inner_bndry_smooth from=line to=boundary layer=2 --o<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.patch input=outer_bndry,inner_bndry_smooth output=merge_smooth --o<br>> GRASS 7.4.0 (nc_basic_spm_grass7):~ > v.centroids merge_smooth output=merged_areas layer=2 option=add<br>><br>><br>> You probably will have to do some manual cleaning of the result, since the smoothed inner boundaries might no longer exactly intersect with the untouched outer boundary due to overshoots, etc.<br>><br>> If you try this, let us know how it went.<br>><br>> Regards, Micha<br>><br>><br>><br>> On 08/24/2018 06:43 PM, Daniel McInerney wrote:<br>><br>> Hi List,<br>><br>> I'm using v.generalize in a script (excerpt included below) to smooth<br>> the boundaries of a polygon vector dataset. In the attached example<br>> (input_vector.png), I would like to *only* generalize the internal lines<br>> (blue), and leave the external boundary (green line) unchanged. I<br>> thought that the flag, '-l' might provide this functionality, but<br>> unfortunately the resulting external boundary is changed significantly<br>> (attached vgeneralize_output.png).<br>><br>> Is this functionality available in v.generalize or is there another way<br>> that this could be achieved in GRASS?<br>><br>> Thanks in advance.<br>><br>> Best regards,<br>> Daniel.<br>><br>> ##run generalisation (step: 1 - douglas)<br>> gscript.run_command('v.generalize', flags='l', overwrite=True,<br>> input='segments', output='segments_douglas', method='douglas', threshold=1)<br>><br>> ##run generalisation (step: 2 - sliding average)<br>> gscript.run_command('v.generalize', flags='l', overwrite=True,<br>> input='segments_douglas', output='segments_douglas_slide',<br>> method='sliding_averaging', threshold='2', look_ahead='9', slide='0.1',<br>> iterations='3')<br>><br>> ##run generalisation (step: 3 - snake)<br>> gscript.run_command('v.generalize', flags='l', overwrite=True,<br>> input='segments_douglas_slide', output='segments_douglas_slide_snake',<br>> method='snake', threshold='3', alpha='1', beta='1')<br>>  <br>>  <br>><br>><br>><br>> _______________________________________________<br>> grass-user mailing list<br>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>><br>><br>> -- <br>> Micha Silver<br>> Ben Gurion Univ.<br>> Sde Boker, Remote Sensing Lab<br>> cell: +972-523-665918<br>><br>> _______________________________________________<br>> grass-user mailing list<br>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a></div>