I'm doing some tests with the v.clean but getting some results that I don't really know if I am the one doing something wrong or what.

As you can see in the image bellow I created 3 features, one with an area quite small compared to the others. I was trying to verify if the described here (https://www.oreilly.com/library/view/learn-qgis-/9781788997423/01a0973e-ce1d-474f-bcdc-2d4605c7b67a.xhtml) would work, and the feature with values bellow the threshold would merge with the neighboring polygon with the longest common boundary.

It simply did not happen. Why is that? Am I doing something wrong?

The area of the smaller polygon is 37.69 and the threshold set in v.clean was 40 with the cleaning tool rmarea selected.

enter image description here

  • Can you make your test polygon available so that we can try to duplicate the problem? – Micha Feb 16 at 14:33
  • sure! you can download the rar here. Unfortunately it is not the same vector layer, since I was using a temporary layer, but I tried to do the same steps on this one and had the same results! drive.google.com/file/d/1P-N8xJ2HfEIxsO1ARZseFOXg1plc1x_8/… – Felippe M. Feb 16 at 15:47
  • 1
    I ran the v.clean tool on the layer in QGIS and the middle poly merged with the polygon on the left. In the input I checked line, boundary and area; in the tools I checked break, snap, bpol and remarea, in the thresholds I set 0,1,0,50 and the v.in.ogr snap of 1 with an area output. – johns Feb 16 at 19:35
  • It worked, thanks!!! – Felippe M. Feb 16 at 19:39

Here are the steps I did to successfully clean the shapefile, and remove the small polygon in the center:

First create a new GRASS location based on the coordinate system of the shapefile, and import the shapefile into GRASS:

# Start GRASS from the command line, using the shapefile to define the location
grass -c teste.shp ./Felippe
# Check projection
g.proj -p
name       : SIRGAS 2000 / UTM zone 23S
datum      : sirgas2000
ellps      : grs80
proj       : utm
zone       : 23
south      : defined
towgs84    : 0,0,0,0,0,0,0
no_defs    : defined
epsg       : 31983
unit       : meter
units      : meters
meters     : 1

# Import shapefile, and check the features
v.import teste.shp output=teste
v.info -t teste
micha@RMS:teste$ v.info -c teste
Displaying column types/names for database connection of layer <1>:

# Three areas, and an attribute column for area
# Check areas:
v.db.select teste

# Just to be sure, let's recalculate areas:
v.to.db teste opt=area column=area --o
WARNING: Values in column <area> will be overwritten
Reading areas...
Updating database...
3 categories read from vector map (layer 1)
3 records selected from table (layer 1)
3 categories read from vector map exist in selection from table
3 records updated/inserted (layer 1)
micha@RMS:teste$ v.db.select teste
# !!! Ooops, the small area is almost 50 sq m. !!!

# Run v.clean with thresh=50
v.clean input=teste output=teste_clean tool=break,rmarea thresh=0,50 --o
# Check topology:
v.info -t teste_clean
# Now only two areas!

So the only problem, I think, was the calculated areas of the polygons in your shapefile. Result:

  • I'm sorry, but I still have no idea what have you done. Did you use the Grass in processing tools? Or was it in the plugin Plugins -> GRASS -> New mapset? Cause whenever I try to use it in the plugin I get stuck in the module cause the plugin doesn't let me choose a "name of the input vector map". So it doesn't let me run, cause it's missing this value, and it doesn't let me choose whatever. Can you elaborate a litttle bit more or send me some references that I could be reading? I can't find anything that helps me about it on google. – Felippe M. Feb 16 at 19:36
  • 1
    Ah, sorry. I ran the above without QGIS at all, directly in GRASS. Often, when a QGIS Processing module is not working, it helps to first try directly in GRASS to isolate where the problem lies. I entered the above commands in the GRASS console. However in the case at hand, it's very simple: the area calculations in the shapefile seem wrong, somehow. If you just enter a threshold of 50 for the v.clean rmarea tool, it should work for you. – Micha Feb 17 at 10:41

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.