Skip to content

Publish as vector tiles format alongside Geo/TopoJSON #106

Open
@nickpeihl

Description

@nickpeihl

With the introduction of feature-state in the Kibana Maps app, we can consider publishing our vector layers as file-based vector tiles. This would allow us to produce much higher resolution datasets than is currently possible with GeoJSON and TopoJSON.

For example, the USA Zip Codes layer currently served as TopoJSON is dramatically simplified to reduce the file size for web map consumption. Compare the following screenshots of zip codes near New York City.

Simplified TopoJSON at zoom 10
zcta_topojson

Full resolution shapefile at zoom 10
zcta_shp

We could theoretically publish zip codes as a directory tree of vector tiles and maintain nearly the same resolution of the shapefile.

Vector Tiles at zoom 10
zcta_mvt

Full resolution shapefile at zoom 10
zcta_shp

GIS files can be converted into vector tiles using the Tippecanoe tool.

  1. Download and extract the US Census ZCTA shapefile from ftp://ftp2.census.gov/geo/tiger/TIGER2018/ZCTA5/tl_2018_us_zcta510.zip
  2. Convert the shapefile into line delimited GeoJSON using gdal.
    ogr2ogr -f GeoJSONSeq -lco RS=YES -lco ID_FIELD=ZCTA5CE10 -sql "SELECT ZCTA5CE10 as zip FROM tl_2018_us_zcta510" zcta.geojsons ~/Downloads/tl_2018_us_zcta510/tl_2018_us_zcta510.shp
  3. Use tippecanoe to generate a directory of vector tiles from the GeoJSON file. This may take a while.
    tippecanoe --read-parallel --detect-shared-borders -S10 -zg -e usa_zip_codes --coalesce-densest-as-needed --no-tile-compression --generate-ids zcta.geojsons

The result vector tiles directory contains nested subdirectories for the {z}, {x}, and {y} tiles. So they can be stored and served using the same cloud storage we use for the other vector files (e.g. https://vector.maps.elastic.co/data/<layer_name>/{z}/{x}/{y}.pbf). And the vector tiles can be styled the same way we style GeoJSON or TopoJSON datasets.

In addition to higher resolution datasets, the vector tiles passed to the client can be much smaller than the GeoJSON and TopoJSON formats. Also, the Maps app in Kibana has native support for vector tiles which means the data is rendered much more quickly.

The Region Maps and Vega Maps in Kibana do not support vector tiles, so we would still maintain support for those visualizations by publishing simplified GeoJSON or TopoJSON datasets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions