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

CreateProjOrigin and axis order of projection #22

Open
Achton-Boel opened this issue May 2, 2022 · 3 comments
Open

CreateProjOrigin and axis order of projection #22

Achton-Boel opened this issue May 2, 2022 · 3 comments

Comments

@Achton-Boel
Copy link

CreateProjOrigin is not working correctly when the axis order of the local coordinate system is (north, east) instead of (east, north).

To reproduce in Python:

from mikecore.Projections import Cartography
projectionString = 'PROJCS["SWEREF99 13 30",GEOGCS["SWEREF99",DATUM["SWEREF99",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6619"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4619"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",13.5],PARAMETER["scale_factor",1],PARAMETER["false_easting",150000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Northing",NORTH],AXIS["Easting",EAST],AUTHORITY["EPSG","3008"]]'
cart = Cartography.CreateProjOrigin(projectionString = projectionString, east = 100007.0, north = 6215293.0, orientationProj = 0)
print(cart.LonOrigin, cart.LatOrigin)

Expected behavior
Expected to get lon/lat coordinates close to Helsingborg. Got lon/lat coordinates in the Indian Ocean.

@ecomodeller
Copy link
Member

As if projections wasn't complicated already...

image

We will pass this onto the mikecore team.

@ecomodeller ecomodeller transferred this issue from DHI/mikeio May 2, 2022
@JesperGr
Copy link
Collaborator

JesperGr commented May 9, 2022

This is actually working as designed. The arguments to CreateProjOrigin contains argument for two axis values. For a NorthEast oriented coordinate system, the first one will then be northing, and the second will be easting. And that works similarly for all the axis types, as e.g. also the SouthWest oriented axis.

That then clashes with the fact that the arguments in the code are named east and north. Maybe they should have been named x and y, or at least something more generic.

There are similar issues in the other classes, as e.g. the MapProjection.Proj2Geo and Cartography.Proj2Xy. The latter converts from projection-(x,y) to a local-grid-(x,y), and the projection-(x,y) is then called (east, north) in the code.

An option could be to rename arguments in the entire code, replacing (east, north) with e.g. (projX, projY).

However, that may break a significant amount of code. Is that worth that?

@ecomodeller
Copy link
Member

No, probably not.

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

3 participants