Package Exports
- lerc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lerc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Lerc JS
Rapid decoding of Lerc compressed raster data for any standard pixel type, not just rgb or byte
Browser
<script type="text/javascript" src="https://unpkg.com/lerc"></script>
Lerc.decode(xhrResponse, {
pixelType: "U8", // leave pixelType out in favor of F32 for lerc1
inputOffset: 10 // start from the 10th byte
});
Node
npm install lerc && npm install node-fetch
const fetch = require('node-fetch');
const Lerc = require('lerc');
fetch('http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer/tile/0/0/0')
.then(response => response.arrayBuffer())
.then(body => {
const image = Lerc.decode(body);
image.width // 257
});
API Reference
Lerc
a module for decoding LERC blobs
decode(input, [options]) ⇒ Object
⏏
A wrapper for decoding both LERC1 and LERC2 byte streams capable of handling multiband pixel blocks for various pixel types.
Kind: Exported function
Param | Type | Description |
---|---|---|
input | ArrayBuffer |
The LERC input byte stream |
[options] | object |
The decoding options below are optional. |
[options.inputOffset] | number |
The number of bytes to skip in the input byte stream. A valid Lerc file is expected at that position. |
[options.pixelType] | string |
(LERC1 only) Default value is F32. Valid pixel types for input are U8/S8/S16/U16/S32/U32/F32. |
[options.noDataValue] | number |
(LERC1 only). It is recommended to use the returned mask instead of setting this value. |
Result Object Properties
Name | Type | Description |
---|---|---|
width | number |
Width of decoded image. |
height | number |
Height of decoded image. |
pixels | array |
[band1, band2, …] Each band is a typed array of width*height. |
pixelType | string |
The type of pixels represented in the output. |
mask | mask |
Typed array with a size of width*height, or null if all pixels are valid. |
statistics | array |
[statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values |
Licensing
Copyright © 2017-2018 Esri
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A local copy of the license and additional notices are located with the source distribution at: