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

error in convert proj #3

Open
sergiorosalesg opened this issue Jul 22, 2022 · 2 comments
Open

error in convert proj #3

sergiorosalesg opened this issue Jul 22, 2022 · 2 comments

Comments

@sergiorosalesg
Copy link

Hi

I modified the pyfcom_preprocessing example to work with my mesh, but in the conversion from UTM to Lat Lon I got the following error
invalid projection: +proj=utm +zone=-18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs: (Internal Proj Error: proj_create: Error 1027 (Invalid value for an argument): UTM: Invalid value for zone)
When reviewing I realized that I cannot indicate that the coordinates correspond to the southern hemisphere. I will try to modify the code to incorporate that option

@jimc101
Copy link
Member

jimc101 commented Jul 22, 2022

I wonder if this is the same issue I encountered in PyLag, where I maintain a module that is based off coordinate.py in PyFVCOM. See issue 70 for further details. I ended up fixing this by switching to using EPSG codes rather than UTM zones when doing coordinate transformations. The updated cooridnate.py file includes the solution I adopted. Note this is a fairly major changes which alters the calling API. Thus, lots of existing scripts would likely have to change to use it. If this is the same problem, you could alternatively try limiting the version of pyproj/proj you use with PyFVCOM.

@sergiorosalesg
Copy link
Author

as my problem is to get positions in the southern hemisphere I made the following change in _covert

the original line:
projection = pyproj.Proj("+proj=utm +zone={} +ellps={} +datum={} +units=m +no_defs".format(zone, ellipsoid, datum))

I change for:

if zone<0:
z=abs(zone)
projection = pyproj.Proj("+proj=utm +zone={} +south +ellps={} +datum={} +units=m +no_defs".format(z, ellipsoid, datum))
else:
projection = pyproj.Proj("+proj=utm +zone={} +ellps={} +datum={} +units=m +no_defs".format(zone, ellipsoid, datum))

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