Hi, when I import a processing script in the QGIS Python console (see parts
of it below), it does not give any error and even displays ("*Executing
algorithm xy*"). However, the output file is not generated, i.e., there is
no file in the output directory. Does anyone know why? Do I need to save
raster output files differently? I also tried by hardcoding the
filepath (resampled
= "C:/result.tif").

# List files in data directory
files = os.listdir(os.curdir)

# Loop over all .tif files in input directory
for f in files:
# Check if file extension is .tif
if os.path.splitext(f)[1]=='.tif':
# Load image as raster layer
fileInfo = QFileInfo(f)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(f, baseName)

# Save raster layer extent
extent = rlayer.extent()
xmin = extent.xMinimum()
xmax = extent.xMaximum()
ymin = extent.yMinimum()
ymax = extent.yMaximum()

# Define name of resampled raster
resampled = str(os.path.splitext(f)[0] + "_" + str(j) + "pixels.tif")

# Run resampling of raster

*processing.runalg('gdalogr:translate',{"INPUT":rlayer, "OUTSIZE":j,
"OUTSIZE_PERC":False, "EXPAND":2, "PROJWIN":"%f,%f,%f,%f" % (xmin, xmax,
ymin, ymax), "OUTPUT":resampled})*


*... code parts removed ...*
# Define name of tiled raster
tiled = str(os.path.splitext(f)[0] + "_" + str(j) + "pixels" + "_tiling_x"
+ str(l+1) + "y" + str(k) + ".tif")

# Run tiling of raster

*processing.runalg('gdalogr:cliprasterbyextent', {"INPUT":reslayer,
"PROJWIN":"%f,%f,%f,%f" % (t_xmin,t_xmax,t_ymin,t_ymax), "OUTPUT":tiled})*


Thank you,

Sophie
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to