Watersheds shapefile related error - Annual water yield - InVEST 3.9.0

Hi NatCap team,

I’ve been running into a “shapely.errors.WKBReadingError” when I run the Annual Water Yield model. The following are some troubleshooting steps I have tried.

  1. I re-created the required raster files using an area of interest shapefile that fully enclosed the watershed shapefile in spatial extent.

  2. I checked the watershed shapefile in QGIS3 using the Topology Checker plugin for the rule “must not have invalid geometry”.

Can you please help me understand the attached error log?

Thank you.

P.S.:The model runs without error when I use a different watershed shapefile (for a smaller watershed within the same area of interest)

InVEST-Hydropower-Water-Yield-log-2021-03-09–21_14_58.txt (10.9 KB)

Hi @denzilroy,
It looks like the original error is Points of LinearRing do not form a closed linestring. There’s almost certainly something wrong with your geometry, but it’s strange that the geometry checker wouldn’t catch it. If you zoom in to the vertices, sometimes one of them doesn’t line up perfectly and the lines intersect instead, which isn’t allowed. If you’re still stuck, feel free to send me your data and I can look into it. You can upload it here or share it privately by email: esoth @ stanford.edu

I’m not familiar with this plugin, but I’ve had luck using the built-in Vector menu > Geometry Tools > Check Validity tool from QGIS. It has a “Method: GEOS” option for the topology rules, which is useful because shapely should be following the same GEOS rules.

I’ve also had luck with the “buffer by 0” trick. Could be worth a try.


Thank you @dave and @esoth for responding with suggestions.

@dave, I tried the built-in check validity tool, and Method: GEOS, but the output did not show up an error. I also tried the “buffer by 0” trick, and it worked. I used the Grass module “v.buffer”, set buffer distance to 0 in map units, and left all other options at default. Now the water yield model was able to run without errors. Thank you.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.