Git Product home page Git Product logo

geotiff / georaster-layer-for-leaflet Goto Github PK

View Code? Open in Web Editor NEW
283.0 10.0 57.0 1.42 MB

Display GeoTIFFs and soon other types of raster on your Leaflet Map

Home Page: https://geotiff.github.io/georaster-layer-for-leaflet-example/

License: Apache License 2.0

JavaScript 0.83% HTML 72.68% Shell 1.11% TypeScript 24.75% Vue 0.63%
leaflet leaflet-map raster georaster geotiff satellite satellite-imagery gis geo geospatial geospatial-visualization webgis

georaster-layer-for-leaflet's Introduction

πŸ‡ΊπŸ‡¦ "Leaflet was created 11 years ago by Vladimir Agafonkin, an Ukrainian citizen living in Kyiv." - (LeafletJS)


georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of rasters on your Leaflet Map

Install

npm install georaster-layer-for-leaflet

GeoRaster Prerequisite

GeoRasterLayer requires that input be first converted into GeoRaster format. You can install GeoRaster with the following command:

npm install georaster

Load Package via Script Tag

<script src="https://unpkg.com/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.min.js"></script>

Usage

new GeoRasterLayer({ georaster }).addTo(map);

Demos

Why

  • Support for nearly all projections, thanks to proj4-fully-loaded and epsg.io
  • Super faster rendering thanks to a simple nearest neighbor interpolation
  • Use of web workers means seamless integration that doesn't block main thread
  • Loads large geotiffs greater than a hundred megabytes
  • Supports custom rendering including custom colors, directional arrows, and context drawing
  • Doesn't depend on WebGL
  • Mask data inside or outside a given geometry

The GeoRasterLayer Class

A custom class for rendering GeoTIFF's (including COG's) on a leaflet map. The layer extends L.GridLayer, see the docs for inherited options and methods.

Usage Example

Source Code: https://github.com/GeoTIFF/georaster-layer-for-leaflet-example/blob/master/main.js

var parse_georaster = require("georaster");

var GeoRasterLayer = require("georaster-layer-for-leaflet");
// or: import GeoRasterLayer from "georaster-layer-for-leaflet";

// initalize leaflet map
var map = L.map('map').setView([0, 0], 5);

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

var url_to_geotiff_file = "example_4326.tif";

fetch(url_to_geotiff_file)
  .then(response => response.arrayBuffer())
  .then(arrayBuffer => {
    parseGeoraster(arrayBuffer).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!

          Optionally set the pixelValuesToColorFn function option to customize
          how values for a pixel are translated to a color.

          https://leafletjs.com/reference.html#gridlayer
      */
      var layer = new GeoRasterLayer({
          georaster: georaster,
          opacity: 0.7,
          pixelValuesToColorFn: values => values[0] === 42 ? '#ffffff' : '#000000',
          resolution: 64 // optional parameter for adjusting display resolution
      });
      layer.addTo(map);

      map.fitBounds(layer.getBounds());

  });
});

Options for GeoRasterLayer

The layer extends L.GridLayer, see the docs for inherited options and methods.

Option Type Default Description
georaster GeoRaster Use georaster from georaster-library. georaster or georasters is required.
georasters GeoRaster[] Use different georasters from georaster-library. georaster or georasters is required.
resolution number 32 The resolution parameter is how many samples to take across and down from a dataset for each map tile. Typical tiles are 256 x 256 pixels (higher resolution are 512 x 512) which would be a optimal resolution of 256. It's not recommended to set the resolution higher then 512.
debugLevel number 0 Available debug levels: 0 - 5
pixelValuesToColorFn (values: number[]) => string null Customize how values for a pixel are translated to a color.
bounds LatLngBounds null https://leafletjs.com/reference.html#latlngbounds
proj4 Function https://github.com/proj4js/proj4js
resampleMethod string nearest bilinear | nearest
mask string | Feature | FeatureCollection | Polygon | MultiPolygon null You can hide all the pixels either inside or outside a given mask geometry. You can provide a JSON object as a mask geometry or a URL to a GeoJSON.
mask_srs string | number "EPSG:4326" Default mask srs is the EPSG:4326 projection used by GeoJSON
mask_strategy string outside inside | outside
updateWhenIdle boolean true https://leafletjs.com/reference.html#gridlayer-updatewhenidle
updateWhenZooming boolean false https://leafletjs.com/reference.html#gridlayer-updatewhenzooming
keepBuffer number 25 https://leafletjs.com/reference.html#gridlayer-keepbuffer

