1

I recently wrote a Python script that uses Esri's viewshed (arcpy.sa.Viewshed) and it seemed to work fine until I compared the output (area size) to what ArcMap's Viewshed_sa itself (which seems to point to arcpy.gp.Viewshed_sa instead) gives me and I was shocked by the difference of the total area.

e.g. a Viewshed clipped to a buffer of 10km gives me a visible area of 2,119,389 square meters in my script but executed with the !SAME! params gives me 1,898,640 square meters

Please see the screenshot for a clearer explanation. Green is the resulting area that is shared by arcmap itself and the script execution. Yellow is the area that is only part of the script's result. Blue is the area that is only part of arcmap's result.

Now I tried a few things to get both results a bit closer together (e.g. if I completely remove the extent for the viewshed execution in my script it gets a little bit better, but it's still off by a few percent) I even harvested all environment settings from my ArcMap instance and fed them to my script. It, sadly, didn't change a thing and results are still off by ~10%

result comparison

(the Python console output does not compare standalone script to ArcMap)

Edit 1 (ad. Fezter's comment):

  • The projected coordinate system is called 'BMN M31'
  • Calculation of the total area is done by a searchcursor (I also compared the area through the statistics function within the toc)
  • All the environment settings of the script are the same as in the application (I literally copied them over)
  • The results here are rasters directly resulted from the viewshed function, later on I tend to create polys - but the problem is already there, in the rasters itself (I edited the title from polys to rasters through)
  • As for the function calls there is really nothing fancy going on: It's a simple arcpy.sa.Viewshed (script-wise) and a Viewshed call through the toolbox' tool in arcmap. The call looks like this: arcpy.sa.Viewshed(dom, single_pnt, z_factor="1", curvature_correction="CURVED_EARTH", refractivity_coefficient="0.13")
  • 1
    What coordinate system is being used on your inputs? How are you calculating areas? It looks like you're converting raster to polygon? What are you settings in this process? Are your environment settings the same in both processes? Can you edit your post to include some code? – Fezter Aug 22 '17 at 1:50
  • Thank you for your input, Fezter. I hope I edited the thread sufficiently according to your questions. – petrochelli Aug 22 '17 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.