MapTiles.jl

Work with tiled web maps in Julia
Author JuliaGeo
Popularity
24 Stars
Updated Last
7 Months Ago
Started In
December 2017

MapTiles

CI codecov.io

MapTiles is a Julia package for working with tiled web maps, also known as slippy maps. It mainly concerns itself with getting a set of tile indices based on a given area of interest and zoom level, specified in WGS84 longitude/latitude or Web Mercator. It does not download any tile images, but can be used together with TileProviders.jl to create URIs for tiles, which can then be downloaded and plotted. Tyler.jl is a Makie package that uses MapTiles and TileProviders to plot interactive web maps, for instance as a background layer to plot geospatial data on top of.

Usage

using MapTiles, TileProviders
import HTTP, ImageMagick
using GeoInterface: Extent, extent

# get a single Tile with x, y and z index from a point and zoom level
point_wgs = (-105.0, 40.0)
tile = Tile(point_wgs, 8, MapTiles.wgs84)
# -> Tile(53, 96, 8)

# get the extent of a Tile in Web Mercator coordinates
bbox = extent(tile, MapTiles.web_mercator)
# -> Extent(X = (-1.1740727e7, -1.1584184e7), Y = (4.8528340e6, 5.0093770e6))

# get a TileGrid from an Extent and zoom level
bbox = Extent(X = (-1.23, 5.65), Y = (-5.68, 4.77))
tilegrid = TileGrid(bbox, 8, MapTiles.wgs84)
# -> TileGrid(CartesianIndices((127:132, 124:132)), 8)

# load the zoom 0 OpenStreetMap tile into an image
provider = OpenStreetMap()
tile = Tile(0, 0, 0)
url = geturl(provider, tile.x, tile.y, tile.z)
result = HTTP.get(url)
img = ImageMagick.readblob(result.body)
# -> 256×256 Array{RGB{N0f8},2}

Tile(0, 0, 0) of OpenStreetMap

Packages in other Languages

If you're coming from Python or R, you might be interested in the following packages instead:

Used By Packages