GeoTIFF/georaster-layer-for-leaflet

Trying to import georaster-layer-for-leaflet makes my software crash

revitalpresman opened this issue · 5 comments

I'm trying to use "georaster-layer-for-leaflet" in my react application,
I'm importing this way:

import { GeoRasterLayer } from "georaster-layer-for-leaflet";

and my program is crashing and I get this error:
"FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory".

Screenshots
image

can you please make a manual on how to use this package in react?

I had a similar issue starting out with this package today where the tab freezes and crashes, but got it working after downgrading to georaster-layer-for-leaflet@3.5.0! Give that a try and hopefully we can help identify an issue introduced since 3.5.0.

My usage looks like this:

import React, { useEffect } from 'react';
import parseGeoraster from 'georaster';
import GeoRasterLayer, { GeoRaster } from 'georaster-layer-for-leaflet';
import { useMap } from 'react-leaflet';

export default ({ url }: { url: string }) => {
  const map = useMap();
  const layerRef = React.useRef(null);

  useEffect(() => {
    parseGeoraster(url).then((georaster: GeoRaster) => {
      const layer = new GeoRasterLayer({
        attribution: 'Planet',
        georaster,
      });
      layerRef.current = layer;
      map.addLayer(layer);
    });

    return () => {
      if (layerRef.current) {
        map.removeLayer(layerRef.current);
      }
    };
  }, [map]);

  return null;
};

Thank you for the answer, unfortunately this versions of georaster-layer-for-leaflet also does the same error.

Same problem.

Hey, all. Thanks so much for commenting. It really helps me prioritize tickets and it seems like this is a big problem! I'll prioritize fixing this.

Hi, all. I'm not sure what the issue but if I had to guess some possibilies:

  • the raster has one band and the new statistical calculations are causing an issue, in which case add a pixelValuesToColorFn would fix that
  • something changed with the way how geotiff.js unpacks raster tile values

Open to other ideas!