How to cut an image (geotiff)?

I would like to cut an image. I try these but I get files that can’t be seen:

gmt grdcut @earth_day_05m  -R-85/-54/9/26 -Gmarble_cut.tif
gmt grdcut @earth_day_05m  -R-85/-54/9/26 -Gmarble_cut2.tif=gd:GTiff 

marble_cut2.tif (228,9 KB)

How is the proper way to cut the image?

Reading sub-regions of Images is deeply screwed. After spending days debugging and trying to defeat the effects of the pad I gave up.
Your options are to use GDAL directly or use the Julia wrapper

julia> I = grdcut("@earth_day_05m", R="-85/54/9/26", img=true);

julia> imshow(I)

The image bellow (coped at ~about half-width) reveals what I suspect is a limitation of the annotations auto scaling algorithm. It uses the product of Weight x Height as a parameter but in this case the image is skinny tall and the annotation font comes out a bit too big.

1 Like

Ok. And how could I do it with gdal?

Btw, the max long is -54 (not 54).

Use gdal_translate, but you’ll have to read its doc. I never remember the syntax.

1 Like

I could do it with:

gdal_translate -projwin -85 26 -54 9 earth_day_05m_p.tif marble.tif

Is it possible to do it with gmt grdgdal? How could I do it?

For example I try

gmt grdgdal @earth_day_05m -Gmarble2.tif -Atranslate -F"-projwin -85 26 -54 9"

but I get an error

(ERROR: Caught signal number 11 (Segmentation fault).

A bug obvious. But adding -M+r works.

1 Like

For the record. this works:

gmt grdgdal @earth_day_05m -Gmarble.tif -Atranslate -M+r -F"-projwin -85 26 -54 9"