Skip to main content
Solved

Combining and extracting values from multiple netCDF files

  • February 3, 2023
  • 6 replies
  • 105 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?

Best answer by david_r

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • 8392 replies
  • February 3, 2023

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.


  • Author
  • 10 replies
  • February 3, 2023

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

 

 


david_r
Celebrity
  • 8392 replies
  • Best Answer
  • February 3, 2023

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.


  • Author
  • 10 replies
  • February 3, 2023

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. 


david_r
Celebrity
  • 8392 replies
  • February 3, 2023

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.


  • Author
  • 10 replies
  • February 6, 2023

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.