Solved

Combining and extracting values from multiple netCDF files

  • 3 February 2023
  • 6 replies
  • 4 views

I have 12 netCDF files downloaded from https://data.ceda.ac.uk/badc/ukmo-hadobs/data/insitu/MOHC/HadOBS/HadUK-Grid/v1.1.0.0/1km/tasmin/day/v20220310. Each contains 1km-1km grid values of the minimum temperature for each day of a specific month. I would like to create a single combined file that counts the number of days where the temperature was below zero.

 

I've tried RasterExpressionEvaluator but I can't get it to generate anything sensible. Can anyone help please?

icon

Best answer by david_r 3 February 2023, 12:44

View original

6 replies

Userlevel 4

It would be easier to help if you could share the details of what you've tried and explain how the results didn't match your expectation.

I've been able to use RasterExpressionEvaluator to generate a 1/0 value based on whether one of the bands in the raster is below zero degrees. E.g.

if(A[1]<0,1,0)

Where I'm stuck is:

  • how to repeat this for each of the 31 bands i.e. A[1] to A[31]
  • how to sum this at the end

 

 

Userlevel 4

I've been able to use RasterExpressionEvaluator to generate a 1/0 value based on whether one of the bands in the raster is below zero degrees. E.g.

if(A[1]<0,1,0)

Where I'm stuck is:

  • how to repeat this for each of the 31 bands i.e. A[1] to A[31]
  • how to sum this at the end

 

 

Use a RasterBandSeparator before the RasterExpressionCalculator, you can then use the constant formula:

    if(A[0]<0,1,0)

Note the use of band 0, not 1.

Finally try the RasterMosaicker and play around with the Overlapping Values parameter.

Use a RasterBandSeparator before the RasterExpressionCalculator, you can then use the constant formula:

    if(A[0]<0,1,0)

Note the use of band 0, not 1.

Finally try the RasterMosaicker and play around with the Overlapping Values parameter.

Thanks, that works. It generates 31 bands with 0/1 values. I've then used RasterBandCalculator to sum these and got the output I needed.

 

Many thanks for your help. 

Userlevel 4

Use a RasterBandSeparator before the RasterExpressionCalculator, you can then use the constant formula:

    if(A[0]<0,1,0)

Note the use of band 0, not 1.

Finally try the RasterMosaicker and play around with the Overlapping Values parameter.

Did you try the RasterMosaicker, as I mentioned above? Remember to click "Expand post" to see all.

Use a RasterBandSeparator before the RasterExpressionCalculator, you can then use the constant formula:

    if(A[0]<0,1,0)

Note the use of band 0, not 1.

Finally try the RasterMosaicker and play around with the Overlapping Values parameter.

Duh, sorry I completely overlooked that line. I just ran it and reassuringly it generated identical results to RasterBandCalculator.

 

Thanks for all your help.

Reply