zoran-cuckovic / QGIS-visibility-analysis

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

AttributeError: 'NoneType' object has no attribute 'GetProjection' #31

Closed plutext closed 3 years ago

plutext commented 4 years ago

I'm trying to get started, but running into the above error. Any clues please?

QGIS version: 3.8.0-Zanzibar
Qt version: 5.13.0
GDAL version: 3.0.0
GEOS version: 3.7.2-CAPI-1.11.2 b55d2125
PROJ version: Rel. 6.1.0, May 15th, 2019
Processing algorithm…
Algorithm 'Viewshed' starting…
Input parameters:
{ 'DEM' : 'contextualWMSLegend=0&crs=EPSG:3857&dpiMode=7&featureCount=10&format=image/png&layers=public_NSW_Elevation&styles=default&tileMatrixSet=default028mm&url=https://maps.six.nsw.gov.au/arcgis/rest/services/public/NSW_Elevation/MapServer/WMTS/1.0.0/WMTSCapabilities.xml', 'OBSERVER_POINTS' : 'tmp foo.shp', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'REFRACTION' : 0.13, 'USE_CURVATURE' : False }

Traceback (most recent call last):
File "/home/jh/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ViewshedAnalysis/algorithms/viewshed_raster.py", line 184, in processAlgorithm
dem = rst.Raster(raster_path, output=output_path)
File "/home/jh/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ViewshedAnalysis/algorithms/modules/Raster.py", line 51, in __init__
self.crs = crs if crs else gdal_raster.GetProjection()
AttributeError: 'NoneType' object has no attribute 'GetProjection'

Execution failed after 0.01 seconds

Loading resulting layers
Algorithm 'Viewshed' finished
plutext commented 4 years ago

I used "save raster later as" GeoTIFF to actually fetch the data from WMTS. Now I get ValueError: could not broadcast input array from shape (4,401,401) into shape (401,401) at https://github.com/zoran-cuckovic/QGIS-visibility-analysis/blob/master/algorithms/modules/Raster.py#L347

Input parameters:
{ 'DEM' : 'elevation_cuttagee/elevation_cuttagee.vrt', 'OBSERVER_POINTS' : 'Point?crs=EPSG:3857&field=ID:string(255,0)&field=observ_hgt:double(10,4)&field=radius:double(10,2)&uid={e51972fe-cf51-4865-88d5-46174408ed5a}', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'REFRACTION' : 0.13, 'USE_CURVATURE' : False }

Traceback (most recent call last):
File "/home/jh/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ViewshedAnalysis/algorithms/viewshed_raster.py", line 245, in processAlgorithm
interpolate = precision > 0)
File "/home/jh/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ViewshedAnalysis/algorithms/modules/visibility.py", line 159, in viewshed_raster
dem.open_window (point["pix_coord"])
File "/home/jh/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ViewshedAnalysis/algorithms/modules/Raster.py", line 347, in open_window
self.rst.ReadAsArray(*self.gdal_slice ).astype(float)
ValueError: could not broadcast input array from shape (4,401,401) into shape (401,401)

Execution failed after 0.60 seconds

Loading resulting layers
Algorithm 'Viewshed' finished
zoran-cuckovic commented 4 years ago

Hello, You seem to pull data through a web connection (WMS). Note that typical WMS data is stored as image (.png in your case), it should be converted in a single band elevation data for visibility analysis. Your geotiff file still has multiple bands (red, green, blue and transparency). You should convert to one band tiff.

See https://gis.stackexchange.com/questions/62133/how-to-export-only-one-band-from-an-image-using-gdal. You can then go to Raster >> Conversion >> Translate in QGIS and add the code from the link to get something like gdal_translate -b 1 input.tif output.tif

nathanielrindlaub commented 4 years ago

Hey there, I'm having the same issue AttributeError: 'NoneType' object has no attribute 'GetProjection', and I double checked to make sure my DEM geotiff contained a single band, and it does:

Band 1 | RepresentationType=THEMATICSTATISTICS_APPROXIMATE=YESSTATISTICS_MAXIMUM=661STATISTICS_MEAN=84.99807083937STATISTICS_MINIMUM=0STATISTICS_STDDEV=138.73283275105STATISTICS_VALID_PERCENT=78.29
-- | --
More information | AREA_OR_POINT=AreaDataType=Generic
Dimensions | X: 1508 Y: 966 Bands: 1

Any thoughts on how to troubleshoot further?