Skip to main content
Solved

Combining and extracting values from multiple netCDF files


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

robshawuk wrote:

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.

View original
Did this help you find an answer to your question?

6 replies

david_r
Celebrity
  • 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
  • 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
  • Best Answer
  • February 3, 2023
robshawuk wrote:

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
  • February 3, 2023
david_r wrote:

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
  • February 3, 2023
david_r wrote:

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
  • February 6, 2023
david_r wrote:

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.


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