leaflet-geotiff-2
leaflet-geotiff-2 copied to clipboard
Unable to change band number
Hi there. I'm running into a couple potential errors (could be on my end). I'm hoping you can help me understand what's going wrong. I have a local geotiff with 4 bands that I'm visualizing. 2 unexpected errors:
- When I change the band number (using the "band" option as an input to L.LeafletGeotiff), nothing changes.
- When I change the clampHigh option as an input to L.LeafletGeotiff.plotty, nothing changes. Specifically, all values higher than displayMax are left empty.
Here is my code if helpful:
JAVASCRIPT import "leaflet-geotiff-2"; import "leaflet-geotiff-2/dist/leaflet-geotiff-plotty"; var map = L.map('map').setView([38, -98], 5); var streetMap = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { attribution: 'Map data © OpenStreetMap contributors, Imagery © Mapbox', maxZoom: 18, id: 'mapbox/streets-v11', tileSize: 512, zoomOffset: -1, accessToken: '..........' }); streetMap.addTo(map); var renderer = L.LeafletGeotiff.plotty({displayMax: 15, colorScale: "viridis"}) var layer_options = {renderer: renderer, band: 3} //change band number here!! var layer = L.leafletGeotiff("./dist/imgs/test_sept.tif", layer_options).addTo(map);
HTML
I'm unable to attach a geotiff (although I can email it if helpful). Here is the converted png:
I've just started using this library, since it seems to plot GeoTIFF data nicely, but I've been having the exact same 2 problems. I've been using an 8 band TIF image: 8band.zip and am unable to plot anything but the first band. The maximum data value is around 158 if you want to try using the attached file (zipped, since github won't allow .tif attachments), but I am seeing the same missing data issue by setting the maximum data value to about 80, since that's what I'm interested in visualising.
For what it's worth, I can get the desired effect by setting layer.options.rBand
to the band I want to plot, and then calling layer.setBand()
(with no arguments, or in fact, any argument I want).
Looking at the code, I don't know why line 266 doesn't say something like:
this.raster.data = data[this.options.band]
but I presume that's to do with how you want RGB plotted images to behave.
I'm also unable to get the .getValueAtLatLng()
function to return anything but undefined
I also ran into this issue. I don't think the band
parameter is actually used. In setBand
all bands are put into a data
array but then values are taken using rBand
, gBand
and bBand
but when I have only 1 band in my tiff file only the rBand
will be defined?
If I change the options value for rBand
to select the band I want to show it seems to work fine. I using this for now as a workaround.