geotiff.js icon indicating copy to clipboard operation
geotiff.js copied to clipboard

RangeError: Invalid typed array length

Open Zvarrit opened this issue 6 years ago • 5 comments

Hello, when I try to load a full raster with fromUrl I have a RangeError. If I try to load only one tile, there is no problem. Seem like than when the Uint8Array is created, it's length is negative. Is it a know issue, and did I made a mistake when I load the raster ?

Zvarrit avatar Mar 20 '20 09:03 Zvarrit

Hi @Zvarrit Thanks for raising this issue.

Is it a know issue,

No, typically this should work.

and did I made a mistake when I load the raster ?

I cannot tell, I did not see the code you are using to read the data.

Can you provide more information? Could you maybe share the TIFF that is causing the problem? Also very helpful is a stacktrace of the error, the tiffdump or a gdalinfo.

constantinius avatar Mar 20 '20 21:03 constantinius

I'll close this issue now, reopen please when there is more information available.

constantinius avatar Apr 08 '20 21:04 constantinius

Sorry for the delay, I'm using PHP for getting the raster of a database. I declare a header to make it a tiff file, and use directly the php link with the "fromUrl" function. If I directly use it, I have a RangeError. However, if I first download the result then use the result with "fromUrl", it work.

Zvarrit avatar Jun 08 '20 12:06 Zvarrit

Hi @constantinius, attached are two sample files with 2 bands (GFS wind u,v) generated with GDAL 3.3.0.

Code used to read them:

const geotiff = await GeoTIFF.fromUrl(url, { allowFullFile: true });
const geotiffImage = await geotiff.getImage(0);
const sourceData = await geotiffImage.readRasters({ interleave: true });

Result:

2021110917.tif.zip - RangeError: Invalid typed array length: -dddd (negative number) 2021110918.tif.zip - works fine

The same error happens with single-band files.

Could you take a look what's the difference between the two attached files, please? GDAL and QGIS opens them both fine.

zakjan avatar Nov 09 '21 18:11 zakjan

Will have a look

constantinius avatar Nov 10 '21 13:11 constantinius