1

Is there a way within QGIS to find a specific numbered edge of a polygon? I'm running a shapefile through R, and st_is_valid reports "Loop 0: Edge 263884 crosses edge 263886" - how can I find those particular edges to rectify the problem?

The particular code in R that checks the validity is this simple block:

data <- st_read("shapefile_path.shp")
data <- sf::st_make_valid(data) #to fix problems r can just fix itself
st_is_valid(data, reason=TRUE)
head(data) #so I know which particular polygon st_is_valid is reporting an error with

Note that running QGIS's own Check Validity process results in no output to the resulting 'invalid' layer, so apparently QGIS doesn't consider this polygon invalid.

0

1 Answer 1

0

The non-programmatic way to do that is to install the Topology Checker Plugin. then, Define a crossing rule. Then it will show you all the polygons that are invalid because of crossing.

If it doesn't work, I suppose to run a simplify processing on that layer with a very small tolerance value. The exported polygon should be fine. You can do the same with polygonize too.

6
  • Topology checker finds no problems with my polygons with a 'check invalid geometry' rule, which is the closest thing I can find to a 'crossing rule'. Besides, I know which polygon it is - I need to know where on its boundary the issue is, as it's a highly complex polygon and I can't just manually scan the outline and expect to find it.
    – Sjiveru
    Nov 30, 2021 at 1:09
  • Is it a self-intersecting polygon that raises the error?
    – Ash
    Nov 30, 2021 at 1:18
  • I suppose to run a simplify processing on that layer with a very small tolerance value. The export should be fine. You can do the same with polygonize too.
    – Ash
    Nov 30, 2021 at 1:23
  • 1
    I'm not entirely sure. That seems to be the issue st_is_valid reports, but the error I get in R trying to use the shapefile may or may not suggest the same thing - it returns Invalid number of points in LinearRing found 2 - must be 0 or >= 4.
    – Sjiveru
    Nov 30, 2021 at 1:23
  • 1
    None of that is working, sadly, but as my original data seems to work fine with a different map projection, I suspect the issue is something unrelated. I've asked a somewhat different question over on StackOverflow now. Thanks for trying to help, though!
    – Sjiveru
    Nov 30, 2021 at 1:54

Your Answer

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

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