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

Negative pixel size if area is flipped #433

Open
sfinkens opened this issue May 11, 2022 · 8 comments
Open

Negative pixel size if area is flipped #433

sfinkens opened this issue May 11, 2022 · 8 comments
Assignees

Comments

@sfinkens
Copy link
Member

Code Sample, a minimal, complete, and verifiable piece of code

from pyresample.geometry import AreaDefinition

area_def = AreaDefinition(
    "test",
    "test",
    "test",
    projection={"proj": "geos", "lon_0": 0, "h": 35785831.0},
    width=2,
    height=2,
    area_extent=[1, 1, -1, -1]   # flipped, upper right corner is S-E
)
area_def.pixel_size_x

Problem description

The pixel_size_x/y attribute of a flipped area is negative.

Expected Output

1.0

Actual Result, Traceback if applicable

-1.0

Versions of Python, package at hand and relevant dependencies

pyresample-1.22.3

@sfinkens sfinkens self-assigned this May 11, 2022
@djhoese
Copy link
Member

djhoese commented May 11, 2022

Any idea if this ever worked? I think I changed something recently about this so I want to double check that I didn't break this.

@sfinkens
Copy link
Member Author

I noticed it in the past, but then forgot to file an issue. Just tried with an old env that has pyresample-1.18.0, same issue.

@pnuu
Copy link
Member

pnuu commented May 12, 2022

I've always thought that is as expected...

@gerritholl
Copy link
Collaborator

gerritholl commented May 12, 2022

If we think of pixel_size as step_size then a negative value is indeed expected.

@sfinkens
Copy link
Member Author

Good point. Although I think of it as resolution. The documentation also describes it as width and height of the pixel. We could keep the current behavior in a step_size property?

@pnuu
Copy link
Member

pnuu commented May 12, 2022

Also geotiffs show the pixel size as negative for example for y-direction of geos projection where north is up.

@djhoese
Copy link
Member

djhoese commented May 12, 2022

I've used the idea of a negative pixel size in the past in Polar2Grid, but don't use it anymore and assume it will be positive. I'm not against forcing it to be positive if it makes everyone happy, but I don't think we need to retain the +/- value in a step_size, at least I don't think so. We'd have to make sure that various calculations that might use pixel size don't assume it can be negative which would make "fixing" the pixel size break this other code.

@sfinkens
Copy link
Member Author

sfinkens commented Dec 7, 2023

Oh, obviously I forgot about this issue... Now that I read your arguments again, I agree to keep the current behaviour. Maybe I'll just add a note the documentation that pixel size can be negative in certain situations.

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

4 participants