Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change band number #31

Open
billybabis opened this issue Nov 11, 2021 · 2 comments
Open

Unable to change band number #31

billybabis opened this issue Nov 11, 2021 · 2 comments

Comments

@billybabis
Copy link

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:

  1. When I change the band number (using the "band" option as an input to L.LeafletGeotiff), nothing changes.
  2. 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

<style> body { padding: 0; margin: 0; } html, body, #map { height: 100%; width: 100%; } </style>
<script src="node_modules/leaflet/dist/leaflet.js"></script> <script src="node_modules/geotiff/dist-browser/geotiff.js"></script> <script src="node_modules/plotty/dist/plotty.js"></script> <script src="./dist/main.js"></script>

I'm unable to attach a geotiff (although I can email it if helpful). Here is the converted png:
test_sept

@guygriffiths
Copy link

guygriffiths commented Nov 23, 2021

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

@eelcocramer
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants