Solved

For MODIS LAI images in an FME output folder, how do I select appropriate images based on date ranges? Image date is given in year + Julian day e.g. A2021123 for 2021 May 3?


For MODIS LAI images in an FME output folder, how do I select appropriate images based on date ranges? Image date is given in year + Julian day e.g. A2021123 for 2021 May 3?
icon

Best answer by geomancer 8 May 2021, 11:52

View original

3 replies

Userlevel 4
Badge +36

You mention Julian day, but in your example you use the day number in the year.

To get the day number in the year use %j in the @DateTimeFormat function. To get the combined year and day number you can use

@DateTimeFormat(@Value(Date),%Y%j)

For more information on the @DateTimeFormat function visit https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_ReadersWriters/!Transformer_Parameters/Date-Time-Functions.htm

Year_and_Day_Number

You mention Julian day, but in your example you use the day number in the year.

To get the day number in the year use %j in the @DateTimeFormat function. To get the combined year and day number you can use

@DateTimeFormat(@Value(Date),%Y%j)

For more information on the @DateTimeFormat function visit https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_ReadersWriters/!Transformer_Parameters/Date-Time-Functions.htm

Year_and_Day_Number

Thanks for your response. Let me clarify, here is an example of two MODIS LAI images: MCD15A2H.A2010169.h10v03.006.2015208215713 and

MCD15A2H.A2010177.h10v03.006.2015208225609. How can I select the two images based on dates? 

Userlevel 4
Badge +36

To get the date from year and day number you can use the @DateTimeParse() function:

@DateTimeParse(@Value(Year_and_Day_Number),%Y%j)

2010169 gives 20100618 (June 18, 2010), 2010177 gives 20100626 (June 26, 2010).

 

Your next question may be how to extract the year and day number from the image name.

There are several possible solutions for this.

In both your examples, the year starts at the same position, so it may be enough to use the @Substring() function.

Or you can use a regular expression to get all the numbers between the first and second dot.

Or you can write the image name to a list with the AttributeSplitter transformer, write the second element (element 1) to a new attribute with the ListIndexer transformer, and ger the year and day number from that attribute.

 

And there are probably other ways to get the year and day number. Just dive into the possibilities. 

FME is best learned by trying it yourself. Use the documentation, it is very extensive. And of course you can ask questions at the forum when you can't figure it out completely.

Reply