1

I have a global IGBP land use dataset in which the land cover exists out of forest cover (depicted with a '1') and non-forest cover (depicted with a '0'), hence, each land grid cell has either the value 1 or 0.

This dataset has a spatial resolution of approximately 1 km at the equator, however, I am going to regrid the dataset to a spatial resolution of approx 100 km at the equator. For this new grid resolution I want to calculate the fraction of forest cover (so the fraction of 1's) for each grid cell, but I am not sure how this can be done without GIS. Is there a way to do this with cdo remapping or perhaps with python? Thank you in advance!

Freek
  • 15
  • 4

1 Answers1

2

if you want to translate to a new grid that is an integer multiple of the original then you can do

cdo gridboxmean,n,m in.nc out.nc 

where n and m are the numbers of points to average over in the lon and lat directions.

Otherwise you can interpolate using the conversative remapping which means that you don't need to worry if the new grid is not a multiple of the old

cdo remapcon,new_grid_specification in.nc out.nc 

Note that in the latter case, however, the result is only first order accurate. There is also a slightly slower second order conservative remapping available using the command remapcon2. The paper describing the two implemented conservative remapping methods is Jones (1999). For further info on remapping you can also see my video guide.

Thanks to Robert for reminding also that you may need to convert to float, which would mean using the option

cdo -b f32 
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • 1
    Upvoted. Only thing to look out for in this case is whether the data is stored as int, which might require precision to be changed in the CDO call – Robert Wilson Dec 20 '22 at 08:06
  • Thank you for your answers Adrian and @RobertWilson, the remapcon worked! The only thing I am wondering about now is how remapcon handles NaN data (which I used to mask water bodies in the dataset) in the calculation of the forest cover fractions. Are NaN values included in calculating the forest cover fractions (as I understood, original NaN grid cells are also weighted to derive new grid cell values with remapcon) or are NaN values ignored? Hope I phrased the question clearly enough, thank you in advance! – Freek Dec 21 '22 at 11:22
  • I don't use remapcon often. My understanding is that its behaviour is not strictly conserving when you have missing values. It will effectively give something like the average value in each grid cell of the target grid, ignoring missing value. This is exactly what you want, but I believe you also need to calculate the missing value fraction independently if you want to use it for something that fully conserves things – Robert Wilson Dec 21 '22 at 13:42
  • The way to test the behaviour is to 1) regrid using boxmean to a coarser grid, and then 2) regrid to that coarser grid using remapcon. Then check the differences. There shouldn't be any! – Robert Wilson Dec 21 '22 at 13:44
  • Robert should get credit for this answer too as I couldn't remember the gridboxmean command exactly, his comment reminded me. My understanding is that remapcon will simply ignore cells with NaN. Unless they are all missing in which case you'll get a NaN result for that coarse cell. – ClimateUnboxed Dec 21 '22 at 18:06
  • Thank you so much @RobertWilson and Adrian for your answers, I will indeed check if the gridboxmean method provides the same result as the remapcon method. – Freek Dec 22 '22 at 08:10