MapMaths and MapMakie - Computing and plotting in planetary coordinate systems

Subnero, a wireless underwater communications company from sunny Singapore, proudly presents to the world the following two packages:

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.

While working on MapMakie, we noticed that while the coordinate transformations provided by Geodesy 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 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 to ECEF (earth-centred, earth-fixed) coordinate system.

julia> using Geodesy

julia> ECEF(LLAfromWebMercator(wgs84)([0,0,0]), wgs84)
ECEF(6.378137e6, 0.0, 0.0)
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.

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)

29 Likes

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

3 Likes

[Meta-comment] Has Subnero considered supporting Makie’s hardworking developers and maintainers?

1 Like

Not at all, curious to hear more!

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.

3 Likes

cc @fbanning who has developed GitHub - MakieOrg/OSMMakie.jl: A Makie.jl recipe for plotting OpenStreetMap data.

2 Likes
MapMaths

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

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

1 Like

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

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.

1 Like

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.

1 Like

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.

2 Likes

Here is the link: 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.

Have a look at GMT.jl mosaic

1 Like

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!

5 Likes

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.

2 Likes

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

3 Likes

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