How to resample a raster to a specified cell size?

I want to resample a raster image (GeoTiff, 5 bands) from 7,29 cm to 25 cm. There are numerous tools for resampling, but I figured out that RigidTransformResample should be the function that does what I want.

Now, there is no way to tell the function directly that my output cell size shall be 25 cm but one has to calculate (?) translation parameters. There are three different ways to resample:

  1. id (spatial scaling, 2 parameters)
  2. translation (translation, 2 OR 4 parameters (unclear which to use, documentation should have an example for each case)
  3. rotation (rotataion, 1 or 3 parameters)

Now I thought spatial scaling (id) would be the right way and I thought that given 25 / 7 is about 3.4, so I wrote the arguments transform.id.scalex= 3.4 transform.id.scaley = 3.4 but the spacing changed from 7cm to 2cm in X and remained the same in Y !

This is the image information before:

Image general information:
Number of bands : 5
No data flags :
Band 1: -10000
Band 2: -10000
Band 3: -10000
Band 4: -10000
Band 5: -10000
Start index : [0,0]
Size : [21726,12037]
Origin : [486232,6.04546e+06]
Spacing : [0.07289,-0.07289]
Estimated ground spacing (in meters): [0.0726658,0.072863]

This was my command line:

otbcli_RigidTransformResample -in C:\Users\oldel\Documents\Nordstrandischmoor_Multispectral_RedEdge\otbConcatenateImages.tif -out C:\Users\oldel\Documents\Nordstrandischmoor_Multispectral_RedEdge\rigitTransformImage_ID.tif -transform.type id -transform.type.id.scalex 3.44 transform.type.id.scaley 3.431 -interpolator bco

and this was the output image

Image general information:
Number of bands : 5
No data flags :
Band 1: -10000
Band 2: -10000
Band 3: -10000
Band 4: -10000
Band 5: -10000
Start index : [0,0]
Size : [74737,12037]
Origin : [486232,6.04546e+06]
Spacing : [0.021189,-0.07289]
Estimated ground spacing (in meters): [0.0211247,0.072863]

Could anyone please explain how to get from 7 to 25cm using image resampling?

Thank you in advance

Hello,

I think you should use the inverse of the scaling you are using, i.e to scale from 7.29 cm to 25 cm you should use 7.29/25 = 0.2916.

Also in your command line you are missing a " - " character before transform.type.id.scaley, this is why the parameter is not taken into account.

Hope that helps,
CĂ©dric

1 Like

Hi @oldi

You have to do the oposite, that is: 7.29 / 25

Best regards,
Pedro Venâncio

@PedroVenancio Yes, thank you. I already checkmarked the answer of @cedric.traizet as correct. Neverheless, thanks for responding.

Thanks @oldi !

My answer was blocked because my account was temporarily on hold! That’s why my answer was showed after the @cedric.traizet contribution! Otherwise, it was strange that I was responding to something that had already been correctly answered! :smile:

Best regards!