I want to write the following python code without the bash command:
# warp coordinates of each tile - to correct the origin of the tif files
for file in tqdm(file_list, desc='warp'):
bashCommand = "gdalwarp -t_srs EPSG:4647 -overwrite " + file + ' ' + file[:-4] + '.tif'
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
I have been trying, but I can not find a working solution. Here is my attempt to solve this:
from osgeo import gdal
input_file = 'input_file_name_string'
output_file = 'output_file_name_string'
input_file = gdal.Open(input_file)
gdal.Warp(output_file, input_file, xRes=5, yRes=5)
dst = None
My ultimate goal is to resolve the error 'Warning 6: gdalbuildvrt does not support positive NS resolution.' and correct the NS resolution with the warp function.
1 Answer 1
At least this (copied and modified from https://github.com/OSGeo/gdal/blob/master/autotest/utilities/test_gdalwarp_lib.py) seems to create a new GeoTIFF
from osgeo import gdal, ogr, osr
ds1 = gdal.Open('base.tif')
dstDS = gdal.Warp('python.tif', ds1)
dstDS=None
It may be enough for turning the y pixel size into negative. Have a try.