4

I'm frustrated with v.generalize trying to simplify polygons. Those polygons stem from ArcGIS's raster to vector function (imported into GRASS from Shapefile), so they are pretty zigzag like this:

Zigzaged

Trying to simplify them with

v.generalize input=polygons -c method=douglas threshold=0.1 layer=-1 output=polygons_dp

Leads to a weird result like this:

simplified

Some isles and even partially borders remain untouched. Tried v.clean, v.build.polylines before simplifying, but same result.

  • Why are you trying with GRASS and not with other tools such QGIS simplify geometry? – Below the Radar Feb 24 '14 at 13:52
  • I'm trying with GRASS because I need topology. Simplifying the Shapefile with QGIS' built-in simplifying tool leads to holes between polygons. – Lars Feb 24 '14 at 13:58
  • Ok I understand. In such case I use FME, but maybe you can use GRASS v.clean to clean the topology after simplifying the Shapefile with QGIS if it is easier. It is just an idea... – Below the Radar Feb 24 '14 at 14:01
  • Tried that also already but got stuck with eliminating the holes in GRASS: Not only holes are eliminated but small polygons that fall under threshold also. I read about this workaround but I would like to clarify the v.generalize issue first. Maybe it's a bug in GRASS!? – Lars Feb 24 '14 at 14:06
  • DP belongs to the simplification algorithms while you want to use smoothing (also provided by v.generalize)... – markusN Mar 3 '14 at 17:26
9

I finally got a workaround for the problem, based on Micha's suggestion (thank you!) to import the raster to GRASS and vectorize it there.

1 Import Raster:

r.in.gdal input=raster.tif output=raster

2 Vectorize (option -s leads to slightly smoothed 45-degree edges):

r.to.vect -s input=raster output=vector_blue feature=area

3 Generalize with Douglas to get rid of excessive points:

v.generalize input=vector_blue -c method=douglas threshold=0.05 output=vector_green

4 Smooth with Chaiken's algorithm to get smoother curves:

v.generalize input=vector_green -c method=chaiken threshold=0.1 output=vector_orange

5 Remove small polygons (area in m² if you have a lat/lon region):

v.clean tool=rmarea thresh=1000000000 input=vector_orange output=vector_red

The result as animated gif

2

If you can go back to the original raster, and import that into GRASS, then the module r.to.vect has a "-s" flag for smoothing the output vector boundaries. No generalize needed. Check this StackExchange question for a way to convert raster to vector in Arc and get smoother boundaries.

  • As far as I understand r.to.vect -s leads only to 45 degree edges. That's not enough smoothing since I want to smooth my vectors further in a third step, using chaiken's algorithm (the vectors are going to be prepared for print). Therefore I have to reduce the number of points first by douglas's algorithm. My question is if there's a bug in GRASS's v.generalize causing the weird result above (leaving out some isles and boundarys) or if there are other possibilities. – Lars Feb 25 '14 at 7:25
0

Back to this topic: you really wanted to apply "smoothing" here, see http://grass.osgeo.org/grass70/manuals/v.generalize.html#smoothing and not what you have tried (douglas). Use instead e.g. "chaiken":

http://grass.osgeo.org/grass70/manuals/v.generalize.html#smoothing-example

BTW: we added the possibility to generate an "error" map which contains those lines which cannot be simplified due to topological conflicts. Like this you can now easily identify issues in order to optimize the control parameters for simplification, smoothing, or displacement.

  • Thanks Markus! Yes, I really wanted smoothing. The idea behind first using DP simplification ist that the chaiken algorithm (which is quite slow on large datasets) speeds up if it's feeded with a simplified version of the original dataset. My input data is a worldwide raster with 1 arc-minute resolution (00:01:00). It would be great if you could point me to other possibilities of speeding up chaiken smoothing (and avoid topological conflicts). – Lars Sep 22 '14 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.