MapServer

Render maps from TileDB arrays stored on S3 using MapServer

MapServer is an open source platform for publishing spatial data and interactive mapping applications to the web. MapServer allows you to render data from TileDB arrays and combine other sources and formats such as GeoJSON to render cartographic quality maps.

Installation

You can run the MapServer and TileDB examples as follows;

docker run -it --rm -u 0 -v /local/path:/data tiledb/geospatial /bin/bash

MapServer configuration

We will use the following MapServer mapfile;

MAP
IMAGETYPE PNG
SIZE 400 300
EXTENT -77.8751 34.1472 -77.7869 34.267
CONFIG "TILEDB_CONFIG" "./aws.config"
PROJECTION
"init=epsg:4326"
END
WEB
METADATA
"wms_title" "TileDB tutorial"
"wms_onlineresource" "https://myhost/mapserv"
"wms_enable_request" "*"
END
END
LAYER
NAME "tiledb_coastal"
TYPE RASTER
DATA "s3://tiledb-mapserver/tiledb_mosaic"
CONNECTIONOPTIONS
"TILEDB_CONFIG" "aws.config"
END
OFFSITE 0 0 0
PROJECTION
"init=epsg:4326"
END
METADATA
"wms_title" "TileDB Sample 2017 NOAA NGS Ortho-rectified Oblique Imagery of the East Coast"
END
END # tiledb_coastal raster layer ends here
END # end of map file

And sample data from https://coast.noaa.gov/dataviewer/#/, in this case the 2017 NOAA NGS Ortho-rectified Oblique Imagery of the East Coast.

The use of CONNECTIONOPTIONS is in the MapServer 8.0 release.

The following GDAL commands are used to produce a single tiledb array from multiple sources.

gdalbuildvrt mosaic.vrt *.tif
gdal_translate -OF TILEDB -CO COMPRESSION=ZSTD -CO BLOCKXSIZE=1024 -CO BLOCKYSIZE=1024mosaic.vrt tiledb_mosaic

As in our TileDB and GDAL tutorials, we store the S3 credentials in an aws.config file. Note that this aws.config file should be stored in a location that is accessible by your web server but is not public.

To test rendering a map with MapServer we use the shp2img command;

shp2img -m tutorial.map -l tiledb_coastal -e -77.82 34.17 -77.80 34.20 -s 250 250 -o ~/Desktop/test.png -map_debug 3

We have tested this mapfile on an AWS m5a.2xlarge instance and successfully created a map from a query to a TileDB array stored on S3.

Rendered TileDB array from S3 using MapServer