# MapMaths and MapMakie - Computing and plotting in planetary coordinate systems

**URL:** https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498
**Category:** Package Announcements
**Created:** [January 8, 2024, 7:36am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498 "2024-01-08T07:36:51Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)
#### Post date: [January 8, 2024, 7:36am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/1 "2024-01-08T07:36:51Z")

</div>

[Subnero](https://subnero.com/), a wireless underwater communications company from sunny Singapore, proudly presents to the world the following two packages:

- [MapMakie](https://github.com/subnero1/MapMakie.jl): Plot on [OpenStreetMap](https://www.openstreetmap.org/) using Makie.
- [MapMaths](https://github.com/subnero1/MapMaths.jl): Utility tools for working with various planetary coordinate systems.

The purpose of MapMakie is pretty straightforward: it augments your Makie plots with OpenStreetMap raster tiles and thereby puts your abstract, hard-to-read geo-spatial data into an intuitive, real-world context. We are using MapMakie internally to create sophisticated, real-time visualisations of our modem deployments.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/4/e46156b6b5b55771daa2635466fae1f7f4513696.jpeg)

While working on MapMakie, we noticed that while the coordinate transformations provided by [Geodesy](https://github.com/JuliaGeo/Geodesy.jl) are great, the API of that package is occasionally not quite as convenient as it could be: `Int` isn’t consistently promoted to `Float`, it is difficult to generically convert from one coordinate system another, and the support for WebMercator coordinates is somewhat halfhearted. All of these issues can of course be worked around, but as Julia programmers [we wanted more](https://julialang.org/blog/2012/02/why-we-created-julia/#:~:text=We%20are%20greedy%3A-,we%20want%20more,-.) and so we went ahead and created MapMaths.

MapMaths is very similar to Geodesy in terms of functionality but exposes these tools in what we believe to be a more user-friendly API. Perhaps the best example to illustrate the difference between Geodesy and MapMaths is the conversion from [WebMercator](https://en.wikipedia.org/wiki/Web_Mercator_projection) to [ECEF](https://en.wikipedia.org/wiki/Earth-centered,_Earth-fixed_coordinate_system) (earth-centred, earth-fixed) coordinate system.

```julia
julia> using Geodesy

julia> ECEF(LLAfromWebMercator(wgs84)([0,0,0]), wgs84)
ECEF(6.378137e6, 0.0, 0.0)

```

```julia
julia> using MapMaths

julia> ECEF(WebMercator(0,0))
ECEF{Float64}(6.378137e6, 0.0, 0.0)

```

As you can see, MapMaths’ API is 100% based on types, and this in turn means that the commands are shorter and fully generic - in the above example, you can replace both `ECEF` and `WebMercator` with any other coordinate type (e.g. `LatLon`, `EastNorth`, or `WMX` (East-West component of WebMercator coordinates)), and as long as the conversion makes sense, everything will just work out as you would expect.

You can see the combined power of MapMakie and MapMaths in action in the following example from [MapMakie’s README](https://github.com/subnero1/MapMakie.jl).

```julia
using GLMakie, MapMakie, MapMaths, Unitful
f = Figure()
a = MapAxis(
    f[1,1];
    origin = LatLon(1.286770, 103.854307), # Merlion, Singapore
    ticks_coordinate = (EastNorth, u"km"),
    limits = (East.(2e3.*(-1,1)), North.(2e3.*(-1,1))),
)
scatter!(
    a,
    Point2f[(0,0)], # WebMercator coordinates relative to `origin`
    color = :red,
    markersize = 15,
    strokewidth = 6,
)
display(f)
save("/tmp/merlion.png", f)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/f/8fb2c840516af2ed276c9d5660ef1453594433b3.jpeg)

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [January 8, 2024, 7:50am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/2 "2024-01-08T07:50:36Z")

</div>

I really like the design of MapMaths.jl compared to Geodesy.jl, thanks for sharing the package. We will assess it internally to see if there is room for integration with our geospatial stack.

Are you aware of the Makie.jl recipes discussed in the Geospatial Data Science with Julia book? Perhaps there is room for collaboration. Our recipes generalize to 3D spaces, and we are working really hard to avoid this community split where people doing GIS only care about 2D and people doing other geosciences (geophysics, 3D geology) have to use other dedicated software (e.g. Paraview).

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [January 8, 2024, 7:55am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/3 "2024-01-08T07:55:13Z")

</div>

> [@ettersi](#):
>
> [Subnero](https://subnero.com/), a wireless underwater communications company from sunny Singapore, proudly presents to the world the following two packages

[Meta-comment] Has Subnero considered [supporting Makie’s](https://makie.org/support/) hardworking developers and maintainers?

---

<div class="post-metadata">

### Author: ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)
#### Post date: [January 8, 2024, 8:51am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/4 "2024-01-08T08:51:12Z")

</div>

> [@juliohm](#):
>
> Are you aware of the [Makie.jl](https://juliahub.com/ui/Packages/Makie) recipes discussed in the Geospatial Data Science with Julia book?

Not at all, curious to hear more!

> [@rafael.guerra](#):
>
> > [@ettersi](#):
> >
> > [Subnero](https://subnero.com/), a wireless underwater communications company from sunny Singapore, proudly presents to the world the following two packages
> 
> [Meta-comment] Has Subnero considered [supporting Makie’s](https://makie.org/support/) hardworking developers and maintainers?

We very much appreciate all the hard work done by the Makie community, but unfortunately the size of our company restricts us to giving back in the form of open-source code related to our immediate needs.

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [January 8, 2024, 9:10am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/5 "2024-01-08T09:10:36Z")

</div>

cc @fbanning who has developed [GitHub - MakieOrg/OSMMakie.jl: A Makie.jl recipe for plotting OpenStreetMap data.](https://github.com/MakieOrg/OSMMakie.jl)

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [January 8, 2024, 9:57am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/6 "2024-01-08T09:57:44Z")

</div>

```julia
MapMaths

```

this seems great, perhaps even GeoMakie.jl can benefit from it to simplify internal handling of representations!

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [January 8, 2024, 9:59am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/7 "2024-01-08T09:59:30Z")

</div>

@ettersi I am also notifying you of the discussion here: [New package: Elliptic2 v0.2.0 by JuliaRegistrator · Pull Request #97594 · JuliaRegistries/General · GitHub](https://github.com/JuliaRegistries/General/pull/97594) as you also seem to utilize Elliptic.jl!

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [January 8, 2024, 10:57am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/8 "2024-01-08T10:57:54Z")

</div>

Hi nice packages! just checking thst youre aware of these:

> **[GitHub - MakieOrg/Tyler.jl: Makie package to plot maptiles from various map...](https://github.com/MakieOrg/Tyler.jl)**
>
> Makie package to plot maptiles from various map providers - GitHub - MakieOrg/Tyler.jl: Makie package to plot maptiles from various map providers

> **[GitHub - JuliaGeo/TileProviders.jl: Shared collection of map tile providers](https://github.com/JuliaGeo/TileProviders.jl)**
>
> Shared collection of map tile providers. Contribute to JuliaGeo/TileProviders.jl development by creating an account on GitHub.

TileProviders is an extendive list of online tile sources, and Tyler.jl is pretty similar to MapMakie, with pretty well optimised zooming and tile loading, and can use all the TileProviders.jl tiles.

---

<div class="post-metadata">

### Author: ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)
#### Post date: [January 8, 2024, 1:59pm UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/9 "2024-01-08T13:59:09Z")

</div>

Dang, I was not aware of these packages, and I probably would have proceeded differently if I had been.

I agree that Tyler serves basically the same purpose as MapMakie, and I wouldn’t be surprised if there’s a bunch of things it does much better than MapMakie. However, it seems Tyler doesn’t allow for an offset between the axis and map coordinates, and this feature is a must-have for our use case. Without it, Makie rounds all coordinates to a grid with about 2.5m mesh width when converting to `Float32`, and this rounding leads to noticeable and distracting artefacts.

Also, it would be nice if TileProviders provided a way to store tiles to disk and then use those tiles as an offline tile provider. We don’t always have internet access during our field trials, so providing some “offline mode” is quite important to us. I’m currently working on this feature for MapMakie, and I might raise a corresponding PR to TileProviders if and when I find the time.

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [January 8, 2024, 3:04pm UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/10 "2024-01-08T15:04:01Z")

</div>

Yes Float32 is a problem with Tyler.jl. Good you hear you have solved it!

It also would be good to work together in future! I personally put a lot if work into smooth and fast zoom and layered tile loading in Tyler.jl, give it a try. There are also potential for 3d tiles and other features in future.

TileProviders.jl is mainly a souce of links to providers, it intentionally doesnt do anything else so its also useful a a minimal deoendency for Leaflet.jl and other things. But it would be good to have that functionality somewhere.

You may also want to look at MapTiles.jl that replicates even more of your code… we should seriously look and combing these efforts.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [January 8, 2024, 3:51pm UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/11 "2024-01-08T15:51:58Z")

</div>

> [@ettersi](#):
>
> Not at all, curious to hear more!

Here is the link: [Geospatial Data Science with Julia](https://juliaearth.github.io/geospatial-data-science-with-julia)

Appreciate if you can take a look and see how we could work closer regarding MapMaths.jl. We have plans to create a similar design and could just reuse the efforts you are leading there.

---

<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: [January 8, 2024, 7:52pm UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/12 "2024-01-08T19:52:53Z")

</div>

> [@ettersi](#):
>
> Also, it would be nice if TileProviders provided a way to store tiles to disk and then use those tiles as an offline tile provider.

Have a look at GMT.jl [mosaic](https://www.generic-mapping-tools.org/GMTjl_doc/documentation/utilities/mosaic/index.html#mosaic)

---

<div class="post-metadata">

### Author: ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)
#### Post date: [January 9, 2024, 9:01am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/13 "2024-01-09T09:01:22Z")

</div>

I just want to chime in and say that I am extremely excited about the tone of the developers of these similar packages. It sounds like you are all open for collaboration and unification, which is really healthy for the Julia Package Ecosystem!

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [January 9, 2024, 9:02am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/14 "2024-01-09T09:02:51Z")

</div>

And I will add that we take PRs to add third-party packages to the Makie docs, maybe if Tyler and OSMMakie were listed there, the duplicated effort could have been avoided.

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [January 9, 2024, 10:22am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/15 "2024-01-09T10:22:36Z")

</div>

We do list them on [Makie.org](http://Makie.org):  
[https://makie.org/](https://makie.org/)  
Maybe we need to unify these more with the docs.  
Hard to do nicely without lots of repetition 😉

---

<div class="post-metadata">

### Author: ![dmolina](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmolina/32/5246_2.png) [@dmolina](https://discourse.julialang.org/u/dmolina)
#### Post date: [January 12, 2024, 6:50am UTC](https://discourse.julialang.org/t/mapmaths-and-mapmakie-computing-and-plotting-in-planetary-coordinate-systems/108498/16 "2024-01-12T06:50:11Z")

</div>

Thank you, there were several interesting packages I did not know 😉.
