Skip to content

Commit

Permalink
addition of gridded livestock layers
Browse files Browse the repository at this point in the history
  • Loading branch information
SofiaAldabet authored and KevSanchez committed Nov 5, 2024
1 parent fddf30d commit 05f765a
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const GriddedLivestockCommonStyles =

'<RasterSymbolizer>' +
'<ColorMap type="ramp" extended="false">' +
'<ColorMapEntry color="#FFFFFF" quantity="0" label="0" />' +
'<ColorMapEntry color="#E0F7FA" quantity="5" label="≤ 5" />' +
'<ColorMapEntry color="#B2EBF2" quantity="10" label="≤ 10" />' +
'<ColorMapEntry color="#80DEEA" quantity="20" label="≤ 20" />' +
'<ColorMapEntry color="#68B0C3" quantity="50" label="≤ 50" />' +
'<ColorMapEntry color="#4A99B4" quantity="100" label="≤ 100" />' +
'<ColorMapEntry color="#3F8B9C" quantity="250" label="≤ 250" />' +
'<ColorMapEntry color="#c766fc" quantity="500" label="≤ 500" />' +
'<ColorMapEntry color="#9c50c7" quantity="1000" label="≤ 1,000" />' +
'<ColorMapEntry color="#883886" quantity="2500" label="≤ 2,500" />' +
'<ColorMapEntry color="#390147" quantity="300000" label="> 2,500" />' +
'</ColorMap>' +
'</RasterSymbolizer>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CategoricalDataset } from './earth-engine-dataset';
import ee from '@google/earthengine';
import { EarthEngineUtils } from "../earth-engine-utils";
import { GriddedLivestockCommonStyles} from "./common-styles-utils";

