Project

General

Profile

how to "overlay" several files

Added by Etienne Tourigny over 11 years ago

Hi

I have 2 land cover map files (one global, one for South America) that I wish to combine in a single one, using the values from the second file where the data is defined, but from the first one elsewhere.

Basically, values are defined by the value of the top-most layer.

Any way I can accomplish this with cdo?

I was imagining I could add the values, but how could I mask the values from the "bottom" file so they don't add up where the top one has values?

regards
Etienne


Replies (5)

RE: how to "overlay" several files - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

Please have a look at the following thread: https://code.zmaw.de/boards/1/topics/1391#message-1403

Hope this will point you in the right direction.

Cheer,
J.

RE: how to "overlay" several files - Added by Etienne Tourigny over 11 years ago

Thanks, but that thread is a bit confusing - what was the exact command that ended up working?

It seems to me that it works because the larger dataset has values of 0 in the common area, so when you add the 2 you get the values from the smaller file in the overlapping area.

In my case, there are already non-zero values in the larger file, and it is not always possible to mask them out using e.g. setclonlatbox, because the common region does not necessarily have a rectangular shape.

RE: how to "overlay" several files - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

In my case, there are already non-zero values in the larger file,

I think, if you mask the area (outside/inside) using the maskregion/maskbox operators

It seems to me that it works because the larger dataset has values of 0 in the common area, so when you add the 2 you get the values from the smaller file in the overlapping area.

then you could do the same trick

and it is not always possible to mask them out using e.g. setclonlatbox, because the common region does not necessarily have a rectangular shape.

May be I'm missing something ...

As far as I understood, the setclonlatbox (/similar operator) options are lat-on "boundaries" - it need not have to be regular/rectangular - it also works with unstructred grid (on NetCDF cell format, for example)

If you are trying to overlay arbitrary locations/grid points at the same time, then I don't think cdo can do that (unless, they are on the same grid & size, then may be you could try "replace" operator").

Cheers,
J.

RE: how to "overlay" several files - Added by Uwe Schulzweida over 11 years ago

Hi Etienne,

the undocumented CDO operator mergegrid will do this task:

cdo mergegrid ifile1 ifile2 ofile
The first input file should be the global one. This operator is in experimental state and works only on rectilinear grids. Both inputfiles needs to have the same mesh coordinates.

Best regards,
Uwe

RE: how to "overlay" several files - Added by Etienne Tourigny over 11 years ago

Hi Jaison-Thomas

what I mean is that, how can I mask a region that is not defined by a lon/lat box?

For example, say you have data for a country (which has an irregular shape), that you want to overlay on another source (say the world), you need to mask out that country, not a rectangular box...

Uwe - I'll have a look at mergegrid - it seems to do what I need.

Regards
Etienn

    (1-5/5)