Search code examples
htmlamazon-s3mapboxmapbox-gl-jsmapbox-gl

How to use AWS S3 raster file in Mapbox gl js?


Mapping a Cloud Optimized Geotiff raster layer in Mapbox GL JS

I think I use a raster source, the source data need to be tiled. the URL would be like .../{z}/{x}/{y}.tif.

But I don't know how to make above URL. how to make url??


Solution

  • I'm not exactly sure what you're asking. If you're asking "how do I turn this GeoTIFF into a tiled raster source", two options are:

    1. Upload it to Mapbox. (In theory this works, although it has not always been successful for me.)
    2. Use GDAL to convert it to mbtiles, then host the .mbtiles file somewhere (either on Mapbox, CloudTiler, or your own hosting.)

    In the latter case, that would look like:

    gdal_translate myfile.tif mytiles.mbtiles