11

enter image description here

I am trying to create a viewshed using the graphical modeler, the first part involves creating the viewpoints which works fine, however when I create the viewshed I get the following error. Also, when I do the exact same process outside of graphical modeler it works fine.

Traceback (most recent call last):

File "C:/Users/Ben/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\viewshed_raster.py", line 245, in processAlgorithm interpolate = precision > 0) File "C:/Users/Ben/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\visibility.py", line 178, in viewshed_raster data /= distance_matrix #all one line = (data -z - mxcurv) /mx_dist FloatingPointError: divide by zero encountered in true_divide

Error encountered while running Viewshed

4
  • Welcome to GIS.SE. What else does your model contain?
    – Erik
    Oct 22, 2019 at 11:45
  • Hi Erik, I have added an image of the modeler. It starts by adding regular points over the extent of a polygon, these points within the polygon are extracted and then used to create viewpoints (with height and radius info). I then try to run a viewshed on it and that's when I get the error: FloatingPointError: divide by zero encountered in true_divide
    – Ben Foster
    Oct 22, 2019 at 11:55
  • "When I do the exact same process outside of graphical modeler it works fine." - This is very common with the graphical modeler. The graphical modeler does not always work well. Sometimes it helps to make the input a permanent layer rather than a temporary one. Also sacrificing a chicken and burning some sage might help.
    – csk
    Oct 22, 2019 at 18:17
  • I have tried making the layer permanent, still comes up with the same viewshed. The only two inputs in the viewshed algorithm are the 'Observer Locations' (Viewpoints) and the 'Digital Elevation Model'; I have tried multiple combinations and different data, tiff. vrt. asc. all come out with the same error: FloatingPointError: divide by zero encountered in true_divide
    – Ben Foster
    Oct 24, 2019 at 8:39

2 Answers 2

7
+25

You should include your DEM as an input within that model. I have reproduce your model and just add that entry, and it worked.

Here is the image of the model: enter image description here

Here is a final screenshot showing the result: enter image description here

Here you can get the model, the project and the layers I have used. Hope it works for you. Link to drive.

By the way, I did this in QGIS 3.8

7
  • I tried the model you uploaded with all the data you shared, unfortunately I keep getting the same Traceback File"C:/Users/Ben/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\viewshed_raster.py", line 245, in processAlgorithm interpolate = precision > 0) File"C:/Users/Ben/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\visibility.py", line 178, in viewshed_raster data /= distance_matrix #all one line = (data -z - mxcurv) /mx_dist FloatingPointError: divide by zero encountered in true_divide
    – Ben Foster
    Nov 11, 2019 at 10:31
  • Do you know what this traceback error means: FloatingPointError: divide by zero encountered in true_divide
    – Ben Foster
    Nov 11, 2019 at 10:34
  • Which QGIS version are you using ? I tryed in other pc, with qgis 3.10 and It works perfectly. Nov 11, 2019 at 11:37
  • Version 3.10. I have just tested it on my colleagues computer and it worked fine. Something is wrong with my QGIS but not sure what, I have downloaded 3.10 a couple of times now, any ideas?
    – Ben Foster
    Nov 11, 2019 at 14:03
  • 1
    @BenFoster if you can (ask your admin if not), do a complete and clean reinstall. Meaning also reset (delete/backup) your QGIS profile within C:/Users/.../appdata/roaming/qgis/qgis3.
    – MrXsquared
    Nov 12, 2019 at 19:26
2

Take a look in this blog entry. This blog entry explain how to make processing algorythm.

And make essence from this blog post. In you algorytm you need parameters: elevations raster and observer points, and global observer height along with analysis radius. From that you are making viewpoints and run viewshed.

1
  • I did look at that blog entry before making this model, the create viewpoints algorithm now already includes the input option for the parameters you mention (elevations raster and observer points, and global observer height along with analysis radius). The create viewpoints works fine, I have even tried creating the viewpoints first outside of the modeler, leaving just the viewshed algorithm in the modeler, but it still comes up with the same error?
    – Ben Foster
    Oct 24, 2019 at 8:30

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.