# Converting Longitude & Latitude to X Y on a map using Julia

**URL:** <https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-map-using-julia/20611>\
**Category:** General Usage\
**Tags:** geo, gmt, geodesy\
**Created:** [February 9, 2019, 6:08pm UTC](https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-map-using-julia/20611 "2019-02-09T18:08:37Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [February 10, 2021, 2:14pm UTC](https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-map-using-julia/20611/21 "2021-02-10T14:14:50Z")

</div>

> [@c42f](#):
>
> TBH we should probably have Web Mercator support in Geodesy.jl because it’s ubiquitous

Well, I went ahead and did this — let me know if it seems useful.

> <https://github.com/JuliaGeo/Geodesy.jl/pull/67>
>
> See https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-…map-using-julia/20611/13
> 
> The names \`WebMercatorfromLLA\` and \`LLAfromWebMercator\` seem a bit unfortunate, but the lowercase \`from\` is consistent with the rest of the transformations in this package, and WebMercator doesn't seem to have an obvious shortening. (There's WebMerc maybe, but unclear whether that's helpful.) There's also LatLon support here, but again I used \`LLA\` for consistency in naming even though it's a bit ugly.

@Wedg somehow I missed your comment about the implementation in PlotShapefiles.jl, but oh well 🙂

One nice (at least, IMO) thing the Geodesy.jl API provides is CoordinateTransformations.jl — based transformation objects so you can naturally create a whole pipeline of coordinate transformations.

TBH it feels a little dirty to provide this somewhat-broken projection in a package called “Geodesy”, but it’s undeniably needed as it’s ubiquitous in practice… Even the EPSG eventually had to give up and assign it an official code 😆

---

<div class="post-metadata">

**Author:** ![jrocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jrocha/32/30491_2.png) [@jrocha](https://discourse.julialang.org/u/jrocha)\
**Post date:** [November 4, 2022, 10:59am UTC](https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-map-using-julia/20611/22 "2022-11-04T10:59:44Z")

</div>

Hi @joa-quim, is there a way in Julia to convert from geographic coordinates (xº x’’ x’) to decimal coordinates to use in GMT?  
Thanks.  
João Rocha

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [November 4, 2022, 12:37pm UTC](https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-map-using-julia/20611/23 "2022-11-04T12:37:39Z")

</div>

Are you asking on how to do it from data in a file?  
It’s automatic

```julia
println(String(read("lixo.dat")))
-10:19:58.800 40:46:37.200

gmtread("lixo.dat")
1×2 GMTdataset{Float64, 2}
 Row │ col.1 col.2
     │ Float64 Float64
─────┼──────────────────
   1 │ -10.333 40.777

```

[Previous page](https://discourse.julialang.org/t/converting-longitude-latitude-to-x-y-on-a-map-using-julia/20611.md?page=1)
