0

I am using GDAL to transfrom ortho from one EPSG to other EPSG. In my case I have used EPSG:32610 which is in (m) and transformed into EPSG:2227 which is in (us-ft). I am able to transform it using below script:

def convert_ortho_into_user_epsg(input_file, output_file, source_epsg, target_epsg):
import os
from osgeo import gdal

dataset = gdal.Open(input_file)
gdal.Warp(output_file, dataset, srcSRS='EPSG:{}'.format(source_epsg), dstSRS='EPSG:{}'.format(target_epsg))
print("Successfully converted ortho from EPSG {} to EPSG {}.".format(source_epsg, target_epsg))

# Close dataset
dataset = None

But when I use gdalinfo int output_file it changes the pixel size. Is it expected?

Moreover the origin and size that I get from the input file is: Size is 10053, 11080 Origin = (608158.944684999994934,4171303.732194999698550) when I transformed it into 2227 then I get: Size is 10345, 11344 Origin = (6193167.632184272632003,2073506.717460004147142)

I also tried to transformed the origin of input file manually using different code from 32610 to 2227, there I get the origin as: 6193187.041177868, 2073506.717459998.

What could be the possible reason?

1 Answer 1

2

Re-projected image is typically rotated and somehow stretched exactly because the coordinate systems are different. Is is a common misbelief that the origin that gdalinfo reports for the original image and for the re-projectet image are presenting the same location on Earth. That is not the case, gdalinfo reports always the location of the top-left pixel of the image as origin even if it happens to be on a nodata area.

enter image description here

enter image description here

2
  • I was doing a transformation from planar projection to planar projection. Even that also rotates the image, units can be different
    – Vivek Rao
    Commented May 16 at 7:59
  • 3
    You are also transforming from Universal Transverse Mercator into Lambert Conformal Conic. Size is 10053, 11080 reports the size of the image in pixels. The pixel size in the units of the coordinate system is reported like Pixel Size = (0.00100,-0.00100) but I think that you have noticed it. That gdalwarp is changing the pixel size is anyway expected even it the source and target CRS use the same units. Gdalwarp rather changes the pixel size than does resampling of pixels but user can control that with the -tr parameter. Or if the size in pixels matters, with -ts.
    – user30184
    Commented May 16 at 8:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.