[gdal-dev] How to estimate the width/height size of output image in a target CRS without running gdalwarp?

Bang Pham Huu b.phamhuu at jacobs-university.de
Thu May 17 02:33:40 PDT 2018


Hi,

I have a hard problem to find the width/height of a 2D GeoTiff file
which is reprojected from a source CRS (e.g: EPSG:4326) to target CRS
(e.g: EPSG:3857) without running gdalwarp. Because, the file could be
large (GBs) and I don't need the projected output file, just need the
width/height of it.

What could be done with gdalwarp is:

gdalwarp  -s_srs EPSG:4326 -t_srs EPSG:3857 full.tif full_3857.tif

gdalinfo full_3857.tif

Size is 879, 811 (width/height).

I've searched a lot and what seems to be good without doing the real
projection is this gdal function: GDALSuggestedWarpOutput2
https://github.com/OSGeo/gdal/blob/106c8288e7a05f4efc1a588c5a3b2da7ec52d915/gdal/alg/gdaltransformer.cpp#L354.
However, it doesn't help because my application developed in Java and it
uses gdal-java (GDAL JNI)
https://search.maven.org/#artifactdetails%7Corg.gdal%7Cgdal%7C1.11.1%7Cpom
as library. Unfortunately, I cannot find this GDALSuggestedWarpOutput2()
from gdal-java http://gdal.org/java/overview-summary.html then cannot
invoke this C++ function from my application to test.

Can anyone please give me a hint to solve this problem?

Thanks,





More information about the gdal-dev mailing list