2

I have been trying to run a Viewshed Analysis on a point layer containing approximately 174 points on a DEM compiled from the SRTM 30m Elevation data available at http://dwtkns.com/srtm30m/

After I compiled a merged GeoTIFF from the required tiles I ran the Viewshed Analysis plugin on QGIS but after numerous attempts and changes in the input parameters I keep getting a MemoryError.

2018-01-02T12:20:46 1   Traceback (most recent call last):
          File "C:/Users/Frans_2/.qgis2/python/plugins\ViewshedAnalysis\viewshedanalysis.py", line 197, in run
            Algo)
          File "C:/Users/Frans_2/.qgis2/python/plugins\ViewshedAnalysis\doViewshed.py", line 409, in Viewshed
            mx_vis = numpy.zeros((full_window_size, full_window_size))
        MemoryError

Does anybody here have any idea why this is happening. I have updated the plugin to the latest available version (0.5.4) already. It seems other users have had similar errors but there is no clear answer to be found anywhere on how it was actually solved.

Project CRS is set to: WGS 84 EPSG:4326

1
  • Why don't you use VRT in stead of merged GeoTiff? May 31, 2018 at 1:40

1 Answer 1

1

Problem

It looks like the plugin script tries to create an empty raster (called mx_vis) to store whether or not a location is visible from your points. Assuming that the script has already loaded your DEM in memory it seems as if it is simply running out of memory.

Likely cause:

I am currently working on a SRTM viewshed analysis in the Afghanistan region. A raster of 6805 x 6806 pixels (roughly 100x100km) with a pixel depth of 16 bits (such as the SRTM):

bitsNeeded = rowcount * columCount * pixelDepth
GigaByteNeeded = bitsNeeded / 8 (to bytes) / 1024 (to kilobytes) / 1024 (to megabytes) / 1024 (to gigabytes)

For my 100x100km SRTM area this means about 0.086 GB of memory is needed only to load the SRTM data. If the script also creates an empty raster (or several of them, e.g. for each observer point) you can run out of memory with desktop computers. Although it will most likely not happen in my case, if you have a larger dataset this can happen.

Solution

To solve this problem you could do the following:

  • Use the above formula or this calculator to calculate the maximum size of the raster you can use as input
  • Rewrite the plugin script yourself so that the memory error is avoided by creating 'virtual memory on your disk'. This would require some Python skills.

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.