Project

General

Profile

Land mask data

Added by nazanin tavakoli almost 4 years ago

Hello,
I want to create a NetCDF land mask data ( 1=land,0=ocean) for my case study. This data should have 0.021-degree resolution, and the first point of this data should be latitude=-39.1458 and longitude=140.9792. Could anybody help me?


Replies (14)

RE: Land mask data - Added by Karin Meier-Fleischer almost 4 years ago

Hi Nazanin,

do you want to create a global LSM or on a specific area only?

You should read the docs in the wiki section first before asking a question.

Tutorial: https://code.mpimet.mpg.de/projects/cdo/wiki/Tutorial
FAQ: https://code.mpimet.mpg.de/projects/cdo/wiki/FAQ

and in general

Doc: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf

The key words are mask, ocean, gridfile and remap.

-Karin

RE: Land mask data - Added by nazanin tavakoli almost 4 years ago

Dear Karin,
I have already read the CDO user guide, but unfortunately, I don't understand well what should I do. I have found the following code, but I don't know what is 10000 means.
cdo -f nc -setrtomiss,0,10000 -topo masked_land.nc

My land mask data should be for the southwest of Australia, like the topography data which I have sent here.

RE: Land mask data - Added by Karin Meier-Fleischer almost 4 years ago

Did you have a look at the output file masked_land.nc with ncdump? The variable topo has units meter, which means that -setrtomiss,0,10000 sets all values between 0m and 10000m to missing value (land=missing), but you want to do it the other way round.

Create a mask file

- use topo data
- change variable name from topo to lsm (just to make it clear)
- remap the data to the desired grid (Topobil.nc)
- set values in the range (-20000,0 m) to missing (set ocean to missing value)
- create the mask (land=1, ocean=missing)

cdo -f nc -gec,0 -setrtomiss,-20000,0 -remapbil,Topobil.nc -chname,topo,lsm -topo mask.nc

The file mask.nc contains only ones and missing values.

Remap data to same grid as mask file (or vice versa):

cdo -f nc -remapbil,Topobil.nc infile.nc tmp.nc

Apply the mask file to mask your data file:

cdo -mul infile.nc mask.nc masked_infile.nc

RE: Land mask data - Added by nazanin tavakoli almost 4 years ago

Thank you for your help.
I have a question. Why do you consider -20000?
And I think this code (cdo -f nc -gec,0 -setrtomiss,-20000,0 -remapbil,Topobil.nc -chname,topo,lsm -topo mask.nc) does what I want. A land mask data which shows land with 1 and oceans with nan.

RE: Land mask data - Added by Karin Meier-Fleischer almost 4 years ago

The code will create the wanted mask as described above.

The value -20000 means -20000 meter depth of topography (-topo), it's just simple and you will be on the save side, but if you feel better with -11500.. ;) .

RE: Land mask data - Added by nazanin tavakoli over 3 years ago

I mean that how do you find -11500? This value isn't in my data.

RE: Land mask data - Added by Karin Meier-Fleischer over 3 years ago

The value depends on the topography dataset not on your data! I don't know what your data is about and I don't need to knoe it in this case. It's about how to create a file which can be used to mask e.g. ocean areas and therfore we use the topography to find out which grid cell is ocean area and which is land area.

I wrote a more general explaination what masking means and the different ways to do it with CDO. See https://code.mpimet.mpg.de/boards/53/topics/10933

RE: Land mask data - Added by nazanin tavakoli over 3 years ago

Thank you for your clarification. It really helped.:)

RE: Land mask data - Added by nazanin tavakoli over 3 years ago

Hello Karin Meier-Fleischer,
I have a question. I made the land mask data as you had told me, but my model can not read the data. Because in a guide of the model has been written that in land-mask data 1=land,0=ocean, but in land-mask data I have produced by the following code, oceans is NaN.
cdo -expr,'topo=((topo>0.0)) ? 1.0: topo/0.0' topo.nc landmask.nc
So, I have edited the code to set oceans cell the value 0.
cdo -expr,'topo=((topo>0.0)) ? 1.0: ((topo/0.0)) ? 0.0' topo.nc landmask.nc
But I have this error:
syntax error, unexpected QUESTION, expecting ';'!

cdo expr (Abort): Syntax error!
Do you have any idea how can I fix this? I have sent my topo data here.
I would appreciate it if you help me.

topo.nc (1.26 MB) topo.nc

RE: Land mask data - Added by Karin Meier-Fleischer over 3 years ago

Your topo.nc file contains missing values which, in your case, have to be set to 0, too.

cdo -f nc -expr,'topo = ((topo > 0)) ? 1 : 0' -setmisstoc,0 topo.nc o.nc

RE: Land mask data - Added by nazanin tavakoli over 3 years ago

Thank you for your help.

RE: Land mask data - Added by Saumya Singh over 3 years ago

Hello Karin Meier-Fleischer,

I have a file which contains surface temperature values a land values while 0 for ocean values. I want to use the same file as a mask file and so want all the land surface temperature values to become 1. How can to do it? Kindly suggest.

Thanks in advance!

RE: Land mask data - Added by Karin Meier-Fleischer over 3 years ago

Hi Saumya,

more information can be found in the 'Masking - more general' article https://code.mpimet.mpg.de/boards/53/topics/10933.

-Karin

RE: Land mask data - Added by Brendan DeTracey over 3 years ago

It is tricky to create a land mask from your grid, unless the temperature units are in Kelvin. Why? Because in Celcius it is possible that the value 0 will appear on land. Whoever produced your data file should have set all ocean grid points as missing values. They could also provide you with a mask file.

How many time steps are in your file? If you have enough time steps, you can try the following:

cdo --reduce_dim gtc,0 -timcumsum -abs file_in.nc file_out.nc

Edit: Note that this will only work if the the cumulative sum of abs(temperature) is only zero for ocean grid points. You will have to check this. Or get the real mask file from the data file producer.

    (1-14/14)