Skip to main content

Hi,

I have 3 raster’s that I wish to merge into one. Two of the 3 are of the exact same extent, cell size and CRS. The third has a larger extent (but overlapping the first two) and a smaller cell size. The issue I am having is that once I have resampled and clipped the 3rd raster to the extent of the other two they are mis-aligned, and I can’t figure out how to fix it. I need them to be exactly aligned so I can merge them.

 

So far this is my method:

  1. Read in all 3 raster’s and ensure their CRS is the same (Using ...
  2. Resample the 3rd raster to the cell spacing of the other two (5000 x 5000) 
Raster 1
Raster 2
Resampled Raster 3
  1. Clip the 3rd raster to the extent of the other two:
  • I use RasterExtentsCoercer for one of the first two raster’s (as they have identical extents). Set extents type to ‘Data Extents’. As I want the data extent clipping not the outer extent rectangle. Then using clipper with the output of RasterExtentsCoercer as ‘Clipper’ and resampled 3rd raster as the ‘Candidate’. It is the ‘Inside’ output I want.
  • The output is visually what I would expect here but the min and max extents don’t match the extents of the ‘Clipper’ i.e. the output of RasterExtentsCoercer
Clipper parameters
Output of Clipper
  1. By using RasterCellCoercer and CenterPointReplacer, I mapped the center points of the original raster 1 before the RasterExtentsCoercer, and the output of the Clipper to understand the misalignment:
  • As you can see the center points of the original and clipped raster’s aren’t identical. This causes RasterBandCombiner to fail. Which is my end goal. 

 

In summary the min and max extents of the original Raster 1 and Raster 2 and the clipped Raster 3 (to the extent of Raster 1&2) is not identical:

 

Clipped Raster 3:

Raster Min X = -77854.55513918214
Raster Min Y = 5348203.923522741

 

Raster 1 & 2:

Raster Min X = -77500
Raster Min Y = 5277500

 

Is there a way to force Raster 3 to have the same extent as Raster 1 & 2?

 

Note: I did this perfectly in R with no errors using

Raster3_cropped <- mask(crop(Raster3, Raster1), Raster1)

This generated a cropped Raster 3 with the extent matching 1 and 2: -77500, 5277500. However, the developers in my project want this method in FME to add to their workbench so I need this to work in FME which I have little experience in.

 

Any help or advice would be greatly appreciated! Thank you

Not read everything, but I see the cell origin differs between the different rasters?

Maybe you only need the RasterCellOriginSetter?


Hi ​@nielsgerrits, Sorry I forgot to mention this in my question. I did use RasterCellOriginSetter to reset the cell origin of clipped Raster 3 but the extents remained mis-aligned:

Output from RasterCellOriginSetter (Clipped Raster 3)

Thank you though! I appreciate your reply :)