Methods

Method Returns Description
getBounds() LatLngBounds Returns the bounds of the layer
getMap() Map Returns the map which contains the layer
getMapCRS() CRS Returns map CRS if available else EPSG3857
getColor(values: number[]) string | undefined Returns the colors of the values
updateColors(pixelValuesToColorFn, options = { debugLevel: -1 }) this Causes the tiles to redraw without clearing them first. It uses the updated pixelValuesToColorFn function. You can set a debugLevel specific to this function by passing in an options object with a debugLevel property. For example, you can turn on the console debugs for this method by setting debugLevel = 1 in the options (even if you created the layer with debugLevel = 0).
getTiles() Tile[] Returns tiles as array
getActiveTiles() Tile[] Returns active / visible tiles as array
isSupportedProjection() boolean Returns if the projection is supported
getProjectionString(projection: number) string Returns the projection string for example "EPSG:3857"
getProjector() Projection Returns the current projection

Advanced Capabilities

Please read about our advanced capabilities including custom context drawing functions, displaying directional arrows, and masking in ADVANCED.md.

More Questions

Check out our Frequently Asked Questions

Videos

Support

Contact the package author, Daniel J. Dufour, at [email protected]

georaster-layer-for-leaflet's People

Contributors

aviklai avatar carlqlange avatar danieljdufour avatar falke-design avatar gabiaxel avatar iamtekson avatar jcphill avatar jellyspoon avatar jomey avatar m-mohr avatar rennzie avatar rowanwins avatar tanrax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

georaster-layer-for-leaflet's Issues

Turn off Logging in Production

Describe the bug
A clear and concise description of what the bug is.
Users see console.log ing when using in production

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://geotiff.github.io/georaster-layer-for-leaflet-example/

Expected behavior
A clear and concise description of what you expected to happen.
No logging unless there's issues

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

enable injection of proj4

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Question: Original band data types

Hello, it's once again question time! I would like to be able to display the raster's original data types for each band for users. For example, being able to know for sure that in band X, number A is an integer and number B is floating point. JavaScript converts everything to number, which I'm sure you know, and it doesn't help if the original data type was uint16, float32, etc.

Is there a way to determine this already in the georaster object somewhere that I've missed?

Interpolate Missing No Data Values on the Fly

Describe the bug
Sometimes GeoTIFFs might have random no data values because of random satellite sensor issues. It would be awesome if this library could automatically interpolate or fill these holes in on the fly dynamically.

Note
Sometimes elevation rasters have similar issues where there are bad anomalous readings. They aren't technically labeled as no-data, but really should be.

Add Documentation of Resolution Parameter

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Users might not realize that this library can display in high-resolution

Describe the solution you'd like
A clear and concise description of what you want to happen.
Add separate section to Readme.md about adjusting resolution. Also update example.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Delete multi Layer

I able to add multi layer based on dynamic url. May I know how to remove layer by id or name (once more than 1 layer).

var url_to_geotiff_fileaaa = "http://localhost:8086/leafletContent/tif/Abc1.tif";

        fetch(url_to_geotiff_fileaaa)
            .then(function (response) { return response.arrayBuffer(); })
            .then(function (arrayBuffer) {
                parseGeoraster(arrayBuffer).then(function (georaster) {
                    layerB = new GeoRasterLayer({
                        georaster: georaster,
                        resolution: 256
                    });
                    layerB.addTo(map);
                    map.fitBounds(layerB.getBounds());
                });
            });

