GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
286 stars 57 forks source link

Proposal: custom value to color function #3

Closed GabiAxel closed 5 years ago

GabiAxel commented 5 years ago

Greetings. I had a usecase in which I needed to show specific colors for specific pixel values in a GeoTIFF. I resolved it by modifying https://github.com/GeoTIFF/georaster-layer-for-leaflet/blob/master/georaster-layer-for-leaflet.js#L149 so that it would accept a function option that does this translation, something like this:

if(this.options.colorFn) {
  color = this.options.colorFn(values[0])
} else {
  // previous behavior
}

In my case it was always a single value and nothing else (such as min or range) mattered, but maybe for a generic case the function should be able to receive more parameters.

DanielJDufour commented 5 years ago

Awesome. I love this idea! Would you like to submit a pull request? I can also take your code and make the PR myself. Whatever works for you :-)

GabiAxel commented 5 years ago

Thanks. Submitted #4

DanielJDufour commented 5 years ago

FYI: I republished with your commit: https://www.npmjs.com/package/georaster-layer-for-leaflet

Closing this issue now. Thanks again!