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

get lon,lat from image coordinates (using mapproject) #1986

Open
espiritocz opened this issue Jul 2, 2022 · 8 comments
Open

get lon,lat from image coordinates (using mapproject) #1986

espiritocz opened this issue Jul 2, 2022 · 8 comments
Labels
feature request New feature wanted help wanted Helping hands are appreciated

Comments

@espiritocz
Copy link

hi guys,
inspired by your egu materials (the trick with Panel), i thought about another interactive feature in ipynb. i want to run a function (show time series plot) upon clicking to the map.

for this, i can get x,y coordinates in generated image, as in:
https://stackoverflow.com/questions/52235476/jupyter-notebook-register-mouse-position-clicks-moves-on-a-displayed-image-j

is there a way on how to get original geographic coordinates, i.e. back-projection from final image coordinates to lon, lat of the source?

thank you for any hints to push this forward

@welcome
Copy link

welcome bot commented Jul 2, 2022

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

@weiji14 weiji14 added the question Further information is requested label Jul 2, 2022
@weiji14
Copy link
Member

weiji14 commented Jul 2, 2022

Hi @espiritocz, glad to see someone checking out the EGU short course materials! From the sounds of what you're trying to do (click on a map to get lon/lat coordinates), you may want to check out https://geoviews.org/index.html instead. Unfortunately it'll be quite difficult to get PyGMT to respond to clicks on a map (since GMT isn't actually designed for interactivity).

Geoviews has a forum at https://discourse.holoviz.org/c/geoviews/7 which would be suited for these types of questions. Good luck!

@espiritocz
Copy link
Author

espiritocz commented Jul 2, 2022 via email

@weiji14
Copy link
Member

weiji14 commented Jul 3, 2022

Ah ok, so if you just want to convert image x y coordinates to longitude and latitude, that can be done with an affine transform that encodes information about the top left corner's coordinates and the pixel size, e.g. following https://gis.stackexchange.com/questions/395667/translating-x-y-coordinates-to-lat-long/395680#395680.

If you don't mind the command line, GMT does have mapproject to convert lonlat to xy (or vice versa), see https://docs.generic-mapping-tools.org/6.4/mapproject.html. Unfortunately that isn't wrapped in PyGMT yet.

@seisman
Copy link
Member

seisman commented Jul 10, 2022

I'm closing the issue because I think this feature is beyond the scope of the PyGMT project.

Feel free to reopen the issue if you think more should be discussed.

@seisman seisman closed this as completed Jul 10, 2022
@weiji14
Copy link
Member

weiji14 commented Jul 11, 2022

The single lonlat to xy conversion could be considered as a feature request for mapproject to be wrapped in PyGMT. I'll reopen this issue to keep track.

@weiji14 weiji14 reopened this Jul 11, 2022
@weiji14 weiji14 changed the title get lon,lat from image coordinates get lon,lat from image coordinates (using mapproject) Jul 11, 2022
@weiji14 weiji14 added help wanted Helping hands are appreciated feature request New feature wanted and removed question Further information is requested labels Jul 11, 2022
@espiritocz
Copy link
Author

espiritocz commented Jul 19, 2022 via email

@espiritocz
Copy link
Author

espiritocz commented Jun 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted help wanted Helping hands are appreciated
Projects
None yet
Development

No branches or pull requests

3 participants