The data I have are ESRI Floating Point Data (so they are a raster type). The path I provided is a fake path, so that I don't show my real system paths.
I know that my code works with vector data, as I wrote this script, just for other data-types (.shp, .gpkg). Therefore, I assume, that the algorithm doesn't work with the flt-type.
... and indeed it doesn't. For reprojecting raster data, there is the algorithm warp
.
So what I did yesterday was to use batch processing for applying the warp-function to the flt-data. The decision to not adapt the python script to warp the data but to use the batch-processing-functionality was just that it was a good opportunity to try it out (never worked with batches before).
I have a couple of .flt-files and I would like to reproject them to another CRS. In QGIS desktop, you can load the .flt-files by just dragging and dropping the file.
However, when I try to load the files in PyQGIS it says:
Could not load source layer for INPUT: path/to/3257559305385.flt not found
My code is just a function which uses the processing module. Is it somehow possible to load .flt-data in PyQGIS?
def reprojectFLTfiles(inputfolderpath, outputfolderpath, crs):
for fltfile_name in os.listdir(inputfolderpath):
if '.flt' in fltfile_name:
if 'xml' not in fltfile_name:
print(fltfile_name)
INPUT = inputfolderpath + '/' + fltfile_name
OUTPUT = outputfolderpath + '/' + fltfile_name
print(INPUT)
print(OUTPUT)
processing.run("qgis:reprojectlayer",
{'INPUT':INPUT,
'TARGET_CRS':crs,
'OUTPUT':OUTPUT
}
)
inputfolderpath
look like? Does the print statement print the the correctINPUT
path string? Can you verify it withos.path.exists()
? As a better practice, I would encourage you to useos.path.join()
instead of the string arithmetic.