Public
Edited
Jun 23, 2024
Insert cell
Insert cell
Insert cell
old_geoblaze = require("geoblaze@2.6.1")
Insert cell
new_geoblaze = require("geoblaze@latest")
Insert cell
// GPM IMERG 1-Day Accumulated Precipitation Raster originally from
// https://pmmpublisher.pps.eosdis.nasa.gov/products/s3/r01/gpm_1d/2024/169/gpm_1d.20240617.tif
georaster = new_geoblaze.load("https://raw.githubusercontent.com/GeoTIFF/test-data/main/files/gpm_1d.20240617.tif")
Insert cell
GeoRasterLayer = require("georaster-layer-for-leaflet")
Insert cell
// a very small rectangle in the Gulf of Mexico
aoi = ({
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-92.525603, 23.776023],
[-92.525603, 23.790637],
[-92.511239, 23.790637],
[-92.511239, 23.776023],
[-92.525603, 23.776023 ]
]
]
}
})
Insert cell
html`<link href='${resolve('leaflet@1.2.0/dist/leaflet.css')}' rel='stylesheet' />`
Insert cell
L = require('leaflet@1.9.4')
Insert cell
container = html`<div style="height:600px;">`
Insert cell
map = L.map(container)
Insert cell
{
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "&copy; <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);
const georasterLayer = new GeoRasterLayer({
georaster
}).addTo(map);
const aoiLayer = L.geoJson(aoi).addTo(map);
map.fitBounds(aoiLayer.getBounds());
map.setZoom(10);
yield map;
}
Insert cell
// the older version of geoblaze doesn't do virtual resampling, so it thinks there's no intersecting pixels, because the AOI isn't large enough (technically speaking, doesn't intersect the middle half of a pixel's horizontal centerline)
old_geoblaze.stats(georaster, aoi)[0]
Insert cell
// running the newer version of geoblaze with the virtual resampling multiplier set to "minimal" means the original pixels are virtually divided enough times to make sure at least one subpixel interesects the AOI. Specifically in this case, each pixel is virtually divided into 196 smaller subpixels and 4 of these subpixels intersect the AOI)
new_geoblaze.stats(georaster, aoi, undefined, undefined, { vrm: "minimal" })[0]
Insert cell
// the older version of geoblaze doesn't do virtual resampling, so it doesn't find any intersecting pixels
old_geoblaze.median(georaster, aoi)
Insert cell
// the newer version of geoblaze automatically applies virtual resampling when calling geoblaze.min, geoblaze.max, geoblaze.mean, geoblaze.median, geoblaze.mode, or geoblaze.sum
new_geoblaze.median(georaster, aoi)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more