@gisatcz/deckgl-geolib 1.6.0-dev.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/cjs/index.js +12 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +12 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/cogbitmaplayer/README.md +34 -21
- package/src/cogterrainlayer/README.md +36 -23
- package/src/cogtiles/README.md +4 -4
- package/src/geoimage/README.md +13 -13
- package/src/geoimage/geoimage.ts +13 -19
package/package.json
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
1
|
# CogBitmapLayer
|
|
2
|
+
|
|
2
3
|
A Deck.gl-compatible layer for loading and displaying tiled COG image data
|
|
3
|
-
|
|
4
|
-
###
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
#### Tiled data rendering
|
|
5
7
|
- Dynamically load and render tiled COG image data
|
|
6
|
-
|
|
8
|
+
#### Data visualization
|
|
7
9
|
- Set visualization styling, colors, use heatmap, set data bounds, and more
|
|
8
|
-
|
|
9
|
-
- Supports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
#### Compression support
|
|
11
|
+
- Supports DEFLATE data compression methods
|
|
12
|
+
|
|
13
|
+
[//]: # (- Supports JPEG, LZW nad DEFLATE data compression methods)
|
|
14
|
+
### Usage
|
|
15
|
+
#### Initialize the layer
|
|
16
|
+
To create CogBitmapLayer, you need an URL of your COG and also an object containing [geoimage](../geoimage/README.md) options for data processing.
|
|
13
17
|
|
|
14
18
|
#### Example
|
|
19
|
+
Import package into project and create terrain layer
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import geolib from '@gisatcz/deckgl-geolib';
|
|
23
|
+
|
|
24
|
+
const CogBitmapLayer = geolib.CogBitmapLayer;
|
|
25
|
+
```
|
|
15
26
|
Display simple rgb image. If you don't specify a channel to process, it defaults to grayscale, RGB, or RGBA depending on the channel count
|
|
16
27
|
```typescript
|
|
17
28
|
const bitmapLayer = new CogBitmapLayer(
|
|
18
|
-
|
|
19
|
-
{type:
|
|
29
|
+
'cog_data_url.tif',
|
|
30
|
+
{type:'image'}
|
|
20
31
|
)
|
|
21
32
|
```
|
|
22
33
|
Display the second channel as a heatmap with data from 0 to 1000
|
|
23
|
-
- Currently, when `useAutoRange` is `true
|
|
34
|
+
- Currently, when `useAutoRange` is `true`, min and max data value for each image is calculated separately, thus it is recommended to set min and max values in `colorScaleValueRange`.
|
|
24
35
|
|
|
25
36
|
```typescript
|
|
26
37
|
const bitmapLayer = new CogBitmapLayer(
|
|
27
|
-
|
|
28
|
-
{type:
|
|
38
|
+
'cog_data_url.tif',
|
|
39
|
+
{type:'image', useHeatmap:true, useChannel:1, colorScaleValueRange: [0, 1000]}
|
|
29
40
|
)
|
|
30
41
|
```
|
|
31
|
-
|
|
42
|
+
<a name='custom-heatmap-color-scale'></a>
|
|
43
|
+
Display the second channel as a heatmap with data from 0 to 1000 with custom color scale
|
|
32
44
|
|
|
33
45
|
```typescript
|
|
34
46
|
const bitmapLayer = new CogBitmapLayer(
|
|
35
|
-
|
|
36
|
-
{type:
|
|
47
|
+
'cog.tif',
|
|
48
|
+
{type:'image', useHeatmap:true, useChannel:1, colorScale: ['green', '#3182bd', [255, 0, 0], colorScaleValueRange: [0, 1000]}
|
|
37
49
|
)
|
|
38
50
|
```
|
|
39
51
|
Display the third channel as a green color and only show data from 100 to 200, the clipped data should be visualized with yellow color
|
|
40
52
|
```typescript
|
|
41
53
|
const bitmapLayer = new CogBitmapLayer(
|
|
42
|
-
|
|
43
|
-
{type:
|
|
54
|
+
'cog.tif',
|
|
55
|
+
{type:'image', useChannel:2, useSingleColor: true, clipLow:100, clipHigh: 200, color: [0, 255, 0], clippedColor: 'yellow'}
|
|
44
56
|
)
|
|
45
57
|
```
|
|
46
|
-
|
|
58
|
+
<a name='assigning-color-to-specific-data-value'></a>
|
|
59
|
+
Asign color to specific data values
|
|
47
60
|
```typescript
|
|
48
61
|
const bitmapLayer = new CogBitmapLayer(
|
|
49
|
-
|
|
50
|
-
{type:
|
|
62
|
+
'cog.tif',
|
|
63
|
+
{type:'image', useChannel:20, useColorsBasedOnValues: true, colorsBasedOnValues: [[1, 'red'], [2, [0,0,255]], [3, '#00FF00']]}
|
|
51
64
|
)
|
|
52
65
|
```
|
|
@@ -1,41 +1,54 @@
|
|
|
1
1
|
# CogTerrainLayer
|
|
2
|
+
|
|
2
3
|
A Deck.gl-compatible layer for loading and displaying tiled COG height data
|
|
3
|
-
|
|
4
|
-
###
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
#### Tiled terrain rendering
|
|
5
8
|
- Dynamically load and render tiled COG height data
|
|
6
9
|
- Overlay another COG as a bitmap, or supply a tile service template url.
|
|
7
|
-
|
|
10
|
+
#### Data visualization
|
|
8
11
|
- Multiply terrain height
|
|
9
12
|
- Clamp COG data on top of generated terrain
|
|
10
13
|
- Set visualization styling, colors, use heatmap, set data bounds, and more
|
|
11
|
-
## Usage
|
|
12
|
-
### Initialize the layer
|
|
13
|
-
To create CogTerrainLayer, you need an URL of your COG and also an object containing [geoimage](/geoimage/README.md) options for data processing.
|
|
14
|
-
For this layer, only needed options are `type`, `format`, and optionally `useChannel` and `multiplier`.
|
|
15
|
-
You can also specify another COG as an overlay and it's corresponding options, or just supply a tile service template url. Overlay options use all of [geoimage](/geoimage/README.md) options and work only with COG
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
### Usage
|
|
16
|
+
#### Initialize the layer
|
|
17
|
+
To create CogTerrainLayer, you need an URL of your COG and also an object containing [geoimage](../geoimage/README.md) options for data processing.
|
|
18
|
+
For this layer, only needed options are `type`, and optionally `useChannel` and `multiplier`.
|
|
19
|
+
You can also specify another COG as an overlay, and it's corresponding options, or just supply a tile service template url. Overlay options use all of [geoimage](../geoimage/README.md) options and work only with COG
|
|
20
|
+
|
|
21
|
+
##### Example
|
|
22
|
+
Import package into project and create terrain layer
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import geolib from '@gisatcz/deckgl-geolib';
|
|
26
|
+
|
|
27
|
+
const CogTerrainLayer = geolib.CogTerrainLayer;
|
|
19
28
|
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
Display simple terrain
|
|
30
|
+
```typescript
|
|
31
|
+
const cogLayer = new CogTerrainLayer(
|
|
32
|
+
'CogTerrainLayer',
|
|
33
|
+
'cog_data_url.tif',
|
|
34
|
+
{ type: 'terrain'},
|
|
35
|
+
);
|
|
24
36
|
```
|
|
37
|
+
|
|
25
38
|
Display terrain with tile service overlay
|
|
26
|
-
```
|
|
39
|
+
```typescript
|
|
27
40
|
const terrainLayer = new CogTerrainLayer(
|
|
28
|
-
|
|
29
|
-
{type:
|
|
30
|
-
|
|
41
|
+
'cog_data_url.tif',
|
|
42
|
+
{type:'terrain'},
|
|
43
|
+
'tile-service.com/{z}/{x}/{y}.png'
|
|
31
44
|
)
|
|
32
45
|
```
|
|
33
46
|
Display terrain with stylized COG overlay
|
|
34
|
-
```
|
|
47
|
+
```typescript
|
|
35
48
|
const terrainLayer = new CogTerrainLayer(
|
|
36
|
-
|
|
37
|
-
{type:
|
|
38
|
-
|
|
39
|
-
{type:
|
|
49
|
+
'cog.tif',
|
|
50
|
+
{type:'terrain'},
|
|
51
|
+
'cog-overlay.tif',
|
|
52
|
+
{type:'image', useHeatMap:true, useChannel:2}
|
|
40
53
|
)
|
|
41
54
|
```
|
package/src/cogtiles/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# COG Tiles
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
##### A Javascript library for easier tile functionality with COG files
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Features
|
|
10
10
|
|
|
11
11
|
Class allows using CogTiff files with Deck.gl TileLayer.
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ Provides extra functionality for CogTiff files
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
### Methods
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
package/src/geoimage/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Geoimage
|
|
2
|
+
##### A Javascript library for generating bitmaps out of **geoTIFF** files.
|
|
3
3
|
<img src = "/images/example0crop1.png" width = "100%">
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
### Features
|
|
6
|
+
##### Color texture generation
|
|
7
7
|
- Create RGB pictures out of RGB geoTIFF data.
|
|
8
8
|
- Generate pictures out of non-RGB geoTIFF data with different processing options.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
##### Terrain texture generation
|
|
11
11
|
- Generate heightmaps out of single-channel geoTIFF elevation data.
|
|
12
12
|
- The **elevation data** is encoded into the bitmap as [Mapbox Terrain-RGB](https://docs.mapbox.com/data/tilesets/guides/access-elevation-data/#decode-data).
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
##### Data visualisation options
|
|
15
15
|
- Color
|
|
16
16
|
- Transparency
|
|
17
17
|
- Heatmap (custom color scale example [here](../cogbitmaplayer/README.md#custom-heatmap-color-scale))
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
- Automatic data range
|
|
20
20
|
- Manual data range
|
|
21
21
|
- Assign color to specific data value (example [here](../cogbitmaplayer/README.md#assigning-color-to-specific-data-value))
|
|
22
|
-
|
|
22
|
+
### Data processing options
|
|
23
23
|
- `useAutoRange : boolean` - set automatic range of color gradient **(default false)**
|
|
24
24
|
- `useDataForOpacity : boolean` - visualise data with opacity of each pixel according to its value **(default false)**
|
|
25
25
|
- `alpha : number` - visualise data in specific opacity **(if useDataOpacity is false)** **(default 150)**
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
- `useSingleColor: boolean` - display data values only with single color **(default false)**
|
|
40
40
|
- `color: chroma.Color` - set color when **if useSingleColor is true**, **(default [255, 0, 255, 255])**
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
### Return options
|
|
43
43
|
**Method returns Image DataUrl**
|
|
44
44
|
|
|
45
45
|
- `getMap(returnFormat : "image" | "terrain", input : string | { width : number, height : number, rasters : any[] }, options?: { opacity : number })`
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
|
|
49
49
|
If `returnFormat` = `"terrain"` - Ignores all options except `multiplier` and returns [Mapbox Terrain-RGB](https://docs.mapbox.com/data/tilesets/guides/access-elevation-data/#decode-data)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
### Basic example
|
|
52
|
+
##### Initialize the library
|
|
53
53
|
```typescript
|
|
54
54
|
import GeoImage from 'geoimage';
|
|
55
55
|
|
|
56
56
|
const g = new GeoImage();
|
|
57
57
|
```
|
|
58
|
-
|
|
58
|
+
##### Get bitmap
|
|
59
59
|
```typescript
|
|
60
60
|
const bitmap = await g.getMap("image", 'image.tif');
|
|
61
61
|
```
|
|
@@ -65,7 +65,7 @@ const bitmap = await g.getMap("image", { width : 512, height : 512, rasters : [[
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
##### Get heightmap
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
71
|
const heightmap = await g.getMap("terrain", 'image.tif');
|
|
@@ -74,7 +74,7 @@ const heightmap = await g.getMap("terrain", 'image.tif');
|
|
|
74
74
|
const bitmap = await g.getMap("terrain", { width : 512, height : 512, rasters : [[...data]] });
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
### Advanced example
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
80
|
//Import the library and initiate GeoImage object:
|
package/src/geoimage/geoimage.ts
CHANGED
|
@@ -135,30 +135,24 @@ export default class GeoImage {
|
|
|
135
135
|
const c = canvas.getContext('2d');
|
|
136
136
|
const imageData = c!.createImageData(width, height);
|
|
137
137
|
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
let pixel = 0;
|
|
142
|
-
if (options.useChannel != null) {
|
|
143
|
-
pixel = options.useChannel;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// console.time("heightmap generated in");
|
|
147
|
-
for (let i = 0; i < s; i += 4) {
|
|
148
|
-
channel[pixel] *= options.multiplier!;
|
|
149
|
-
const multiplied = 100000 + channel[pixel] * 10;
|
|
138
|
+
const numOfChannels = channel.length / (width * height);
|
|
139
|
+
const size: number = width * height * 4;
|
|
140
|
+
let pixel:number = options.useChannel === null ? 0 : options.useChannel;
|
|
150
141
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
for (let i = 0; i < size; i += 4) {
|
|
143
|
+
// height image calculation based on:
|
|
144
|
+
// https://deck.gl/docs/api-reference/geo-layers/terrain-layer
|
|
145
|
+
|
|
146
|
+
const elevationValue = channel[pixel] * options.multiplier!;
|
|
147
|
+
const colorValue = Math.floor((elevationValue + 10000) / 0.1);
|
|
148
|
+
imageData.data[i] = Math.floor(colorValue / (256 * 256));
|
|
149
|
+
imageData.data[i + 1] = Math.floor((colorValue / 256) % 256);
|
|
150
|
+
imageData.data[i + 2] = colorValue % 256;
|
|
155
151
|
imageData.data[i + 3] = 255;
|
|
156
152
|
|
|
157
|
-
pixel +=
|
|
153
|
+
pixel += numOfChannels;
|
|
158
154
|
}
|
|
159
155
|
|
|
160
|
-
// console.timeEnd("heightmap generated in");
|
|
161
|
-
|
|
162
156
|
c!.putImageData(imageData, 0, 0);
|
|
163
157
|
const imageUrl = canvas.toDataURL('image/png');
|
|
164
158
|
// console.log('Heightmap generated.');
|