# Package for map visualizations?

**URL:** <https://discourse.julialang.org/t/package-for-map-visualizations/1875>\
**Category:** Visualization\
**Created:** [February 3, 2017, 4:54pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875 "2017-02-03T16:54:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![evanfields](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanfields/32/1744_2.png) [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Post date:** [February 3, 2017, 4:54pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/1 "2017-02-03T16:54:05Z")

</div>

Is there a Julia package with resources for plotting map visualizations - something similar to R’s ggmap, perhaps? I’ve scanned through the Gadfly and Plots documentation and [pkg.julialang.org](http://pkg.julialang.org) and didn’t see anything obvious.

I’m interested in making visualizations similar to this: [http://i.imgur.com/Tub0BMD.jpg](http://i.imgur.com/Tub0BMD.jpg)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [February 3, 2017, 5:10pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/2 "2017-02-03T17:10:16Z")

</div>

Is there code available for that (neat) visualization?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [February 3, 2017, 5:30pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/3 "2017-02-03T17:30:02Z")

</div>

[http://www.reddit.com/r/boston/comments/17kd4b/2013\_boston\_rental\_heat\_map\_with\_added\_tstops/](http://www.reddit.com/r/boston/comments/17kd4b/2013_boston_rental_heat_map_with_added_tstops/)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 3, 2017, 5:33pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/4 "2017-02-03T17:33:29Z")

</div>

OpenStreetMap.jl for the underlying map. Plots.jl for the dots, lines and transparent heatmap. Perhaps Geodesy.jl if you need to project the coordinates.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [February 3, 2017, 5:34pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/5 "2017-02-03T17:34:35Z")

</div>

It’s pretty hard to actually find where the code and data are.

EDIT: Seems the code is basically [here](https://github.com/jeffkaufman/apartment_prices)

---

<div class="post-metadata">

**Author:** ![amellnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amellnik/32/137_2.png) [@amellnik](https://discourse.julialang.org/u/amellnik)\
**Post date:** [February 4, 2017, 12:09am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/6 "2017-02-04T00:09:17Z")

</div>

I know you can [layer scatter plots on top of geographic data in Plotly](https://plot.ly/javascript/scatter-plots-on-maps/), and I would think you could also do the same with a density plot. If that’s the case, then you can also do it in PlotlyJS.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 4, 2017, 2:44am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/7 "2017-02-04T02:44:17Z")

</div>

You can use the Matplotlib Basemap module through PyCall and PyPlot.

---

<div class="post-metadata">

**Author:** ![sglyon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sglyon/32/67_2.png) [@sglyon](https://discourse.julialang.org/u/sglyon)\
**Post date:** [February 4, 2017, 5:21am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/8 "2017-02-04T05:21:07Z")

</div>

@amellnik you are right on about this.

plotly.js can do it, so PlotlyJS.jl can also.

[here](http://spencerlyon.com/PlotlyJS.jl/examples/maps/) are a couple examples from the PlotlyJS.jl docs

---

<div class="post-metadata">

**Author:** ![evanfields](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanfields/32/1744_2.png) [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Post date:** [February 7, 2017, 4:42pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/9 "2017-02-07T16:42:00Z")

</div>

Thanks @sglyon. Can this be done with arbitrary maps downloaded from some API, similar to `get_map` and `ggmap()` in R’s tidyverse? (In my case, I’m trying to plot the densities at the city level.)

As far as I can tell, the PlotlyJS.jl documentation examples use the built-in maps listed [here (Plotly docs)](https://plot.ly/javascript/reference/#layout-geo-scope), which are limited to the enumerated options. Is that right?

There’s also `scattermapbox` which seems to work (see [here](http://codepen.io/etpinard/pen/oLdaXP) for an example), but that requires interacting with the MapBox service via Plotly; that example code includes

```julia
Plotly.setPlotConfig({
  mapboxAccessToken: ...
})

```

and I don’t see a way to do this via PlotlyJS.jl or Plotly.jl.

Am I missing something obvious about how to plot on arbitrary maps with PlotlyJS.jl?

---

<div class="post-metadata">

**Author:** ![sglyon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sglyon/32/67_2.png) [@sglyon](https://discourse.julialang.org/u/sglyon)\
**Post date:** [February 7, 2017, 5:24pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/10 "2017-02-07T17:24:41Z")

</div>

I don’t have any special code in PlotlyJS.jl that automates the creation of maps.

That being said, anything you’ve seen in any plotly library is possible in PlotlyJS.jl

The first example from the [python mapbox docs](https://plot.ly/python/scattermapbox/) would look like this in Julia:

```julia
mapbox_access_token = "pk.eyJ1IjoiY2hlbHNlYXBsb3RseSIsImEiOiJjaXFqeXVzdDkwMHFrZnRtOGtlMGtwcGs4In0.SLidkdBMEap9POJGIe1eGw"

data = scattermapbox(
    lat=[45.5017], lon=[-73.5673], text=["Montreal"],
    mode="markers", marker_size=14, 
)

layout = Layout(
    autosize=true, hovermode=closest,
    mapbox=attr(
        accesstoken=mapbox_access_token,
        bearing=0,
        center_lat=45, center_lon=-73,
        pitch=0,
        zoom=5
    )
)

plot([data], layout)

```

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 8, 2017, 8:14am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/12 "2017-02-08T08:14:46Z")

</div>

> [@mkborregaard](#):
>
> OpenStreetMap.jl for the underlying map. Plots.jl for the dots, lines and transparent heatmap

I have tried to experiment with just doing it in Plots (which I often find easier as it acts as a general interface to many plotting packages), but I’m having some trouble, so it appears my response was too glib. This is probably a case where you need to use a specific package, like PlotlyJS or PyPlot, as suggested by others. Note that if are happy with using PyCall to call Python libraries you might instead consider using RCall and just do the visualisation with ggmap, if you are used to that. Otherwise, it’d be very cool to see what julia-native solution you could find with PlotlyJS.

To my mind map visualisations are many things - it could include everything from building maps from the bottom up with rasters and shapefiles (that’s what I usually do - see this question [Overview of Geo tools](https://discourse.julialang.org/t/overview-of-geo-tools/1844) for the current progress of this kind of functionality in julia), to an interface to google map’s API (which I don’t think exists right now), to simply plotting a heatmap and points on top of an image taken from the interwebs (that was what I tried). All of these approaches could lead to the nice map you posted.

---

<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:** [February 8, 2017, 1:36pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/13 "2017-02-08T13:36:52Z")

</div>

I have a google maps API wrapper flying around, I’m just not sure if I can  
publish it. Google doesn’t seem to like people downloading it’s images. If  
someone wants to take a look at their AGBs and assure me that it’s legal to  
offer it as a package, please let me know!

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 8, 2017, 1:43pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/14 "2017-02-08T13:43:12Z")

</div>

This R package [CRAN - Package RgoogleMaps](https://CRAN.R-project.org/package=RgoogleMaps) is GPL-3, it could be an option to drop him an email and hear if he investigated the licensing issues.

---

<div class="post-metadata">

**Author:** ![evanfields](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanfields/32/1744_2.png) [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Post date:** [February 14, 2017, 2:40pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/15 "2017-02-14T14:40:27Z")

</div>

A small status update in case anybody from the future searches for map visualizations and finds this thread looking for advice:

- sglyon is of course totally correct that the mapbox plots can be done via PlotlyJS.jl. Mapbox does have a free API tier, and with the `scattermapbox` trace you can make some really nice looking scatter plots on maps. I definitely prefer the result over Google maps. Heatmaps on top of maps is less obvious than just using `scattermapbox` (there’s not a `heatmapmapbox`), but the Plotly documentation does have sections on geo axes, so it’s probably possible.
- The Mapbox docs show some heatmaps using mapbox directly, but I don’t think they look great.
- ggmap and ggplot in R provide lots of functionality, but I haven’t been able to produce exactly what I need with them. By default the density estimation doesn’t allow weights on points, but you can do your own density estimation and provide the density surface yourself - a bit of hassle, but doable. Plotting the density surface on a map isn’t great though; as far as I can tell, you’re limited to the contour polygon geometries. These can be filled in with color, but it doesn’t look great. (For general heatmaps you can use tile geometries with many small tiles, but tiles and map projections are incompatible.)
- Google maps has a visualization library you can use with a free API key (not sure about the licensing situation) which provides quite nice looking heatmaps. See [here](https://developers.google.com/maps/documentation/javascript/heatmaplayer) for an example. The code to generate those is in Javascript, so there is a hassle of going Julia data → javascript code.

---

<div class="post-metadata">

**Author:** ![amellnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amellnik/32/137_2.png) [@amellnik](https://discourse.julialang.org/u/amellnik)\
**Post date:** [February 16, 2017, 9:13pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/16 "2017-02-16T21:13:17Z")

</div>

It sounds like you’ve done a lot of looking into this. If this result is anything you can share a notebook or gist of, I think it would be pretty helpful for others who are interested in doing the same in the future!

---

<div class="post-metadata">

**Author:** ![anon51122801](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@anon51122801](https://discourse.julialang.org/u/anon51122801)\
**Post date:** [February 17, 2017, 4:51am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/17 "2017-02-17T04:51:18Z")

</div>

Comment from a Julia newb:

I was previously using Python 3 & Folium on top of OpenStreetMaps to generate valid HTML for web-based mapping. [Folium](https://github.com/python-visualization/folium) is a Python wrapper for the [LeafletJS](http://leafletjs.com/) library, which is an excellent library for all sorts of visualisations: charts, graphs, vectors and maps.

Based on the information I have read in relation to the Julia project, the aim is not merely to be an “alternative” to Python for general computing. However, with an ever increasing Julia code base across networked and inter-networked devices, I believe that the concept of visualising data in context of it’s geolocation, is increasingly needed.

While the PlotlyJS solution is workable, it produces (AFAIK) static images with overlaid and contextualised data of pre-defined sections of a map.

Whereas the Python/Folium/OpenStreetMaps or Python/Leaflet/OpenStreetMaps solutions produce valid HTML for use in a web app, existing web server or can even output a static image.

It is not that the Python solutions are better per se but they do seem to offer flexability (Multiple and variable data layers & data-related attributes), easy modification and almost real-time updating whereas the Julia solution(s) currently do not.

I’m happy to try and use Julia to call Python & Folium as a workaround but perhaps this needs a real developer assessment to judge the merits of this thread and identify or at least indicate a sane direction of progress for Julia & Mapping.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 17, 2017, 7:37am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/18 "2017-02-17T07:37:09Z")

</div>

I believe all of these things are in development - check the JuliaGeo organization and e.g. this thread [Overview of Geo tools](https://discourse.julialang.org/t/overview-of-geo-tools/1844)

---

<div class="post-metadata">

**Author:** ![anon51122801](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@anon51122801](https://discourse.julialang.org/u/anon51122801)\
**Post date:** [February 17, 2017, 7:49am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/19 "2017-02-17T07:49:35Z")

</div>

I had read that thread from your post (9 days ago) and it seems there is traction for change. So whom do we lobby for features? 🕶 I’m hands up for Alpha & Beta testing.

---

<div class="post-metadata">

**Author:** ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)\
**Post date:** [February 17, 2017, 11:51am UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/20 "2017-02-17T11:51:39Z")

</div>

The current head of the real time mapping committee for Julia development  
is a new community member named Justin Ant. I understand you know him…  
please pass along congratulations on his nomination.

In all seriousness… don’t offer testing services. Build.

---

<div class="post-metadata">

**Author:** ![amellnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amellnik/32/137_2.png) [@amellnik](https://discourse.julialang.org/u/amellnik)\
**Post date:** [February 17, 2017, 4:26pm UTC](https://discourse.julialang.org/t/package-for-map-visualizations/1875/21 "2017-02-17T16:26:32Z")

</div>

> [@jna](#):
>
> While the PlotlyJS solution is workable, it produces (AFAIK) static images with overlaid and contextualised data of pre-defined sections of a map.

One of the nice things about PlotlyJS is that you can get the JSON source for the plot, which can be used in any web page via normal plotly.js. That’s how [this](http://app.juliadiffeq.org/ode;settings=eyJkaWZmRXFUZXh0IjoiZHggPSBhKnggLSBiKngqeVxuZHkgPSAtYyp5ICsgZCp4KnkiLCJwYXJhbWV0ZXJzIjoiYT0xLjUsIGI9MSwgYz0zLCBkPTEiLCJ0aW1lU3BhbiI6WzAsMTBdLCJpbml0aWFsQ29uZGl0aW9ucyI6IjEuMCwgMS4wIiwic29sdmVyIjoiVHNpdDUiLCJ2YXJzIjoiWzp4LCA6eV0iLCJ0aXRsZSI6IlRoZSBMb3RrYS1Wb2x0ZXJyYSBFcXVhdGlvbnM6IE1vZGVsIG9mIFJhYmJpdHMgYW5kIFdvbHZlcyJ9) works (although it’s using PlotlyJS via Plots.jl rather than directly).

[Next page](https://discourse.julialang.org/t/package-for-map-visualizations/1875.md?page=2)
