In the final installment, we look at how to consume the tiles we uploaded to GCS from the two most popular Desktop GIS packages: QGIS and Esri's ArcGIS Pro.
In the first part of this series, we baked the Hamilton County contour vector tiles and uploaded them to GCS. Last time, we demonstrated how to consume the tiles in web clients. Now, we turn to desktop GIS clients, the workhorses of the GIS professional.
QGIS
Since QGIS doesn't offer direct support for vector tiles, we will use the Vector Tiles Reader plugin. The plugin requires the tile server to support the TileJSON format.
TileJSON
The TileJSON specification requires a json file that describes the tileset characteristics. These are the contents of tiles.json:
{
"bounds": [
-84.82072199999999,
39.02586199999998,
-84.235878,
39.31225600000001
],
"center": [
-84.80896,
39.23650799999998,
15
],
"crs": "EPSG:3857",
"crs_wkt": "PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH],EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs\"],AUTHORITY[\"EPSG\",\"3857\"]]",
"description": "hamilton_contours_50ft.mbtiles",
"extent": [
-9442199.581757817,
4725376.759498271,
-9377095.045484316,
4766498.776948617
],
"format": "pbf",
"generator": "tippecanoe v1.35.0",
"generator_options": "tippecanoe -zg -o hamilton_contours_50ft.mbtiles hamilton_contours_50ft.geojson",
"maxzoom": 15,
"minzoom": 0,
"name": "hamilton_contours_50ft.mbtiles",
"tile_grid": "mercator",
"tilejson": "2.0.0",
"tiles": [
"https://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/{z}/{x}/{y}.pbf"
],
"tilestats": {
"layerCount": 1,
"layers": [
{
"attributeCount": 1,
"attributes": [
{
"attribute": "ELEVATION",
"count": 6,
"max": 1000,
"min": 500,
"type": "number",
"values": [
1000,
500,
600,
700,
800,
900
]
}],
"count": 10104,
"geometry": "LineString",
"layer": "hamilton_contours_50ft"
}]
},
"type": "overlay",
"vector_layers": [
{
"description": "",
"fields": {
"ELEVATION": "Number"
},
"id": "hamilton_contours_50ft",
"maxzoom": 15,
"minzoom": 0
}],
"version": "2"
}
There's a convenient way to generate tiles.json. You can use a free maptiler.com account to generate a metadata file upon uploading your tiles in .mbtiles format. First, create the tileset in the .mbtiles format:
tippecanoe \
-z11 -o hamilton_contours_50ft.mbtiles hamilton_contours_50ft.geojson
Upload the hamilton_contours_50ft.mbtiles file to maptiler.com as a new tileset. Unfortunately, because we already used our one-time free account, we cannot show the result.
The maptiler.com tileset creation makes tiles.json available from a well-known endpoint. See the land cover tileset below as an example.
Now that tiles.json is available locally on disk, we can upload to GCS.
gsutil cp \
hamilton_contours_50ft/tiles.json \
gs://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/tiles.json
gsutil setmeta \
-h "Cache-Control:no-cache, max-age=0" \
gs://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/tiles.json
Vector Tile Reader Plugin
Now, head over to QGIS. Using the vector tile reader plugin, add a server connection pointing at the tiles.json file:
- https://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/tiles.json
Save the connection and click Connect. The layers available in the tileset are presented in the table. Select the hamilton_contours_50ft layer and click Add.
The vector tiles are added to the map as a new layer.
Esri ArcGIS Pro
To consume the vector tiles in ArcGIS Pro, almost all the pieces are in place. Because Pro expects to find styling at the root of .../VectorTileServer/resources/styles, we must add this file to GCS.
Place Default Style at Root
We will create a duplicate of .../resources/styles/root.json, already present and required by the ArcGIS JavaScript API. If GCS supported redirects or rewrites, we could easily redirect root.json -> index.json and it would make for a more elegant solution.
cp \
hamilton_contours_50ft/VectorTileServer/resources/styles/root.json \
hamilton_contours_50ft/VectorTileServer/resources/styles/index.json
gsutil cp \
hamilton_contours_50ft/VectorTileServer/resources/styles/index.json \
gs://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/VectorTileServer/resources/styles/index.json
gsutil setmeta \
-h "Cache-Control:no-cache, max-age=0" \
gs://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/VectorTileServer/resources/styles/index.json
Now the request to .../VectorTileServer/resources/styles successfully returns index.json because of the MainPageSuffix static website settings we made earlier.
Add Data from Path
Open a new map in Pro and select Add Data > Add Data From Path and enter the following service URL and click Add:
- https://geoaccelerators.woolpert.dev/tileservices/hamilton_contours_50ft/VectorTileServer
That's all there is to adding a GCS-based vector tile layer to Pro!
Pro does support simple pop-ups that pull content directly from the vector tiles, but we are still working on the reverse engineering of the process.
Comments
0 comments
Please sign in to leave a comment.