Using the GeoServer option, it is possible to load map tiles from external services.

Which services are compatible with GeoServer? How can I find such services? Does GeoServer follow a standard that has a name that I can google for?

The documentation shows a few examples:

GeoGraphics[{Entity["AdministrativeDivision", {"California", "UnitedStates"}]}, 
   GeoServer -> "http://a.tile.openstreetmap.org/`1`/`2`/`3`.png"
]

Mathematica graphics

Mapbox works. It requires an API key which can be retrieved for free, for information about pricing read this.

Mapbox has many beautiful map styles, and also the ability for you to create your own map styles or modify existing ones with their browser based tool.

Here is a list of default styles that everyone has access to:

styles = {"streets", "light", "dark", "satellite", 
   "streets-satellite", "wheatpaste", "streets-basic", "comic", 
   "outdoors", "run-bike-hike", "pencil", "pirates", "emerald", 
   "high-contrast"};

Here is a template for using Mapbox with GeoGraphics:

token = (* your API key here *);
style = "outdoors";
st[style_] := StringTemplate["https://api.mapbox.com/v4/mapbox." <> style <> "/``/``/``.png?access_token=" <> token];

GeoGraphics[
 GeoRange -> Entity["City", {"Goteborg", "VastraGotaland", "Sweden"}],
 GeoServer -> {st[style], "ZoomRange" -> {1, 22}}
 ]

Mathematica graphics

Here is an example using the "pirates" style:

Mathematica graphics

And another one, also depicting Gothenburg, using the "pencil" style:

Mathematica graphics

up vote 11 down vote accepted

The keywords to search for are "tile server" and "XYZ URL". I was able to find several services compatible with this format.

There is a list, complete with previews here:

(Found through GIS.SE)

The {x}, {y} and {z} placeholders in the URL correspond to `1`, `2` and `3` in Mathematica.

MapBox is another great source for base maps, as shown by @C.E. in his answer.


Here are a few examples that do not require API keys:

From https://basemap.nationalmap.gov/,

USGS[map :"HydroCached" | "ImageryOnly" | "ImageryTopo" |"ShadedReliefOnly" | "Topo"] :=
 "https://basemap.nationalmap.gov/arcgis/rest/services/USGS" <> map <> "/MapServer/tile/`1`/`3`/`2`"

From https://carto.com/location-data-services/basemaps/,

carto[style : "light_all" | "dark_all" | "light_nolabels" | "light_only_labels" |"dark_nolabels" | "dark_only_labels"] :=
 "https://cartodb-basemaps-1.global.ssl.fastly.net/" <> style <> "/`1`/`2`/`3`.png"

From http://maps.stamen.com/,

stamenBase[style_, format_] := "http://tile.stamen.com/" <> style <> "/`1`/`2`/`3`." <> format
stamen[style : "toner"] := stamenBase[style, "png"]
stamen[style : "watercolor" | "terrain"] := stamenBase[style, "jpg"]

Demo:

GeoGraphics[Entity["AdministrativeDivision", {"California", "UnitedStates"}], 
   GeoServer -> #] & /@ {USGS["Topo"], carto["light_all"], stamen["terrain"]}

enter image description here

These are just quick and dirty examples. In some cases it may be beneficial or necessary to set the "Tileset" suboption of GeoServer (see under Details in doc page).


Tile servers can also be used with the interactive DynamicGeoGraphics:

DynamicGeoGraphics[Entity["City", {"Lyon", "RhoneAlpes", "France"}], 
 GeoServer -> stamen["toner"]]

enter image description here

  • China hard to use those serve. How to make this map be a mma server? – yode Oct 18 '17 at 19:08
  • @yode it won't be easy. The first though would be to use "http://api.map.baidu.com/staticimage?center=2,3&width=300&height=300&zoom=1" but unfortunately Baidu seems to use a different tile spec than the others and also Baidu uses a different coordinate system – b3m2a1 Apr 18 at 1:36
  • @b3m2a1 I believe that in China, all mapping services must use a certain standard (Chinese) coordinate system by law. This coordinate system differs from what is commonly used by web mapping services, leading to a misalignment with some services (e.g. google map data vs google satellite data). en.wikipedia.org/wiki/… – Szabolcs Apr 18 at 10:12

This specific usage in the documentation confused me momentarily as there is a server for serving mapping features called specifically GeoServer.

However, I think in this usage they mean any kind of server that can provide GIS data.

On the documentation page they specify what the remote server must accept as a request string.

The URL template for tile download uses the XYZ protocol and must be given as a string "http://…/`1`/`2`/`3`.png" or as StringTemplate["http://…/`1`/`2`/`3`.png"]...

This URI is in the Tile Map Service (TMS/WTMS) specification for serving raster data from a server. Most tile servers accept TMS specification as it is standard created by the Open Geospatial Consortium, an organization created to help standardise GIS interoperability.

In the example you provide, they are accessing OpenStreetMaps' own tile server to provide tiles for the slippymap. If you didn't specify the server the map service would use the default values, which appear to be Wolfram's own servers.

  • This seems to suggest that XYZ and TMS are different things (but I don't know much about GIS stuff). – Szabolcs Sep 7 '17 at 20:02
  • The TMS, I believe came out of the XYZ schema, and wikipedia seems to supports my recollection. TilesetOrientation option in GeoServer accounts for the Y axis reversal between the XYZ and TMS specification. In practice, I have not experienced an issue between the two. – RomaH Sep 7 '17 at 20:27

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.