You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
get lon,lat from image coordinates (using mapproject) #1986
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.
👋 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.
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).
thank you Wei Ji,
actually, the question is rather about function that would have input as
x,y coordinates of an image (that contains map on canvas, generated by GMT)
and in my opinion it should be fairly easy to just get lat,lon from there,
as GMT should know where it places related pixels.
i can do the rest )
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.
thank you Wei Ji,
actually, can you share some material/code that would help me figure out
how to best wrap the (compiled) C code to python (outside of just
os.system)?
that might be helpful.
cheers!
M.
After a long delay, it's likely we will wrap the mapproject module (at least an initial implementation) in the next few months. I'm closing this feature request, and the progress will be tracked in #4209
hi, that's great news!
really appreciate your continuous work on pyGMT!!
From my side, we used your advices and got this done through the proper way on calling mapproject! allowing interactive jupyter widget - see my post that refers to the lines towards mapproject (you may find it useful, or just very satisfying):
Activity
welcome commentedon 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 commentedon 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 commentedon Jul 2, 2022
weiji14 commentedon 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
mapprojectto 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 commentedon 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.
weiji14 commentedon Jul 11, 2022
The single lonlat to xy conversion could be considered as a feature request for
mapprojectto be wrapped in PyGMT. I'll reopen this issue to keep track.[-]get lon,lat from image coordinates[/-][+]get lon,lat from image coordinates (using mapproject)[/+]espiritocz commentedon Jul 19, 2022
espiritocz commentedon Jun 4, 2023
seisman commentedon Nov 14, 2025
After a long delay, it's likely we will wrap the
mapprojectmodule (at least an initial implementation) in the next few months. I'm closing this feature request, and the progress will be tracked in #4209espiritocz commentedon Nov 14, 2025
hi, that's great news!
really appreciate your continuous work on pyGMT!!
From my side, we used your advices and got this done through the proper way on calling mapproject! allowing interactive jupyter widget - see my post that refers to the lines towards mapproject (you may find it useful, or just very satisfying):
https://forum.generic-mapping-tools.org/t/interactive-pygmt-solution-in-jupyter/5369