zoran-cuckovic/QGIS-visibility-analysis

ValueError: negative dimensions are not allowed

SvenRansijn opened this issue · 5 comments

Hi,
I am trying to run the intervisibility function of the visibility plugin on a 100 by 100 m grid (17914 points) on a landscape to eventually get a network of all the intervisibile points in a landscape. I probably will change this eventually to do this for every raster cell of the DEM.

When I run the plugin it throws this error:

Input parameters:
{ 'DEM' : 'G:/ArcGIS/AsterGDEM_Dom-Rep/DEM dom rep/dem_ruta_colon_utm19.tif', 'OBSERVER_POINTS' : 'D:\Dominican_Republic2\teste_points3.shp', 'OUTPUT' : 'memory:', 'REFRACTION' : 0.13, 'TARGET_POINTS' : 'D:\Dominican_Republic2\teste_points3.shp', 'USE_CURVATURE' : True, 'WRITE_NEGATIVE' : True }

1 Constructing the network
2 Testing visibility
Traceback (most recent call last):
File "C:/Users/svenr/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\viewshed_intervisibility.py", line 221, in processAlgorithm
ws.intervisibility(ob, dem, interpolate = precision)
File "C:/Users/svenr/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\visibility.py", line 383, in intervisibility
raster_class.open_window ((x,y))
File "C:/Users/svenr/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\Raster.py", line 347, in open_window
self.rst.ReadAsArray(*self.gdal_slice ).astype(float)
File "C:\PROGRA1\QGIS31.2\apps\Python36\lib\site-packages\osgeo\gdal.py", line 1944, in ReadAsArray
callback_data = callback_data )
File "C:\PROGRA1\QGIS31.2\apps\Python36\lib\site-packages\osgeo\gdal_array.py", line 263, in DatasetReadAsArray
callback_data = callback_data )
File "C:\PROGRA1\QGIS31.2\apps\Python36\lib\site-packages\osgeo\gdal_array.py", line 339, in BandReadAsArray
buf_obj = numpy.empty([buf_ysize,buf_xsize], dtype = typecode)
ValueError: negative dimensions are not allowed

Execution failed after 1.47 seconds

I looked into the code but I had difficulties to determine what goes wrong. Could you please help me what needs to be changes in order to run these analysis without any problems?

Thank you in advance.

Best wishes,

Sven

Hi, did you re-project your ASTER data in a valid geographic projection?

Hi, thank you for your quick reply, my AsterDEM is projected as follows: EPSG:32619 - WGS 84 / UTM zone 19N - Projected.

OK, that's good... I can only tell that there is a misplacement of point coordinates (they should have been created with "Create viewpoints" routine). If you could attach a sample of your DEM and some of your points, I could take a closer look ...

Dear Zoran,

Sorry for my late reply. I reprojected both the DEM and grid and it seems that this error doesn't show up anymore. However, when I run the analysis I now get this following error:

Traceback (most recent call last):
File "C:/Users/svenr/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\viewshed_intervisibility.py", line 208, in processAlgorithm
o.network(t) #do this after .take which takes points within raster extents
File "C:/Users/svenr/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\Points.py", line 391, in network
self.pt[pt1]["targets"][pt2]=value
MemoryError

Execution failed after 227.08 seconds

As requested, I added the files I use. Thank you very much!
Example.zip

Hello,
"Memory Error" would indicate that here are too many intervisibility lines to test in a single batch. However, 20k points is not that enormous (I didn't have problems ...). If it's a problem of your available live memory, you could divide your points in several files. For instance, make two groups (odd/even IDs) and test intervisibility within groups and then between groups (3 times the analysis), and then combine the results...