L is not defined when using georaster-layer-for-leaflet

Hello! Thanks for making this, it has come in handy for me lately! I have a question for you to see if you can clarify a rather
bizarre issue I've been having recently with this package.

I'm working in Angular 9, which I'm not sure is important or not, but I'm running out of ideas of what is at this point. Long story
short, when I'm running ng serve with a local server, everything is running smoothly. I can view my raster on the Leaflet
map just fine. When running ng build - which creates a production build of the app and puts it in its own dist/ folder - I can
run a simple server and everything is good to go as well.

The problem is when I try to push the project up to AWS. The project doesn't even finish loading, and I get the above mentioned
Uncaught ReferenceError: L is not defined. You can use this link to check out the page (which is all gray) and upon console inspection it gives the error line in the georaster-layer-for-leaflet.bundle.js. The line in question is:

var GeoRasterLayer = L.GridLayer.extend({

Do you have any idea why L wouldn't be defined here, but is defined when run in other environments? The app doesn't create
the raster layer on creation, so I'm confused to be getting an error at this point. You as the user would need to click on a menu button to do that. You can see how it should work here.

Sorry for the longer post; I've just run into a wall head first and thought I'd ask your thoughts on this! Let me know if anything
above wasn't clear. Thanks!

Support Cloud Optimized GeoTIFFs

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Users want to display large COGs, but don't want to have to download the whole thing in order to visualize it.

Describe the solution you'd like
A clear and concise description of what you want to happen.

  1. Add COG support to https://github.com/GeoTIFF/georaster by using https://github.com/geotiffjs/geotiff.js (This is being tracked in a separate issue here)
  2. Use new version of georaster developed in (1) and update code in georaster-layer-for-leaflet.js to dynamically get values from GeoRaster rather than getting them all when layer is initialized

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Not sure, but open to solutions :-)

Additional context
Add any other context or screenshots about the feature request here.

I don't understand how pixelValuesToColorFn works

Hi, thanks a lot for your work!

I'm new to JS and not sure how to properly use the GeoRasterLayer's pixelValuesToColorFn option.

I want to display transparent zones where the values equal -99.0 in my GeoTIFF file, else the original color.

I wrote that:

pixelValuesToColorFn: values => values[0] === -99.0 ? null : '#000000",

But obviously everything is black where the value !== 99.0.

Could someone give me some hints?

Problems with loading of Cloud Optimized Geotiff

Hi,

first thanks for this great project.

When trying to load the attached COG file I get an error message (in Firefox Web Console):
Uncaught (in promise) Error: No image at index 7
ke https://unpkg.com/georaster:8
requestIFD/this.ifdRequests[e]< https://unpkg.com/georaster:8
georaster:8:133786
asyncGeneratorStep https://unpkg.com/georaster-layer-for-leaflet/georaster-layer-for-leaflet.browserify.min.js:14
_throw https://unpkg.com/georaster-layer-for-leaflet/georaster-layer-for-leaflet.browserify.min.js:16

This seems to be a problem with the overviews, because the index changes when the image has different overview levels.
Also it is not showing the complete image. This only happens if I directly open the image, not if I first fetch it (commented in the Example).

Another problem not related to this, is that I'd like to use a pixelValuesToColorFunction based on the min/max values of the GeoTiff, but those values are unavailable after opening directly. Is there a way to load them or at least get the min max values of the current view before rendering? Or do I need to write my own rendering function instead?

Thanks in advance,

Christian Lampe

_Example.zip
_20m_Jeddah_WGS84_COG_0_01deg.zip

Single value array support

Hi!

Mega suit of geotiff packages - really helpful, nice code to work with!

I've got a GeoTIFF that has single values, not RGB bands. It looks like you're expecting this line

return this.georaster.getValues(getValuesOptions);

to return an array of an array of pixel values so [Unit32Array,Unit32Array,Unit32Array] or whatever - but I end up with just a single array - Unit32Array (not wrapped in an array).

SO this line:

values = tileRasters.map(raster => raster[h][w]);

maps over the height coordinates and I end up with a load of undefined values.

I think it might come from: https://github.com/geotiffjs/geotiff.js/blob/e31dfcc61dff03af5ac9209ad7a9b460c07acfc2/src/geotiffimage.js#L441

But I'm really not sure - I think if interleave is set, it's not an array of values, if that makes sense? But I could be wrong here! I've just looked, haven't ran it or inspected.

I've solved for me:

if (tileRasters.length === numberOfSamplesDown) { values = [tileRasters[h][w]]; } else { // get value from array specific to this tile values = tileRasters.map(raster => raster[h][w]); }

here:

but this obviously falls down when the height of the tile is the number of bands. (So no PR).

I'm not sure if this problem should be fixed in this library or geotiff library. (My gut probably learns towards a standard return value from the GeoTiff library (so wrapping the array in an array), but that might break the API for others?).

To Reproduce
I've got a GeoTIFF file in S3:
https://tiff-library.s3.eu-west-2.amazonaws.com/ethiopia/flood-maps/maxDepth1yr-cogeo.tiff

Or you can try and open it in the COG-Explorer (and see the network request to undefined
https://geotiffjs.github.io/cog-explorer/#long=45.142&lat=9.136&zoom=13&scene=https://tiff-library.s3.eu-west-2.amazonaws.com/ethiopia/flood-maps/maxDepth1yr-cogeo.tiff&bands=0,1,2&pipeline=

Thanks again for the library, hope this helps. It's been really useful. Let me know if I can help/provide more info.

Cheers
S

Proposal: custom value to color function

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.

Add GeoJSON Mask Option

new GeoRasterLayer({
    georaster,
    bounds: geojson
})

This would mean only display within the bounds.

Question: What does resolution mean for the Raster layer?

Hello again! You previously helped me with Issue #40 back in July, which allowed me to put out the first couple maps with raster information. Now I just have a question about what exactly the resolution option for a raster means. I tried looking into the code but couldn't discern it myself. The reason I ask is that some of the layers we display are meant to have 1 cell in the layer represent 40 acres (or something similar) on the Leaflet map, but depending on the resolution, those can look very blocky from far away.

Increasing the resolution will help with that obviously, but what does it mean? Is it just arbitrarily increasing resolution for the layer when changed from 32 to 64 for example, or is the resolution tied to something specific? Such as, if I wanted to show a cell as being 40 acres, would resolution be set to 40? I figure that's not how it works, but I hope you get my question.

Also, if a raster layer's opacity is less than one, you can see horizontal and/or vertical lines on the layer. I'm not sure if these are also arbitrary, or if they mean something, as they sometimes are differently spaced apart. For an example of this, the Colorado Counties map contains a raster layer where this occurs. Zooming into the map until at least zoom level 12.5 or more will show the lines.

Just out of curiosity, what is the highest resolution that a raster can be set to? I've seen some examples that use 512.

Thank you again for taking time out of your busy schedule to look into this! I'm still grateful to be able to use this awesome tool that allows us to create and show some pretty cool information.

Question: loading minimal data from image with internal overviews

My goal is to load the minimal amount of data from a COG with internal overviews. Is this possible or do I need to be using external overviews?

I want to either load the entire image (using the internal overviews ex: 500x500) or load the actual data when far zoomed in. Any breadcrumbs to help me with this or best practices advice would be appreciated. Thanks!

Colored tif rendered in bn

Not sure if is a bug, this is my first time I work with geotiff
I'm trying your example with a colored tif I should work with but It appear on the map in black and white...is there something I'm missing?
image

Unable to display big Geotiff data

Describe the bug
When trying to use some GeoTif coming from this site https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/ifr/
I'm unable to display them in leaflet. Firstly the library is processing the image for few minutes on web worker, then I'm getting info that basically it was processed successfully however layer is empty.

To Reproduce
Steps to reproduce the behavior:

  1. Download any geotif from https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/ifr/
  2. Use example code from readme with this file
  3. After few minutes of processing, there will be nothing to show on the map

Is it connected with the size of the image? I wanted to scaled it down to see if that's the issue, however I don't have a software which preserves embeded tags of geotiff, so after such procedure the format is corrupted (tried gimp/krita/photoshop)

When using some small geotiff like this ones https://github.com/stuartmatthews/stuartmatthews.github.io/tree/master/leaflet-geotiff/tif

everything is working as expected, so I don't think it's something on my side of code

Extra props passed to custom draw function

Hi again!

I'm using the library to render a DEM so my raster values represent altitude at each point.

I'm adding hill shading to a layer. So, I hook into the customDrawFunction - except I don't get access to the entire raster here and I need the surrounding pixels to determine slop angle and aspect

this.options.customDrawFunction({ values, context, x, y, width, height });

Describe the solution you'd like
Would be great if you could also pass the w + h variables, along with the raster being rendered to the customDrawFunction

References:
https://observablehq.com/@sahilchinoy/hillshader

As before, I've solved for me - but I guess this could be useful to others!

I'd be happy to open a PR if you think the extra props is sensible.....
I could see people misusing it and calculating min/max values for the entire raster every time a pixel is drawn, but you can't protect everyone!

Thanks again :)
S

Default global debugLevel to 0 in production

When in production its a good idea to silence the debug level by default as the extra console logs would degrade performance and obscures other logging (errors etc). By having a good default setup it improves the DX of the lib.

Add a const isProduction = process.env.NODE_ENV === 'production' to the top of georaster-layer-for-leaflet.js and then default the global debugLevel depending on it: if (!("debugLevel" in options)) options.debugLevel = isProduction ? 0 : 1;

Setting custom color scheme

Hi, thank you are this library.
I would like to color code a raster layer based on specific colors assigned to specific value.
with the pixelValuesToColorFn I can add it by hardcoding the ranges as I have seen being done on this forum But I would like to calculate the ranges of colors before hand then use then render it.

Describe the solution you'd like
For the solution I was thinking how to adopt something similar to plotty's add color scale
plotty.addColorScale("mycolorscale", ["#00ff00", "#0000ff", "#ff0000"], [0, 0.5, 1]);

where One can have an array of colors and an array of values

Describe alternatives you've considered
For the alternatives, I have tried leaflet-geotiff but it is not as fast as this library while rendering my geotiffs. With leaflet-geotiff, I can easily access plotty and customize how the colors are added with functions already built in to clamp values that are out of range to get a nice coloring withing the bounds of the raster and not the rectangle

kindly advice on how to achieve this using this library because I know it is possible I am limited by my knowledge of the
pixelValuesToColorFn and customDrawFunction

Errors loading tiff files

Describe the bug
I'm trying to use this library to display some tiff files on my application but some errors are being thrown when loading some specific files. I'm not sure if this is a bug with the lib itself but maybe you can give me some insights about the issues. The code I used is mostly the same as in the georaster-layer-for-leaflet-example repository I even forked it to host the tiff files I mentioned, if you want to check it: https://github.com/fernandomantoan/georaster-layer-for-leaflet-example, the files are ndvi_contrast_Field_4960_2020-01-24.tiff, ndvi_contrast_FieldGroup_1_2020-02-10.tiff, visual_FieldGroup_1_2020-02-10.tiff, exemplotiff.tif. The only difference is that I had to add the proj4 library.

Some Logs:

Uncaught (in promise) RangeError: Invalid typed array length: 528
georaster projection is 32621
bundle.js:3156 georaster projection is UTM
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '131' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
(anonymous) @ bundle.js:3051
_loop2 @ bundle.js:3050
(anonymous) @ bundle.js:3087
_loop @ bundle.js:3091
(anonymous) @ bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '78' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
(anonymous) @ bundle.js:3051
_loop2 @ bundle.js:3050
(anonymous) @ bundle.js:3087
_loop @ bundle.js:3091
(anonymous) @ bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '5' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
(anonymous) @ bundle.js:3051
_loop2 @ bundle.js:3050
(anonymous) @ bundle.js:3087
_loop @ bundle.js:3091
(anonymous) @ bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '133' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '22' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '130' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '126' of undefined
    at bundle.js:3051
    at Array.map (<anonymous>)
    at _loop2 (bundle.js:3050)
    at bundle.js:3087
    at _loop (bundle.js:3091)
    at bundle.js:3098
bundle.js:3051 Uncaught (in promise) TypeError: Cannot read property '4' of undefined

It's important to note that when I use the tiff files provided from your original repo everything works fine.

I also tried uploading my files to http://app.geotiff.io/load and the errors are also being thrown there.

To Reproduce
Steps to reproduce the behavior:

  1. Download any of the aforementioned tiff files
  2. Change main.js to point to the tiff file
  3. Build
  4. Run in browser (I used apache)

Expected behavior
The tiff files should be presented.

Screenshots
Each screenshot is a different tiff file.

screen1
screen2
screen3

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 80

ReferenceError: Can't find variable: proj4

Hello!
I am a beginner using this for my project. I got the following error in console not sure what it means...please tell me how I should go about debugging.
I'm using macOS Mojave and safari.

image

The error directs to this portion of the code in : georaster-layer-for-leaflet.browserify.min.js

image

Add an updateColours method to allow for smooth colour updates of MS images.

Is your feature request related to a problem? Please describe.
Its frustrating that I need to invoke georaster.redraw() to update the colour of my multi-spectral map. It removes all tiles before redrawing showing a flash of blank screen before the image is updated.

Describe the solution you'd like
Add an updateColours method that takes an updated pixelValuesToColorFn. This method should recolour the pixels with the new function.

Describe alternatives you've considered
An alternative is to use the redraw() method of L.GridLayer however this is sub-optimal as describe above.

Additional context
The motivation for such a feature is for setting dynamic thresholds on multi-spectral images. This will allow use cases where a user need to highlight certain parts of an image. In our case we use a historgram with range-sliders to set the thresholds on an NDVI map.

I'd be more than happy to put together a PR if there is interest for this feature. We are hoping to begin making use of COG's and this feature would be critical for it's success.

Screen.Recording.2020-12-21.at.14.26.14.mov

Add ESLint Linter

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
There are naming inconsistencies between snake case and camel case, i.e. no_data_value versus noDataValue.

Describe the solution you'd like
A clear and concise description of what you want to happen.
Add in ESLint like we did for GeoRaster: https://github.com/GeoTIFF/georaster/blob/master/package.json#L7

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Not sure.

Additional context
Add any other context or screenshots about the feature request here.
image

Easily ID Layer Type

Would like an easy way to easily determine if something is a GeoRaster Layer

Maybe edit the lyr.name or lyr.constructor.name to be GeoRasterLayer?
Or add a type like lyr.type === GeoRasterLayer?

Strange gridlines for specific pixelValuesToColorFn

Hi Daniel and thanks for this amazing plugin!
I run into a strange problem.
I render a geotiff, and when picking this pixelValuesToColorFn:

              pixelValuesToColorFn: values => values[0] === -32768 ? null :
                            (values[0] > -70                    ) ? '#607c3c' :
                            (values[0] > -90  && values[0] <= -70) ? '#809c13' :
                            (values[0] > -100 && values[0] <= -90) ? '#abc32f' :
                            (values[0] > -115 && values[0] <= -100) ? '#b5e550' :
                            (                    values[0] <= -115) ? '#ececa3' :
                            null

everything works perfect:
image

But with this function that messes with the alpha value:

              pixelValuesToColorFn: values => values[0] === -32768 ? null :
                          (values[0] > -140  && values[0] <= -65) ?  `rgba(255, 0, 0, ${((values[0]+60)/80+1).toFixed(2)})` :
                          (values[0] < -140  ) ?  `rgba(255, 0, 0, 0)` :
                          (values[0] > -65  ) ?  `rgba(255, 0, 0, 1)` :
                          null

some red grid lines appear in zoom levels >=12
image

when I zoom out, the lines disappear
image

The problem appears both on latest Chrome and Firefox, Leaflet 1.6

here is the tiff file I'm using
sample.zip

Any idea on why this is happening??
Thanks in advance!

Serialization of a layer

Is your feature request related to a problem? Please describe.
Not a problem - more a request for assistance/feature.

I'm reading quite heavy files from disk (GB++) and i want to save the rendered raster layer on disk for use next time the user wants to view it. I simply save the result from new geoRasterLayer() as a JSON; JSON.stringify(layer). When it's time to read the file from disk i can't seem to assemble the layer from the object created from the previously saved raster layer.

Describe the solution you'd like
I would like the possibility to do this:

// first time this TIFF is used
let layer = new geoRasterLayer(options);
geoRasterLayer.writeLayerToDisk(path, layer);

// next time this layer will be used (hours or days later)
let layer = geoRasterLayer.readLayerFromDisk(path);
this.map.addLayer(layer);

I can see that this approach might be beyond the scope of this package; so the next best solution would be to create a new layer from a simple object that was previously written to file in JSON;

// first time this TIFF is used
let layer = new geoRasterLayer(options);
fs.writeFile(JSON.stringify(path), layer);

// next time this layer will be used (hours or days later)
let cachedLayer = JSON.parse(fs.readFile(path));
let layer = new geoRasterLayer(cachedLayer);
this.map.addLayer(layer);

Describe alternatives you've considered
I have tried the second approach but i get errors like:
"The provided object is not a Layer."
"You must initialize a GeoRasterLayer with a georaster or georasters value"

Dependencies missing

Describe the bug
If I do npm install this package, it doesn't install georaster package, but examples use it. The documentation doesn't say whether users should install it their self. I'd say it should be part of the dependencies in package.json or mentioned to be installed by users.

Implement TypeScript

Is your feature request related to a problem? Please describe.

  • Developers using TypeScript would like more support (Intellisense, type-checking etc.)

Describe the solution you'd like

  • Create a georaster-layer-for-leaflet.ts file that is basically georaster-layer-for-leaflet.js but in typescript

Describe alternatives you've considered

  • using types file

Additional context

  • Please preserve the current build scripts, but basically add the ts-to-js conversion as a pre-processing step. This way users who want to import that unbuilt pure-JS file can continue to do so.
  • @Rennzie

Get valueson click

Thank you for this leaflet plug-in!
It seems very promising and it could indeed smooth the process for prototyping map with raster by avoiding the need of a specific server.

I have more a question than a bug to report. From my understanding, the Plug-In rely on Leaflet GridLayer and it seems that it does not allow to access on click to the underlying tile values (in the present case, the rater values). Is it indeed true or is there an easy path for retrieving those values?
Thanks in advance,
Pierre

IE 11 Support?

Hi @DanielJDufour , is there a way to make this work on Internet Explorer 11? That would be great!
Most of the problems I'm facing seem related to unsupported sintax.

Raster WorldCopy

Amazing library @DanielJDufour! Is there a way to copy the raster data over to all "copies" of the map? For example, if the user pans the map past -180 or 180 longitude (see screenshot). Thank you!

Screen Shot 2020-06-21 at 6 55 57 PM

parse_georaster is not defined

I think this may be a very basic issue but I'm struggling to get this working. I'm working with plain JS.

I add the package via script tag:
<script src="https://unpkg.com/georaster-layer-for-leaflet/georaster-layer-for-leaflet.browserify.min.js"></script>

Georaster is also included. I copied the example code and got this error with the first two "require" lines:
ReferenceError: require is not defined

So... I checked require.js and downloaded it, but got another error derived of loading the script two times, once in HTML and once in JS. I got rid of the requires and now I have parse_georaster not defined because... it isn't defined, obviously, but how can I get this working? I'm a bit lost...

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.