Project

General

Profile

create polygon maskfile

Added by kunal bali about 4 years ago

Dear CDO users,

I need to create a one mask/or shape file of the given desired polygon box [see in the attached figure] from the attached .nc file.

The coordinates of the given polygon are

lonv = (/77.98,77.96,79.01,80.02,80.98,81.57,81.98,83.01,84.00,83.99,83.01,83.01,80.98,81.00,80.01,79.64,79.63,79.01,77.98/)
latv = (/31.00,29.70,29.15,28.82,28.43,28.01,27.98,27.47,27.38,28.64,28.99,29.40,29.56,29.99,30.05,30.01,30.61,30.64,31.00/)

Could you please provide some information on that.

Thank You


Replies (8)

RE: create polygon maskfile - Added by kunal bali about 4 years ago

Dear Brendan,
Thanks for your suggestion. I have tried this already.

This function creates only rectilinear box. But, in my case my area is different as you could see in the the attached figure. So, if you have any other suggestion then please let me as well.

Thank You

RE: create polygon maskfile - Added by Brendan DeTracey about 4 years ago

Welp, it would easier to help if you posted the command line you tried as well as upload your ascii region file. :)
Note that maskregion documentation states:

The elements inside a region are untouched, the elements outside are set to missing value.

The output file has the same dimensions but the points outside the polygon are masked with missing values.

RE: create polygon maskfile - Added by kunal bali about 4 years ago

the function takes only 4 coordinates lat1,lat2,lon1,lon2. So it mask only square/rectangular box.

And in my case, I have more than 4 coordinates and not in rectangular box (as mentioned in attached figure). It's irregular shape. So this function can't be applicable as far as I understood.

RE: create polygon maskfile - Added by Brendan DeTracey about 4 years ago

maskbox takes box corners, maskregion takes a plain text file with coordinates....

RE: create polygon maskfile - Added by kunal bali about 4 years ago

I tried

cdo mskregion,myregion.txt file.nc out.nc

file created with NaN values only.

myregion.txt is

77.98,77.96,79.01,80.02,80.98,81.57,81.98,83.01,84.00,83.99,83.01,83.01,80.98,81.00,80.01,79.64,79.63,79.01,77.98
31.00,29.70,29.15,28.82,28.43,28.01,27.98,27.47,27.38,28.64,28.99,29.40,29.56,29.99,30.05,30.01,30.61,30.64,31.00

RE: create polygon maskfile - Added by Brendan DeTracey about 4 years ago

Carefully read the description for the polygon text file. You have not made it correctly. They have an example in the manual.

poly.txt (247 Bytes) poly.txt

RE: create polygon maskfile - Added by kunal bali about 4 years ago

ah! my bad

Thanks

    (1-8/8)