-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmap.component.ts
More file actions
58 lines (49 loc) · 1.64 KB
/
map.component.ts
File metadata and controls
58 lines (49 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { AfterViewInit, Component, OnInit } from '@angular/core';
import * as L from 'leaflet';
import parseGeoRaster from 'georaster';
import GeoRasterLayer from 'georaster-layer-for-leaflet';
import proj4 from 'proj4';
(<any>window).proj4 = proj4;
@Component({
selector: 'app-map',
template: `<div id="map"></div>`,
styles: [
]
})
export class MapComponent implements AfterViewInit {
private map;
ngAfterViewInit(): void {
const createMap = async () => {
this.map = L.map('map', {
center: [ 39.8282, -98.5795 ],
zoom: 3
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(this.map);
// this url is for the Near-Infrared Band
const url = "https://landsat-pds.s3.amazonaws.com/c1/L8/045/032/LC08_L1TP_045032_20180811_20180815_01_T1/LC08_L1TP_045032_20180811_20180815_01_T1_B5.TIF";
const georaster = await parseGeoRaster(url);
console.log(georaster);
const imageryLayer = new GeoRasterLayer({
georaster,
pixelValuesToColorFn: values => {
// transforming single value into an rgba color
const nir = values[0];
if (nir === 0) return;
// console.log("nir:", nir);
const r = nir / 20000 * 255;
const g = 0;
const b = 0;
return `rgba(${r},${g},${b}, 1)`;
},
resolution: 64,
opacity: 1
});
imageryLayer.addTo(this.map);
this.map.fitBounds(imageryLayer.getBounds());
};
createMap();
}
}