[gdal-dev] How to find correct 2D bounding box to subset in different CRS with gdal (different outputs for gdalwarp)?
Andre Joost
andre+joost at nurfuerspam.de
Wed Nov 21 08:28:30 PST 2018
Hello Pham,
note that an EPSG:4326 rectangle of full degrees gets rotated and bended
in almost any projected CRS (except Mercator).
Since the EPSG:32632 raster has to be an unrotated rectangle again, the
corners of the projected EPSG:4326 rectangle are different from the
corners of the EPSG:32632 rectangle. The difference will be filled with
NODATA pixels.
Try to vsualize your problem in a GIS software like QGIS, and you see
what I mean.
HTH,
Andre Joost
Am 21.11.18 um 16:33 schrieb Pham Huu Bang:
> 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,
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
More information about the gdal-dev
mailing list