I'm trying to use r.viewshed in PyQGIS to perform Viewshed analysis on a point placed on a raster layer. The algorithm seems to run correctly, as no errors come up, but the output .tif file is not created, and I've tried it using multiple different locations, using absolute and relative paths, both with no luck.
Here is a snippet of my python code below.
rasterLayer is the QgsRasterLayer object, the main raster of the project for the viewshed to be done upon.
pointPath = r"C:/Users/me/Documents/ZVIs/zvi.tif"
maxRange = 500
pointElevationFromDTM = 100
coordStr = "230049.90500026295, 2841692.311715042"
result = processing.run("grass7:r.viewshed",
{'input' : rasterLayer,
'coordinates': coordStr,
'observer_elevation': pointElevationFromDTM,
'max_distance': maxRange,
'memory': 300,
'output': pointPath})
if result['output']:
print("Viewshed analysis completed. Output saved to:", pointPath)
else:
print("Viewshed analysis failed")
if os.path.isfile(pointPath):
print(f"ZVI file was created.")
else:
print(f"ZVI file was not created")
I added in some checks at the end so you can see what I mean. It seems that an output is being created, just not saved for whatever reason.
I've been able to print out the processing feedback after the answer by @Taras. The main errors I can see are below:
ami_single_temp_name: G_mkstemp() failed: : No such file or directory
Assertion failed: 0, file ami_stream.cpp, line 91
ERROR: Raster map <outputb422948942aa4ef6a24c5ce880e5fe23> not found
ERROR: Raster map or group <outputb422948942aa4ef6a24c5ce880e5fe23> not found
But when using isValid() on the raster layer it is returning True.
Where do I go next?
I've googled the errors but haven't had any luck yet.

coordStrlies within therasterLayer. The CRS of therasterLayeris EPSG:32615 - WGS 84 / UTM zone 15N. How would I know if therasterLayerCRS matches thecoordStr? I've just ran it with a maxRange of 10, which should definitely lie within the rasterLayer, and it gave the same issues. – oliver Feb 22 '24 at 11:19SR_50M_alaska_nad.tiffound athttps://download.qgis.org/downloads/data/, and it is behaving exactly the same, when tested withcoordStr = "1100248.3159823148, 6360501.794258764", withpointElevationFromDTM =100andmaxRange=10. Hope this helps. – oliver Feb 22 '24 at 12:20