XYZ Tile API
  • 24 Jan 2024
  • 3 Minutes to read
  • Dark
    Light
  • PDF

XYZ Tile API

  • Dark
    Light
  • PDF

Article Summary

XYZ Tile API

XYZ Tiles, also known as slippy map tiles, is a method of expressing map tile mosaics, indexed by (x,y) offsets and zoom levels (z).

Unlike WMTS, there is no formal Get Capabilities request to obtain meta data about a tile service, however we have an Imagery API endpoint that will return available layers with bounding box in JSON format

Most applications have in-built knowledge of the mosaic and how to access the correct tile to fulfil a view (For example, QGIS). XYZ Tiles uses a REST interface where a request for a tile includes the desired map layer, x, y and z values as part of the URL. URLs are typically of the format. You must replace the parameters shown in shown in [square brackets]

TMS vs XYZ

The different between XYZ and TMS is that the y-axis is flipped. XYZ can therefore convert from to TMS (and back again) using the following generic code statement to flip the y coordinate.

y = (2^z) - y - 1

https://api-v3.metromap.com.au/tiles/xyz/Australia_latest/{z}/{y}/{x}.png?key=[API KEY]

https://api-v3.metromap.com.au/tiles/xyz/[layername]/{z}/{y}/{x}.{format}?key=[API KEY]&contrastfilter=[contrastfilter]&brightnessfilter=[brightnessfilter]&unsharpmaskfilter=[unsharpmaskfilter]&contrast=[contrast]&brightness=[brightness]&umradius=[umradius]&umpercent=[umpercent]

XYZ Specification

ParameterAccept formatPurposeNote
[layerid]*int or stringthe id of the required map layerThis can also be the name of the layer (For example, Australia_latest)
{z}*intzoom level of the tileThese parameters are not necessary to be change to see the images (most of the software will recognise the curly bracket and automatically substitute a number accordingly) See example below.
{y}*intvertical location offset of the tile (aka. row)
{x}*inthorizontal location offset of the tile (aka. column)
{format}*strspecify the format of the tileAvailable formats are:'webp', 'jpg', 'jpeg', 'png', 'jpgpng'
[API KEY]*stringthe API keyA valid API key, otherwise a 401 Error will be given.
[contrastfilter]booleanContrast filter is on or off
[brightnessfilter]booleanBrightness filter is on or off
[unsharpmaskfilter]booleanUnsharpmask filter is on or off
[contrast]floatAmount of contrast enhancement
[brightness]floatAmount of brightness enhancement
[um_radius]intUnsharp mask filter’s Blur Radius
[um_percent]intUnsharp mask filter’s Unsharp strengthValue in percent

(star(*) indicates the parameter is mandatory)

  • Example in QGIS v3.xx

Create New Connection:
XYZ_QGIS1.png

Change Max. Zoom Level to 22 to get the best of MetroMap high resolution imagery
QGIS_XYZ_Tile_Zoom_Level_1.png



Appoint a name and URL to the connection:
XYZ_QGIS1.png

Note: substitute a valid API key to the URL after ‘key’ parameter and a valid layer id/name (see specification above)

Drag the service to the layer then the image will be shown on the map
XYZ_QGIS3.png

Your account must have permission to access this service, to request access please contact your MetroMap Account Manager or email MetroMap Support


Click to see previous version

REQUEST=GetCapabilities

https://api.metromap.com.au/metromapkey/wmts?key={api-key}&SERVICE=WMTS&REQUEST=GetCapabilities

REQUEST=GetTile

https://api.metromap.com.au/metromapkey/wmts?key={api-key}&SERVICE=WMTS&REQUEST={request}&LAYER={layer}&FORMAT={format}&TileMatrixSet={tilematrixset}&TileMatrix={tilematrix}&TileRow={row}&TileCol={col}

If REQUEST=GetTile, you must specify the following parameters:

RequiredKeyValue
LAYERThe Identifier of the tile. (e.g. Melbourne_2019_5_GM) If you are unsure, use REQUEST=GetCapabilities to get a XML file listing all avaliable tiles and the identifier of each tile.
FORMATFormat of the return tile image
  • image/jpeg
  • image/webp
  • image/png
OptionalVERSION1.0.0
OptionalSTYLE
  • default
TileMatrixSet
  • GoogleCRS84QuadExt:epsg:4326
  • GoogleMapsCompatibleExt:epsg:3857
  • OGC:1.0:GlobalCRS84Pixel
  • OGC:1.0:GoogleMapsCompatible
TileMatrixValue differ based on the TileMatrixSet you choose. For a list of accepted value of each of the TileMatrixSet, refer to the bottom section of the Capabilities XML
TileRowRow number of the tile
TileColColumn number of the tile

Example of a GetTile Request:

https://api.metromap.com.au/metromapkey/wmts?key={api-key}&REQUEST=GetTile&SERVICE=WMTS&LAYER=Melbourne_2019_5_GM&FORMAT=image/jpeg&TileMatrixSet=GoogleCRS84QuadExt:epsg:4326&TileMatrix=20&TileRow=643142&TileCol=947623

Responses

The following table describes the possible HTTP response status codes to the URL request and the surveys response fields:

CodeDescription
200OK
400Bad Request. Returned when the request is invalid. This means either the format is wrong, or a value is out of range.
401Unauthorized. Returned when the API key is invalid.
403Forbidden. Returned when not allowed to access the requested location.
404Not Found. Returned when cannot find any surveys for the requested condition.
5XXServer Error. Returned when something is wrong in the server side.



Was this article helpful?

What's Next