I want to perform a viewshed analysis on multiple points in a shapefile. I'm working with a solution as seen in this post by Jakob
I modified his code such that I am able to pass the extents into r.viewshed. this is given by the variable "extcoordStr" in the below code
import processing from PyQt4.QtCore import QFileInfo rasterLayer = qgis.utils.iface.activeLayer() pointLayer=QgsMapLayerRegistry.instance().mapLayersByName('Tasmania_select_two') i=0 for ft in pointLayer.getFeatures(): point = ft.geometry().asPoint() coordStr = '%d,%d' % (point.x(),point.y()) coordArray = coordStr.split(',') #extent generation, +- 50,000Metres from point origin(coordStr) xMin = int(coordArray) - 50000 xMax = int(coordArray) + 50000 yMin = int(coordArray) - 50000 yMax = int(coordArray) + 50000 #Type juggling to get xmin,xmax,ymin,ymax extcoordStr = str(xMin) + ',' + str(xMax) + ',' + str(yMin) + ',' + str(yMax) outputViewshed = 'C:\Users\nightswitch57\Desktop\Script\viewshed_%i.tif' % i #running viewshed with observer and target heights set to 20Metres at max distance of 50Km outputs_0=processing.runalg("grass7:r.viewshed", rasterLayer,coordStr,20,20,50000,False, extcoordStr,0,outputViewshed) i = i + 1
problem when I click run, my computer freezes up a bit task manager shows GRASS is been used but at the end there is nothing in the output folder. in Jakobs answer he uses, I feel this might be the reason why I do not have any output in the folder I specified
outputViewshed = 'd:/temp/viewshed_%i.tif' % i
while I use
outputViewshed = 'C:\Users\nightswitch57\Desktop\Script\viewshed_%i.tif' % i
Also in addition I would much rather have the viewshed named after the point features "Site ID" which is in a column within the point shapefile (Tasmania_select_two) as currently it is supposed to name each viewshed as the number of the point feature. to achieve this i'm guessing I would need to append the point features Site ID to the outputViewshed variable somehow but I don't know how to.