Question

I can't get rasters to align

  • 14 July 2020
  • 3 replies
  • 19 views

Badge +3

Problem: I download rasters (satellite images) with differten extends (but overlapping) and different cellsizes. I can not get them to align, whatever I do. I tried:

 

- setting the largest to 'nodata' and using the rastermosaicer. I get an error showing a different number of rows. I also tried it by setting all data to 0 and using the target raster in mosaicer with 'maxiumum' as setting.

- The above for both rasters (I was running out of ideas)

- Exposing the raster properties of one raster and trying to use the raster resampler to resample the second raster: I get a rejected raster with this weird error: @%0: Failed to obtain raster from feature. Only features with raster geometry are expected

 

- Exposing the raster properties and using the raster georeferencer (the raster gets rejected INVALID_FEATURE_ATTRIBUTES)

 

 

and many, many more things. I can not get them to align and could use some help

 

FME version 2020.0.0.1


3 replies

Badge +22

The rasterMosaiker requires all images to have the same number of bands, NoData value, and projection. It does not require rasters to have the same cell size, it will resample and snap every subsequent raster to the that of the first raster.

 

Could you set up a workspace with just the two rasters, a mosaiker and a logger on the rejected port of the mosaiker and give us the actual log errors?

Badge +3

The rasterMosaiker requires all images to have the same number of bands, NoData value, and projection. It does not require rasters to have the same cell size, it will resample and snap every subsequent raster to the that of the first raster.

 

Could you set up a workspace with just the two rasters, a mosaiker and a logger on the rejected port of the mosaiker and give us the actual log errors?

example.fmw

 

I triewd it both ways for the rasters, the error I get:

 

NDVICalculator_RasterExpressionEvaluator_2 (RasterEvaluationFactory): Raster A has '10938' rows and '11383' columns, whereas raster B has '21877' rows and '22766' columns. Paired rasters must have the same dimensions

A fatal error has occurred. Check the logfile above for details

RasterMosaicker (RasterMosaicFactory): Failed to output the feature with the mosaicked raster

RasterMosaicker (RasterMosaicFactory): A fatal error has occurred. Check the logfile above for details

A fatal error has occurred. Check the logfile above for details

 

I also tried merging the porperties using rastermerger and then I get something extremely weird: The requestor raster gets all the cell vallues (merger is on attributes only) from the suplier?!? |This results in a 0-value only raster when I do A - B:

 

 

It is showing weird behaviour anyway: depsite being set to 0, the counter did start at 1.

Badge +22

So your issue is not with the RasterMosaiker at all, but rather the RasterExpressionEvaluator, which is considerably more strict.

 

 

Option 1:

 

Assuming you want an output for the overlapping region only, and that you want the resolution of image A

 

 

Clip image A by image B.

RasterPropertyExtractor image A.

FeatureMeger with B as the requestor and A as the supplier - prefixSupplier.

RasterResampler of B to spacing_x and spacing_y of A.

Clip image B by image A.

RasterPropertyExtractor image B.

Test the number of _num_rows and _num_columns of B = A, resample if not. (Sometimes it will be off by 1 column)

Test the _lower_left_x and lower_left_y of B = A, rasterGeoreferencer if not. (Sometimes it will be off by essentially a floating point error)

 

 

 

 

Option 2:

 

Assuming you want an output of the region of both rasters, padded by 0 where necessary, and you want the output resolution of image A.

 

 

Assign an _order attribute of 1 and _copynum of 0 to A and _order of 2, _copynum of 1 to B.

 

Sort the images by _order numeric ascending.

RasterMosaicker, accumulation mode Drop Incoming Attributes.

 

RasterCellValueReplacer >0 = 0

 

Assign an _order attribute of 0 to the mosaic.

 

Cloner - 2 copies

Sorter with all 4 images by _copynum and then _order

RasterMosaiker, group by _copynum, accumulation mode merge incoming attributes.

 

 

 

In either case you will end up with two images with the same extent and spacing as required by the RasterExpressionEvaluator.

 

 

 

Reply