[gdal-dev] How to find correct 2D bounding box to subset in different CRS with gdal (different outputs for gdalwarp)?

Pham Huu Bang a09550 at gmail.com
Wed Nov 21 07:33:38 PST 2018


Hello,

I'm using GDAL version 1.11.4 and I have a problem how to use gdal to
translate a bounding box correctly [Lat(62:63), Long(10:11)] from source
CRS EPSG:4326 to target CRS EPSG:32632.

I've tried so far with gdaltransform to translate coordinates: Long min,
Lat min and Long max, Lat max (EPSG:4326) to E min, N min and E max, N Max
(EPSG:32632) like this:

gdaltransform -s_srs EPSG:4326 -t_srs EPSG:32632

10 61.9999999999999 0
552375.799656895 6874583.72713382

11 62.9999999999954 0
601293.020582477 6987164.64881585

Then, I use these translated coordinates to create a bounding box in
EPSG:32632 E(552375.799656895:601293.020582477),
N(6874583.72713382:6987164.64881585) in EPSG:32632 for subsetting a 32632
tiff file and then using gdalwarp the cropped result to EPSG:4326.

The problem is the results of 2 cropped tiff files (both in EPSG:4326) are
significantly different and I could not understand the reason (I think
bounding box in EPSG:32632 are wrong but how to find the correct bounding
box in EPSG:32632 from bounding box EPSG:4326)?

32632.tiff is a tiff file with grid size: 6820, 4632 and 4326.tiff is a
file created by using gdalwarp -t_srs EPSG:4326 32632.tiff 4326.tiff with
grid size: 8213, 2654.

 Test 1:
 # Subset on 32632 tiff by 32632 subset which are translated point by point
 from 4326 subset
 gdalwarp -te 552375.799656895 6874583.72713382 601293.020582477
 6987164.64881585 32632.tiff subset_32632.tiff
 Creating output file that is 1631P x 3753L.

 # Warp cropped 32632 tiff file to 4326
 gdalwarp -t_srs EPSG:4326 subset_32632.tiff subset_4326.tiff
 Creating output file that is 3009P x 3070L.

 Test 2:
 # Subset 4326 on 4326 tiff file directly
 gdalwarp -te 10 61.9999999999999 11 62.9999999999954 4326.tiff
 subset_4326_org.tif
 Creating output file that is 2019P x 2019L.

Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20181121/fe366fd1/attachment-0001.html>


More information about the gdal-dev mailing list