I have two TIFFs that have the same pixel size. One of them is geolocated inside the other. I would like to crop the larger one down to the exact same extent as the smaller one. Is this possible with a gdal command?
gdalinfo small.tif
Pixel Size = (0.100000000000000,-0.100000000000000)
Upper Left (-13042354.590, 3866165.781) (117d 9'41.27"W, 32d46'48.73"N)
Lower Left (-13042354.590, 3865668.981) (117d 9'41.27"W, 32d46'35.22"N)
Upper Right (-13041857.790, 3866165.781) (117d 9'25.21"W, 32d46'48.73"N)
Lower Right (-13041857.790, 3865668.981) (117d 9'25.21"W, 32d46'35.22"N)
Center (-13042106.190, 3865917.381) (117d 9'33.24"W, 32d46'41.98"N)
gdalinfo big.tif
Pixel Size = (0.100000000000000,-0.100000000000000)
Upper Left (-13042373.699, 3866184.891) (117d 9'41.89"W, 32d46'49.25"N)
Lower Left (-13042373.699, 3865649.891) (117d 9'41.89"W, 32d46'34.70"N)
Upper Right (-13041838.699, 3866184.891) (117d 9'24.59"W, 32d46'49.25"N)
Lower Right (-13041838.699, 3865649.891) (117d 9'24.59"W, 32d46'34.70"N)
Center (-13042106.199, 3865917.391) (117d 9'33.24"W, 32d46'41.98"N)
small.tif
above is actually the larger one? Also I've tried to recreate rasters using the coords printed but due to precision its not exact so the rasters don't match any more. Can you give the number of cells in X and Y also? And have you triedgdal_translate
with-projwin
? Or does the problem also involve a) finding which is the smaller and b) extracting the coordinates to pass to-projwin
?small.tif
andbig.tif
swapped around. I want to cut the extend ofsmall.tif
out ofbig.tiff
and create a new tiff. @Spacedmangdal_translate -projwin
does, so unless you want to automate it for any two given TIFs, cut and paste the coordinates fromgdalinfo
forsmall.tif
into agdal_translate
operation onbig.tif
.