I have one elevation file (SRTM) and one satellite imagery file (sentinel-2), both are in GeoTIFF format.
The elevation file has a much larger area covered.
Here is the gdalinfo
of the elavation file:
> Driver: GTiff/GeoTIFF Files: C:\DEV\3D\Assets\Heightmaps\nv\full.tif
> Size is 10801, 7201 Coordinate System is: GEOGCS["WGS 84",
> DATUM["WGS_1984",
> SPHEROID["WGS 84",6378137,298.257223563,
> AUTHORITY["EPSG","7030"]],
> AUTHORITY["EPSG","6326"]],
> PRIMEM["Greenwich",0],
> UNIT["degree",0.0174532925199433],
> AUTHORITY["EPSG","4326"]] Origin = (-2.000138888888889,36.000138888888884)
> Pixel Size =(0.000277777777778,-0.000277777777778)
> Metadata: AREA_OR_POINT=Area
> Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates:
> Upper Left ( -2.0001389, 36.0001389) ( 2d 0' 0.50"W, 36d 0' 0.50"N)
> Lower Left ( -2.0001389, 33.9998611) ( 2d 0' 0.50"W,33d59'59.50"N)
> Upper Right ( 1.0001389, 36.0001389) ( 1d 0'0.50"E, 36d 0' 0.50"N)
> Lower Right ( 1.0001389, 33.9998611) ( 1d 0' 0.50"E,33d59'59.50"N)
> Center( -0.5000000, 35.0000000) ( 0d30' 0.00"W, 35d 0' 0.00"N)
> Band 1 Block=10801x1 Type=Int16,ColorInterp=Gray
and the satellite image:
> Driver: GTiff/GeoTIFF Files:
> C:\DEV\3D\Assets\Imagery\new\sub_big_merge.tif Size is 15017, 8131
> Coordinate System is: PROJCS["WGS 84 / UTM zone 30N",
> GEOGCS["WGS 84",
> DATUM["WGS_1984",
> SPHEROID["WGS 84",6378137,298.257223563,
> AUTHORITY["EPSG","7030"]],
> AUTHORITY["EPSG","6326"]],
> PRIMEM["Greenwich",0,
> AUTHORITY["EPSG","8901"]],
> UNIT["degree",0.0174532925199433,
> AUTHORITY["EPSG","9122"]],
> AUTHORITY["EPSG","4326"]],
> PROJECTION["Transverse_Mercator"],
> PARAMETER["latitude_of_origin",0],
> PARAMETER["central_meridian",-3],
> PARAMETER["scale_factor",0.9996],
> PARAMETER["false_easting",500000],
> PARAMETER["false_northing",0],
> UNIT["metre",1,
> AUTHORITY["EPSG","9001"]],
> AXIS["Easting",EAST],
> AXIS["Northing",NORTH],
> AUTHORITY["EPSG","32630"]]
> Origin = (614090.000000000000000,3987110.000000000000000)
> Pixel Size =(10.000000000000000,-10.000000000000000)
> Metadata:
> AREA_OR_POINT=Area Image Structure Metadata: INTERLEAVE=PIXEL Corner
> Coordinates:
> Upper Left ( 614090.000, 3987110.000) (1d44' 1.72"W,36d 1'18.55"N)
> Lower Left ( 614090.000, 3905800.000) (1d44'43.19"W, 35d17'19.93"N)
> Upper Right ( 764260.000, 3987110.000) (0d 4' 6.98"W, 35d59'33.60"N)
> Lower Right ( 764260.000, 3905800.000) (0d 5'42.84"W, 35d15'37.76"N)
> Center ( 689175.000, 3946455.000) (0d54'37.94"W, 35d38'37.76"N)
> Band 1 Block=15017x1 Type=Byte,
> ColorInterp=Red Band 2 Block=15017x1 Type=Byte, ColorInterp=Green Band
> 3 Block=15017x1 Type=Byte, ColorInterp=Blue
Now, how do I get a subset of the elevation file that exactly matches the same area of the satellite image with gdal_translate or any other tool (since as you can see the two files have differents projections, resolutions, units ... etc)?
In the meantime I have tried these two "solutions"
Use GDAL command line to copy projections
Use gdalsrsinfo to get the srs of the tiff that still has the projection:
gdalsrsinfo -o wkt tiffwithsrs.tiff
Then copy the output and use gdal_translate to apply it to a new tiff:
gdal_translate -a_srs '...' tiffwithoutsrs.tif newfixedtif.tif
just paste your projection after the -a_srs option wich did nothing .
and this which completely broke my file.