Project

General

Profile

masking with 0 values

Added by kunal bali over 5 years ago

Dear CDO users,

I have one global file ( e.g. modis.nc ) with some values (e.g AOD ) . Now I want to assign 0 values in one country/shapefile (e.g India) in that global file. So how can I mask 0 values in Indian region.

if I have two files such as
1.) global.nc
2.) shape file in NetCDF ==> India1.nc

so how can we proceed.

regards
kunal

india1.nc (8.19 KB) india1.nc shape_file
modis.nc (514 KB) modis.nc global file

Replies (2)

RE: masking with 0 values - Added by Uwe Schulzweida over 5 years ago

1. Create a mask with 0/1 from your "shapefile" and enlarge this field to the size of the global modis data:

cdo -remapnn,modis.nc -setmisstoc,1 -eqc,0 india1.nc mask.nc
2. Multiply this mask with the modis data:
cdo mul modis.nc mask.nc result.nc
You can combine these commands to:
cdo mul modis.nc -remapnn,modis.nc -setmisstoc,1 -eqc,0 india1.nc result.nc

    (1-2/2)