7

When I polygonize a raster, I very often have 'pixels' holes/interior ring that touches exterior ring.

An example:

POLYGON((5 0, 10 0, 10 10, 0 10, 0 0, 5 0, 3 3, 5 6, 7 3, 5 0))

image

It's defined as an invalid geometry in the OGC geometry specifications.

In QGIS, how to fix this?

1 Answer 1

8

I've found the solution here but for PostGIS: https://gis.stackexchange.com/a/15301/93097 and I've test it in Spatialite/Virtual layers, and it works.

Bellow the code I use with a shapefile 'my_layer' with one field "DN":

SELECT DN, ST_Buffer(geometry, 0.0) as geometry
FROM my_layer;
5
  • Hi, where do you use this code ?
    – Robagb
    Feb 7, 2022 at 11:55
  • WHat is DN? can you explain the context?
    – Robagb
    Feb 7, 2022 at 12:02
  • All the answers of your comments are already in my answer. Feb 7, 2022 at 15:18
  • Hi, what is postGis, a pluggin? what is DN, do you use the field calculator? sorry it is very blur to me I am new to QGIS...
    – Robagb
    Feb 7, 2022 at 16:10
  • So, I advise you to search on internet a little about SQL and databases (with spatial extensions). Feb 7, 2022 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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