export const GriddedLivestockBuffalo: CategoricalDataset = {
assetPath: {
default: "projects/gmvad-grass/assets/5_Bf_2015_Da"
},

bandName: 'b1',

sldStyles: GriddedLivestockCommonStyles,


areYearsValid(startYear?: number, endYear?: number): boolean {
// This Asset is static, and year selector is irrelevant
return true;
},

getEEAsset() {
return ee.Image(this.assetPath.default);
},

async getMapUrl(z, x, y) {
const image = this.getEEAsset().select(this.bandName).sldStyle(this.sldStyles);
const mapId = await EarthEngineUtils.getMapId(image);
return ee.data.getTileUrl(mapId, x, y, z);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CategoricalDataset } from './earth-engine-dataset';
import ee from '@google/earthengine';
import { EarthEngineUtils } from "../earth-engine-utils";
import { GriddedLivestockCommonStyles} from "./common-styles-utils";

export const GriddedLivestockCattle: CategoricalDataset = {
assetPath: {
default: "projects/gmvad-grass/assets/5_Ct_2015_Da"
},

bandName: 'b1',

sldStyles: GriddedLivestockCommonStyles,


areYearsValid(startYear?: number, endYear?: number): boolean {
// This Asset is static, and year selector is irrelevant
return true;
},

getEEAsset() {
return ee.Image(this.assetPath.default);
},

async getMapUrl(z, x, y) {
const image = this.getEEAsset().select(this.bandName).sldStyle(this.sldStyles);
const mapId = await EarthEngineUtils.getMapId(image);
return ee.data.getTileUrl(mapId, x, y, z);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CategoricalDataset } from './earth-engine-dataset';
import ee from '@google/earthengine';
import { EarthEngineUtils } from "../earth-engine-utils";
import { GriddedLivestockCommonStyles} from "./common-styles-utils";

export const GriddedLivestockGoat: CategoricalDataset = {
assetPath: {
default: "projects/gmvad-grass/assets/5_Gt_2015_Da"
},

bandName: 'b1',

sldStyles: GriddedLivestockCommonStyles,


areYearsValid(startYear?: number, endYear?: number): boolean {
// This Asset is static, and year selector is irrelevant
return true;
},

getEEAsset() {
return ee.Image(this.assetPath.default);
},

async getMapUrl(z, x, y) {
const image = this.getEEAsset().select(this.bandName).sldStyle(this.sldStyles);
const mapId = await EarthEngineUtils.getMapId(image);
return ee.data.getTileUrl(mapId, x, y, z);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CategoricalDataset } from './earth-engine-dataset';
import ee from '@google/earthengine';
import { EarthEngineUtils } from "../earth-engine-utils";
import { GriddedLivestockCommonStyles} from "./common-styles-utils";

export const GriddedLivestockHorse: CategoricalDataset = {
assetPath: {
default: "projects/gmvad-grass/assets/5_Ho_2015_Da"
},

bandName: 'b1',

sldStyles: GriddedLivestockCommonStyles,


areYearsValid(startYear?: number, endYear?: number): boolean {
// This Asset is static, and year selector is irrelevant
return true;
},

getEEAsset() {
return ee.Image(this.assetPath.default);
},

async getMapUrl(z, x, y) {
const image = this.getEEAsset().select(this.bandName).sldStyle(this.sldStyles);
const mapId = await EarthEngineUtils.getMapId(image);
return ee.data.getTileUrl(mapId, x, y, z);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CategoricalDataset } from './earth-engine-dataset';
import ee from '@google/earthengine';
import { EarthEngineUtils } from "../earth-engine-utils";
import { GriddedLivestockCommonStyles} from "./common-styles-utils";

export const GriddedLivestockSheep: CategoricalDataset = {
assetPath: {
default: "projects/gmvad-grass/assets/5_Sh_2015_Da"
},

bandName: 'b1',

sldStyles: GriddedLivestockCommonStyles,


areYearsValid(startYear?: number, endYear?: number): boolean {
// This Asset is static, and year selector is irrelevant
return true;
},

getEEAsset() {
return ee.Image(this.assetPath.default);
},

async getMapUrl(z, x, y) {
const image = this.getEEAsset().select(this.bandName).sldStyle(this.sldStyles);
const mapId = await EarthEngineUtils.getMapId(image);
return ee.data.getTileUrl(mapId, x, y, z);
},
};
12 changes: 11 additions & 1 deletion cloud_functions/earth_engine_tiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {ModisNetPrimaryProductionChange} from './geeAssets/modis-net-primary-pro
import {AnthropogenicBiomes} from './geeAssets/anthropogenic-biomes';
import {LivestockProductionSystems} from './geeAssets/livestock-production-systems';
import {ForestLoss} from './geeAssets/forest-loss';
import {GriddedLivestockCattle} from './geeAssets/gridded-livestock-cattle';
import {GriddedLivestockGoat} from './geeAssets/gridded-livestock-goat';
import {GriddedLivestockHorse} from './geeAssets/gridded-livestock-horse';
import {GriddedLivestockBuffalo} from './geeAssets/gridded-livestock-buffalo';
import {GriddedLivestockSheep} from './geeAssets/gridded-livestock-sheep';
import {EarthEngineDataset} from "./geeAssets/earth-engine-dataset";
import {TileRequestDTO, Tilesets} from "./tile-request.dto";
import {default as fetch , Response as FetchResponse} from "node-fetch";
Expand All @@ -20,7 +25,12 @@ const assets: Record<Tilesets, EarthEngineDataset> = {
[Tilesets.modis_net_primary_production_change]: ModisNetPrimaryProductionChange,
[Tilesets.anthropogenic_biomes]: AnthropogenicBiomes,
[Tilesets.livestock_production_systems]: LivestockProductionSystems,
[Tilesets.forest_loss]: ForestLoss
[Tilesets.forest_loss]: ForestLoss,
[Tilesets.gridded_livestock_cattle]: GriddedLivestockCattle,
[Tilesets.gridded_livestock_goat]: GriddedLivestockGoat,
[Tilesets.gridded_livestock_horse]: GriddedLivestockHorse,
[Tilesets.gridded_livestock_buffalo]: GriddedLivestockBuffalo,
[Tilesets.gridded_livestock_sheep]: GriddedLivestockSheep,
}

//We're using express to simplify path parameter parsing for the Tiles endpoint
Expand Down
7 changes: 6 additions & 1 deletion cloud_functions/earth_engine_tiler/src/tile-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export enum Tilesets {
modis_net_primary_production_change = "modis_net_primary_production_change",
anthropogenic_biomes = "anthropogenic_biomes",
livestock_production_systems = "livestock_production_systems",
forest_loss = "forest_loss"
forest_loss = "forest_loss",
gridded_livestock_cattle = "gridded_livestock_cattle",
gridded_livestock_goat = "gridded_livestock_goat",
gridded_livestock_horse = "gridded_livestock_horse",
gridded_livestock_buffalo = "gridded_livestock_buffalo",
gridded_livestock_sheep = "gridded_livestock_sheep"
}


Expand Down

0 comments on commit 05f765a

Please sign in to comment.