Mapbox along with GIBS NASA API

I have been exploring options on how to add NASA images over Mapbox backgrounds. In this search I have encountered an example in this github respository GIBS mapbox-gl-js example, however it only shows how to establish MODIS Terra True Color image as a background map such as those of Mapbox (e.g. open street maps). I am interested on plotting images such as Landsat products among others, which have a limit field of view with its correspondent coordinates delimiting the box of the taken imagem and put them as a layer over a mapbox map background. I have tested meanwhile the following code to plot just the MODIS Terra True Color image in the coordinates specified but it is not working

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Add a raster image to a map layer</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v3.4.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v3.4.0/mapbox-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
    mapboxgl.accessToken = 'pk.eyJ1IjoibWFmZWdvbnphbGV6IiwiYSI6ImNscnYyb3Z5MDBteGsya25hZWpmYTdsNzcifQ.3Rj3jRdf_iSTNOdT26iqUg';
    const map = new mapboxgl.Map({
        container: 'map',
        maxZoom: 5.99,
        minZoom: 4,
        zoom: 5,
        center: [-75.789, 41.874],
        // Choose from Mapbox's core styles, or make your own style with Mapbox Studio
        style: 'mapbox://styles/mapbox/dark-v11'
    });

    var tilePath = 'wmts/epsg3857/best/' +
    'MODIS_Terra_CorrectedReflectance_TrueColor/default/' +
    '2018-06-01/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg'

    map.on('load', () => {
        map.addSource('radar', {
            'type': 'image',
            'url': tilePath,
            'coordinates': [
                [-80.425, 46.437],
                [-71.516, 46.437],
                [-71.516, 37.936],
                [-80.425, 37.936]
            ]
        });
        map.addLayer({
            id: 'radar-layer',
            'type': 'raster',
            'source': 'radar',
            'paint': {
                'raster-fade-duration': 0
            }
        });
    });
</script>

</body>
</html>

Does someone knows how to this kind of plot? It would be of great help.

Thanks in advance!

Upvotes: 0

Views: 47

Answers (0)

Related Questions