Skip to main content
Question

Perform date conversions within rasters

  • December 11, 2024
  • 3 replies
  • 37 views

wolters
Contributor
Forum|alt.badge.img+6

I have a raster wherein the values are in epoch time (number of days since 1970-01-01)

Is there a way in FME to convert these values into different date formats, such as yyyyddd?

DateTimeConverter seems to only work with attributes, but translating all pixels to polygons with attributes for the pixel value is not optimal. I would guess this could be possible with RasterExpressionEvaluator, but if someone can give an example that would be really helpful.

 

Thanks!

3 replies

hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • December 11, 2024

You could use the RasterCellCoercer to convert the cells to points. The band values will be converted to attributes.

It does mean you will have one point per pixel, which depending on the size of your raster, may or may not be a problem


wolters
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • December 11, 2024

@hkingsbury this is not feasible since it is a global raster.


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • December 16, 2024

Hi ​@wolters,

This can be done using an RGB48 palette to hold year, month and day values, then a RasterExpressionEvaluator to convert these into a single integer value:

The PythonCaller generates an RGB48 palette for dates from 1970 to 2149, which is applied to the image in the RasterPaletteAdder. The RasterPaletteResolver replaces the index values with the RGB48 values. Finally, the RasterExpressionEvaluator creates a new INT32 value from the RGB48 using the expression: A[0]*10000 + A[1]*100 + A[2].

I am attaching the workspace snippet for you.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings