wschwanghart/topotoolbox

self-correcting error in polygon2GRIDobj

Closed this issue · 2 comments

In getmask, getextent is called with the order of the arguments being row/lat/y first and col/lon/x second.

ext = getextent(r,c);

However, getextent requires the order to the opposite.

function ext = getextent(x,y)
ext = [min(x) max(x) min(y) max(y)];
end

This means getmask has swapped X and Y dimensions. Fortunately, the ext(1:2) refers to Y and ext(3:4) refers to X, so the error corrects itself. But I suggest returning ext = [min(y) max(y) min(x) max(x)]; in getextent and call getextent(c,r) in getmask.

(potentially we also just have different definitions of how x,y map to row,col!)

Hi @oejwing
well spotted ;-). I agree that the naming of the variables in getextent is confusing, and x and should be renamed to row and y should be col. I will change this because otherwise, this really makes reading the code difficult. In the end, it doesn't produce an error.
In the end, it is the order to which we are used to and which is confusing: lat lon, x y, row col...
Cheers, Wolfgang