sul-dlss / earthworks

Geospatial discovery application for Stanford University Libraries.
https://earthworks.stanford.edu
Other
21 stars 3 forks source link

Support "serverless" Cloud Optimized Geotiffs in EW #867

Open mapninja opened 2 years ago

mapninja commented 2 years ago

"As a researcher using drone acquired data at The Stanford Farm, I would like to deposit the data I create (orthophotography and digital elevation models), into the SDR, and make it available through Earthworks."

Cloud Optimized Geotiffs are quickly becoming the default archival and analysis-ready format for imagery-based geospatial data. A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing ​HTTP GET range requests to ask for just the parts of a file they need.

https://www.cogeo.org/

This work would support the addition of Cloud-optimized GeoTiffs, as a supported data deposit format for discovery in Earthworks. Scanned & Georeferenced Maps, Satellite & Drone Imagery, and any other pixel-based & georeferenced data can be deployed in this way. SDR is capable, at this point, of serving COGs without additional infrastructure.

This enhancement would also be a step toward future work to automatically harvest and archive imagery ordered through the Planet.com API by Stanford researchers (we have the right to re-download unmetered, and retain in perpetuity, any imagery accessed by Stanford researchers).

The work here, would be limited to geoblacklight/Earthworks work to recognize a COG record and enable Leaflet to display it on an item page.

This can be accomplished two ways, I think: Geoserver intervention (using Geoserver would require addition of the COG Plugin), so that external COG sources (in our case, SDR-based) can be "passed through" Geoserver to our existing Leaflet previews on items pages.

Or directly in the Leaflet Preview map, using the library highlighted in the example, below.

Here's a COG direct from SDR, in a leaflet map: https://web.stanford.edu/~maples/cog/leaflet_cog.html

Collection PURL: https://purl.stanford.edu/vq494qx9344

Stacks URL for COG in Map: https://stacks.stanford.edu/file/druid:vq494qx9344/odm_orthophoto_COG_d.tif

Using: https://github.com/GeoTIFF/georaster-layer-for-leaflet

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"/>
    <style>
      #map {
        bottom: 0;
        left: 0;
        position: absolute;
        right: 0;
        top: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
    <script src="https://unpkg.com/proj4"></script>
    <script src="https://unpkg.com/georaster"></script>
    <script src="https://unpkg.com/georaster-layer-for-leaflet"></script>
    <script>
      // initalize leaflet map
      var map = L.map('map').setView([37.42663274227526,-122.18297839164735], 19);

      // add OpenStreetMap basemap
      L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
          attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
      }).addTo(map);

      var url_to_geotiff_file = "https://stacks.stanford.edu/file/druid%3Avq494qx9344/odm_orthophoto_COG_d.tif";

      parseGeoraster(url_to_geotiff_file).then(georaster => {
        console.log("georaster:", georaster);

        /*
            GeoRasterLayer is an extension of GridLayer,
            which means can use GridLayer options like opacity.
            Just make sure to include the georaster option!
            http://leafletjs.com/reference-1.2.0.html#gridlayer
        */
        var layer = new GeoRasterLayer({
            attribution: "Planet",
            georaster: georaster,
            resolution: 128
        });
        layer.addTo(map);

        map.fitBounds(layer.getBounds());

    });

    </script>
  </body>
</html>
mapninja commented 2 years ago

Complication for both approaches, above, is that Stacks URLs are apparently not guaranteed to be stable.

thatbudakguy commented 1 year ago

blocked while we figure out how to best serve this content.