Reprojection of .tiff file using gdal

1.7k Views Asked by At

I need to re-project a .tiff file from EPSG:4326 - WGS 84 - Geographic to EPSG: 32638 (UTM Zone 38N). When I run the code below the output file is a re-projected .tiff half the size of the original one.

# Reprojection

from osgeo import gdal

filename = r"/home/DATA/Test.tif"

input_raster = gdal.Open(filename)
output_raster = r"/home/DATA/Test_UTM38N.tif"

gdal.Warp(output_raster,input_raster,dstSRS="+init=epsg:32638")

1

There are 1 best solutions below

0
jxb On

I have had a similar experience when using the command line version of gdalwarp. Specifying the x and y resolution fixed the problem. I.e., In my case, adding '-tr 1000 1000' to the gdalwarp command produced a reprojected output grid about the same size as the original.

Also note that the gdalwarp doc for the '-tr' option (https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-tr) says:

If not specified (or not deduced from -te and -ts), gdalwarp will generate an output raster with xres=yres, and that even when using gdalwarp in scenarios not involving reprojection.