1

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.

gene
55.8k3 gold badges115 silver badges196 bronze badges
asked Mar 4, 2020 at 15:41

1 Answer 1

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.

answered Mar 4, 2020 at 16:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.