I have a raster layer and a vector point layer. I calculated distance between center each pixel and each point based on @YoLecomte and @mgri, this link and xunilk, this link. For each pixel there are multi distance,I want to sum this multi distance for each pixel in raster layer and write them into a new raster file. In the last portion of this code to sum distances for each pixel, what is the error?
def pixel2coord(x, y): xp = (pixelWidth * x) + originX + (pixelWidth/2) yp = (pixelHeight * y) + originY + (pixelHeight /2) return QgsPoint(xp, yp) pntLayer = QgsVectorLayer("/Data/points.shp","pointLayer",'ogr') feats = [ feat for feat in pntLayer.getFeatures() ] # Open tif file ds = QgsRasterLayer("/Data/study.tif","Study") pixelWidth = ds.rasterUnitsPerPixelX() pixelHeight = ds.rasterUnitsPerPixelY() # extent of the layer ext = ds.extent() originX ,originY = (ext.xMinimum(),ext.yMinimum()) src_cols = ds.width() src_rows = ds.height() drive = gdal.GetDriverByName( 'GTiff' ) src_ds = gdal.Open("/Data/study.tif") outBand = src_ds.GetRasterBand(1) outData = numpy.zeros((src_cols, src_rows), numpy.float32) pntRstList =  for i in range(0, src_cols): for j in range(0, src_rows): rspnt = pixel2coord(i,j) pntRstList.append(rspnt) sumP =  for rpoint in pntRstList: for ft in feats: vgeometry = ft.geometry() rgeometry = QgsGeometry.fromPoint(rpoint) dist=vgeometry.distance(rgeometry) # get distance between cell center to point if dist < 200: sumP.append(dist) print sumP