[Thread Prev][Thread Next][Index]

Re: [ferret_users] polygon to mask country



Hi Nicolas,

Yes, sometimes it's useful to do a SHOW FUNCTION/DETAILS to see how the result depends on the grids of the arguments. The result mask you're defining will have the x and y axes of the first argument, and the other arguments are just lists.

Most often for function calls, it's best to specify any ranges as a context in square brackets right in the function call. I don't know what mihght have been going wrong in your original example, but if you had a global region defined using SET REGION that could throw things off.

yes? show func/details pt_in_poly
PT_IN_POLY(A,XVERT,YVERT)
Return -1 outside, 0 if on edge, 1 if inside polygon
Axes of result:
X: inherited from argument(s)
Y: inherited from argument(s)
Z: NORMAL (no axis)
T: NORMAL (no axis)
E: NORMAL (no axis)
F: NORMAL (no axis)
A: Variable on the XY grid and region to be tested (FLOAT)
Influence on output axes:
X: passed to result grid
Y: passed to result grid
Z: no influence (indicate argument limits with "[]")
T: no influence (indicate argument limits with "[]")
E: no influence (indicate argument limits with "[]")
F: no influence (indicate argument limits with "[]")
XVERT: X-coordinates of vertices of polygon (FLOAT)
Influence on output axes:
X: no influence (indicate argument limits with "[]")
Y: no influence (indicate argument limits with "[]")
Z: no influence (indicate argument limits with "[]")
T: no influence (indicate argument limits with "[]")
E: no influence (indicate argument limits with "[]")
F: no influence (indicate argument limits with "[]")
YVERT: Y-coordinates of vertices of polygon (FLOAT)
Influence on output axes:
X: no influence (indicate argument limits with "[]")
Y: no influence (indicate argument limits with "[]")
Z: no influence (indicate argument limits with "[]")
T: no influence (indicate argument limits with "[]")
E: no influence (indicate argument limits with "[]")
F: no influence (indicate argument limits with "[]")

On 3/26/2019 11:30 AM, Nicolas Freychet wrote:
Hi Ansley,

Yes it does show the right boundary. Actually I found a solution by specifying the i/j limits of the var in the definition (I think because I used "dimensional" lists to define the polygon, it was somehow inconsistent with dimension of the variable). So something like that works:

let xp=LON[d=7,i=1:735178]
let yp=LAT[d=7,i=1:735178]
let mask = if pt_in_poly(Tmax[d=1,l=1,i=1:350,j=1:95],xp,yp) gt 0 then 1

Cheers,
Nicolas


Lemar. 26 mars 2019 à16:22, Ansley C. Manke <ansley.b.manke@xxxxxxxx> a écrit:
Hi Nicolas,

As a check of your definition, does a plot of the points

PLOT/VS/LINE xp, yp

show the outline of the boundary you want?

On 3/25/2019 4:18 AM, Nicolas Freychet wrote:
> Dear Ferret users,
>
> I'm trying to create a mask for a country, following this discussion:
> ../fu_2012/msg00019.html
>
> I managed to have a netcdf file with all lon/lat coordinate to define
> a polygon of the country as in the discussion, but now I am not sure
> how to apply it to mask my data.
> The pt_in_poly function
> (../../documentation/users-guide/appendix-a-external-functions/pt_in_poly.html)
> requires to define a table of xp/yp. I tried to do something like:
>
> let xp=LON[d=7,i=1:735178]
> let yp=LAT[d=7,i=1:735178]
> let mask = if pt_in_poly(Tmax[d=1,l=1],xp,yp) gt 0 then 1
>
> But it doesn't seem to work. I think it's the way I define xp/yp that
> is wrong, but I don't know how to make a table {} from a coordinate.
> Any idea?
>
> Cheers,
> Nico
>


--
----------------------------------------------------
Nicolas Freychet
PDRA, School of Geosciences
University of Edinburgh
----------------------------------------------------

[Thread Prev][Thread Next][Index]