Project

General

Profile

mask out a netcdf database using a landuse database

Added by Natalia L over 5 years ago

Hello,

I have a netcdf file with a variable v(lat,lon,v), and I have the land cover corine database which I have already converted to a netcdf file with the same grid dimensions to the netcdf with the variable v.

So, I want to remap my netcdf file with the variable based on the land uses of corine database. For example, I want to keep only land (i.e. excluding the water surfaces) etc.

Could anyone help me on how I can do that?

Thanks a lot in advance

Regards,
Natalia


Replies (3)

RE: mask out a netcdf database using a landuse database - Added by Karin Meier-Fleischer over 5 years ago

Hi Natalia,

without your data I can only guess.

Assume:
your_data.nc: your data file
corine_data.nc: your corine file used to be the mased input on same grid as your_data_nc
mask_land_only.nc: is the newly created masked file land only
your_data_masked.nc: shows only your data on land

Create land-sea mask from corine_data.nc:

cdo -setrtomiss,-20000,0 corine_data.nc mask_land_only.nc

Mask your_data with mask_land_only to get the values of your_data.nc only over land:

cdo ifthen mask_land_only your_data.nc your_data_masked.nc

-Karin

RE: mask out a netcdf database using a landuse database - Added by Natalia L over 5 years ago

Thank you very much!

regards,
Natalia

RE: mask out a netcdf database using a landuse database - Added by Natalia L over 5 years ago

Hi again,

the land use database I use has the id 20 for waters . So, I finally I masked my data as following

cdo setctomiss,20 $Database_outdir/land_use_map.nc $Database_outdir/land_use_map_only_land.nc"

cdo ifthen $Database_outdir/land_use_map_only_land.nc $Database_outdir/input.nc $Database_outdir/output.nc

The masking is done correctly however all the no land cells are filled in with Nan values. Does this mean that something is wrong ? How I could make the masking and no land cells values be zero instead of Nan?

thanks
N

    (1-3/3)