Skip to content

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

Closed

Description

@espiritocz

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

Activity

  1. welcome commented on Jul 2, 2022

    @welcome

    👋 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.

  2. added
    question
    on Jul 2, 2022
  3. weiji14 commented on Jul 2, 2022

    @weiji14
    Member

    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!

  4. espiritocz commented on Jul 2, 2022

    @espiritocz
    Author
  5. weiji14 commented on Jul 3, 2022

    @weiji14
    Member

    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.

  6. seisman commented on Jul 10, 2022

    @seisman
    Member

    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.

  7. weiji14 commented on Jul 11, 2022

    @weiji14
    Member

    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.

  8. changed the title [-]get lon,lat from image coordinates[/-] [+]get lon,lat from image coordinates (using mapproject)[/+] on Jul 11, 2022
  9. added
    help wanted
    feature request
    and removed
    question
    on Jul 11, 2022
  10. espiritocz commented on Jul 19, 2022

    @espiritocz
    Author
  11. espiritocz commented on Jun 4, 2023

    @espiritocz
    Author
  12. removed
    help wanted
    on Nov 14, 2025
  13. seisman commented on Nov 14, 2025

    @seisman
    Member

    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

  14. added this to the 0.18.0 milestone on Nov 14, 2025
  15. espiritocz commented on Nov 14, 2025

    @espiritocz
    Author

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions