Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self-correcting error in polygon2GRIDobj #39

Open
oejwing opened this issue Jul 10, 2023 · 2 comments
Open

self-correcting error in polygon2GRIDobj #39

oejwing opened this issue Jul 10, 2023 · 2 comments

Comments

@oejwing
Copy link

oejwing commented Jul 10, 2023

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.

@oejwing
Copy link
Author

oejwing commented Jul 10, 2023

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

@wschwanghart
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants