zoran-cuckovic / QGIS-visibility-analysis

Quantum GIS plugin for visibility analysis
GNU General Public License v3.0
73 stars 18 forks source link

problem with qgis 2.18.19 - empty raster #16

Closed silettog closed 3 years ago

silettog commented 6 years ago

Hi I never had problems using the plugin, neither with DEM or point file. Now when generating a binary viewshed (cumulative) i get a raster with 0 values, and this python error:

2018-06-16T08:49:41 1 Traceback (most recent call last): File "C:/Users/Gianni/.qgis2/python/plugins\ViewshedAnalysis\viewshedanalysis.py", line 197, in run Algo) File "C:/Users/Gianni/.qgis2/python/plugins\ViewshedAnalysis\doViewshed.py", line 331, in Viewshed RasterPath= str(QgsMapLayerRegistry.instance().mapLayer(Raster_layer).dataProvider().dataSourceUri()) AttributeError: 'NoneType' object has no attribute 'dataProvider'

Thank you for any help or suggestion! Gianni

QGIS version 2.18.19 QGIS code revision 3a17f72ba5 Compiled against Qt 4.8.5 Running against Qt 4.8.5 Compiled against GDAL/OGR 2.2.4 Running against GDAL/OGR 2.2.4 Compiled against GEOS 3.5.0-CAPI-1.9.0 Running against GEOS 3.5.0-CAPI-1.9.0 r4084 PostgreSQL Client Version 9.2.4 SpatiaLite Version 4.3.0 QWT Version 5.2.3 PROJ.4 Version 493 QScintilla2 Version 2.7.2

zoran-cuckovic commented 6 years ago

This seems to be a problem with QgsMapLayerRegistry , that is with the DEM layer. I wouldn't have any other clue (?) There is a new version available for QGIS 3 : do you have problems with the new version ?

mixedbredie commented 6 years ago

I can confirm the same empty raster being created in 2.18.20 where it used to work in 2.18.12. Using the plugin (0.6.2) in QGIS Master 3.3 I get the following error:

Processing algorithm…
Algorithm 'Viewshed' starting…
Input parameters:
{ 'DEM' : 'dem_10mdtm.tif', 'OBSERVER_POINTS' : 'pri_school.shp', 'OUTPUT' : 'pri_5k.tif', 'REFRACTION' : 0.13, 'USE_CURVATURE' : False }

Traceback (most recent call last):
File "C:/Users/user/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\viewshed_raster.py", line 233, in processAlgorithm
interpolate = precision > 0)
File "C:/Users/user/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\visibility.py", line 159, in viewshed_raster
dem.open_window (point["pix_coord"])
File "C:/Users/user/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ViewshedAnalysis\algorithms\modules\Raster.py", line 296, in open_window
self.rst.ReadAsArray(*self.gdal_slice ).astype(float)
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\osgeo\gdal.py", line 1944, in ReadAsArray
callback_data = callback_data )
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\osgeo\gdal_array.py", line 263, in DatasetReadAsArray
callback_data = callback_data )
File "C:\OSGEO4~1\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 0.73 seconds

Loading resulting layers
Algorithm 'Viewshed' finished

My raster and vector layers are in EPSG:27700 and I have set the ID, observ_hgt and radius fields correctly.

mixedbredie commented 6 years ago

I've done some further research after reading the documentation and found that:

I now get valid rasters output.