Hi
Based on my understanding, you are seeking assistance in generating a mask using the "drawfreehand" function over a "geoshow" plot that spans from latitude 60° to 90° and longitude -180o to 180o.
Upon reviewing the provided code, it appears that the "drawfreehand" function is being called before plotting the map, resulting in an empty mask. To address this issue, please follow the steps outlined below:
- Remove line [6] from the code, which declares the mask prematurely.
- Move line [5], which calls the "drawfreehand" function, to the end of the code. Please note that the "drawfreehand" function returns position coordinates in Cartesian format, which need to be converted to latitude-longitude coordinates.
- Utilize the code provided below for the conversion, as there is no direct function available for converting the output of "drawfreehand"(cartesian output) on a circular latitude-longitude "geoshow" plot to latitude-longitude coordinates.
[theta,r] = cart2pol(x,y)
lon1(idx1) = lon1(idx1)+90;
lon1(idx2) = lon1(idx2) + 90;
lon1(idx3) = lon1(idx3)-270;
4. After getting the “drawfreehand” coordinates in lat-lon format from using the above code snippet, you can use the poly2mask function by referring to its documentation.
Please refer to the below Mathworks documentation for more reference:
- Poly2mask: https://www.mathworks.com/help/images/ref/poly2mask.html
- Drawfreehand: https://www.mathworks.com/help/images/ref/drawfreehand.html
I hope this helps.
Regards
Binaya