CDT
CDT copied to clipboard
Geomask error for polygons
Hi, I'm new to CDT and new to GitHub. I am trying to write my thesis on climate change with the help of Matlab and CDT… And I found out that the geomask does not work well when entering multiple countries = polygons (at least according to the instructions).
Therefore, instead of the part in the geomask.m function:
indv = lonv > 180;
lonv(indv) = lonv(indv) - 360;
I suggest using:
% The following part of the code (lonv correction) was made by Tomáš Poláček
% Check if lonv is of type cell
if iscell(lonv)
% Iterate over individual rows
for i = 1:numel(lonv)
% If the given line contains double data
if isnumeric(lonv{i})
indv = lonv{i} > 180;
lonv{i}(indv) = lonv{i}(indv) - 360;
end
end
else
% If lonv is not of cell type, it is a different variable type,
% we perform the operation on the entire lonv (if it is of type double)
if isnumeric(lonv)
indv = lonv > 180;
lonv(indv) = lonv(indv) - 360;
end
end
There is also inaccuracy in CDT help (geomask): % For this sample 1 degree resolution grid: [Lat,Lon] = geogrid;
(geogrid is not defined function)
So maybe it will be better to use something like: [Lon,Lat] = meshgrid(lon, lat);
Thank you in advance for your response and possible correction of my statement.