Closed stefanfluck closed 2 years ago
line 110 and 120 are to be changed:
from osgeo import ogr, gdal
import os
srcds = ogr.Open(filein)
srclayer = srcds.GetLayer()
x_res = int((xmax - xmin) / xres)
y_res = int((ymax - ymin) / yres)
trgds = gdal.GetDriverByName('GTiff').Create('tmp.tif', x_res,y_res,1,gdal.GDT_Float32) ########HERE
trgds.SetGeoTransform((xmin,xres,0,ymax,0,-xres))
band = trgds.GetRasterBand(1)
band.SetNoDataValue(-9999)
if alltouched==False:
gdal.RasterizeLayer(trgds, [1], srclayer, options=['ATTRIBUTE='+burnatt])
else:
gdal.RasterizeLayer(trgds, [1], srclayer, options=['ALL_TOUCHED=TRUE', 'ATTRIBUTE='+burnatt])
trgds=None
ds = gdal.Open('tmp.tif') ################# and HERE
ds = gdal.Translate(fileout, ds)
array = ds.ReadAsArray()
ds = None
os.remove('tmp.tif')
return array
in geodatatools.py, function rasterandcuttlm() creates tmp.tif in the make_static.py location, which is bad. create the tmp.tif file in the tmp folder of the case.