From d777f49eb8b2baa5cf9a13f7621d36cca6984c20 Mon Sep 17 00:00:00 2001 From: Abby Vath Meyer Date: Mon, 3 Feb 2025 19:53:52 +0000 Subject: [PATCH] Update kelp report with linear data. Remove kelpPersist report --- data/precalc/precalcKelp.json | 66 + data/precalc/precalcKelp.ts | 61 + examples/output/mpa-test/kelp.json | 90 ++ examples/output/mpa-test/spacing.json | 7 + examples/output/network/kelp.json | 362 +++++ examples/output/network/spacing.json | 7 + project/datasources.json | 170 +-- project/geoprocessing.json | 6 +- project/metrics.json | 90 +- project/precalc.json | 1178 ++--------------- src/components/{KelpMax.tsx => Kelp.tsx} | 90 +- src/components/KelpPersist.tsx | 313 ----- src/components/RepresentationPage.tsx | 6 +- src/components/Shoretypes.tsx | 5 - src/components/Spacing.tsx | 2 +- src/components/Span.tsx | 3 - src/functions/{kelpMax.ts => kelp.ts} | 20 +- src/functions/kelpPersist.ts | 90 -- src/functions/kelpPersistSmoke.test.ts | 24 - src/functions/kelpPersistWorker.ts | 87 -- ...kelpMaxSmoke.test.ts => kelpSmoke.test.ts} | 10 +- .../{kelpMaxWorker.ts => kelpWorker.ts} | 70 +- src/functions/spacingWorker.ts | 10 +- src/util/genSketchTable.tsx | 3 +- 24 files changed, 809 insertions(+), 1961 deletions(-) create mode 100644 data/precalc/precalcKelp.json create mode 100644 data/precalc/precalcKelp.ts create mode 100644 examples/output/mpa-test/kelp.json create mode 100644 examples/output/network/kelp.json rename src/components/{KelpMax.tsx => Kelp.tsx} (71%) delete mode 100644 src/components/KelpPersist.tsx rename src/functions/{kelpMax.ts => kelp.ts} (81%) delete mode 100644 src/functions/kelpPersist.ts delete mode 100644 src/functions/kelpPersistSmoke.test.ts delete mode 100644 src/functions/kelpPersistWorker.ts rename src/functions/{kelpMaxSmoke.test.ts => kelpSmoke.test.ts} (63%) rename src/functions/{kelpMaxWorker.ts => kelpWorker.ts} (51%) diff --git a/data/precalc/precalcKelp.json b/data/precalc/precalcKelp.json new file mode 100644 index 0000000..ce1b16e --- /dev/null +++ b/data/precalc/precalcKelp.json @@ -0,0 +1,66 @@ +[ + { + "metricId": "metric", + "value": 43.520270317077255, + "classId": "kelp", + "groupId": null, + "geographyId": "north_sr", + "sketchId": null + }, + { + "metricId": "metric", + "value": 47.4713821595827, + "classId": "kelp", + "groupId": null, + "geographyId": "northcentral_sr", + "sketchId": null + }, + { + "metricId": "metric", + "value": 155.14793112016181, + "classId": "kelp", + "groupId": null, + "geographyId": "central_sr", + "sketchId": null + }, + { + "metricId": "metric", + "value": 315.3763949392171, + "classId": "kelp", + "groupId": null, + "geographyId": "south_sr", + "sketchId": null + }, + { + "metricId": "metric", + "value": 89.57109047586958, + "classId": "kelp", + "groupId": null, + "geographyId": "north_br", + "sketchId": null + }, + { + "metricId": "metric", + "value": 156.5684931209522, + "classId": "kelp", + "groupId": null, + "geographyId": "central_br", + "sketchId": null + }, + { + "metricId": "metric", + "value": 317.08104847029153, + "classId": "kelp", + "groupId": null, + "geographyId": "south_br", + "sketchId": null + }, + { + "metricId": "metric", + "value": 563.2206320671133, + "classId": "kelp", + "groupId": null, + "geographyId": "world", + "sketchId": null + } +] diff --git a/data/precalc/precalcKelp.ts b/data/precalc/precalcKelp.ts new file mode 100644 index 0000000..44a2d9f --- /dev/null +++ b/data/precalc/precalcKelp.ts @@ -0,0 +1,61 @@ +import { bbox, featureCollection, union } from "@turf/turf"; +import geographies from "../../project/geographies.json" with { type: "json" }; +import { lineOverlap } from "../../src/util/overlapLineLength.js"; +import { + LineString, + loadFgb, + MultiPolygon, + Feature, + Polygon, + genFeatureCollection, + createMetric, +} from "@seasketch/geoprocessing"; +import fs from "fs-extra"; +import projectClient from "../../project/projectClient.js"; + +async function main() { + // Initialize an empty array to store results + const metrics = []; + const metricGroup = projectClient.getMetricGroup("kelp"); + for (const geography of geographies) { + try { + console.log(`Processing geography: ${geography.geographyId}`); + const geo = await loadFgb>( + `http://127.0.0.1:8080/${geography.datasourceId}.fgb`, + ); + + // Load features once + const features = await loadFgb>( + "http://127.0.0.1:8080/" + metricGroup.classes[0].datasourceId + ".fgb", + bbox(featureCollection(geo)), + ); + + // Use union if there are multiple features + const geoUnion = + geo.length > 1 ? union(genFeatureCollection(geo))! : geo[0]; + + // Calculate total length + const totalLength = lineOverlap(geoUnion, features, { units: "miles" }); + + // Create metric and add it to the array + const metric = createMetric({ + geographyId: geography.geographyId, + classId: "kelp", + value: totalLength, + }); + metrics.push(metric); + } catch (error) { + console.error( + `Error processing geography ${geography.geographyId}:`, + error, + ); + } + } + + // Write the results to a JSON file + fs.writeJsonSync(`${import.meta.dirname}/precalcKelp.json`, metrics); + + console.log("All geographies processed."); +} + +main(); diff --git a/examples/output/mpa-test/kelp.json b/examples/output/mpa-test/kelp.json new file mode 100644 index 0000000..583eb29 --- /dev/null +++ b/examples/output/mpa-test/kelp.json @@ -0,0 +1,90 @@ +[ + { + "geographyId": "central_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 7.483337, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "central_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 7.483337, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "north_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "north_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "northcentral_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "south_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "south_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "world", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "29784", + "groupId": null, + "value": 7.483337, + "extra": { + "sketchName": "mpa-test" + } + } +] \ No newline at end of file diff --git a/examples/output/mpa-test/spacing.json b/examples/output/mpa-test/spacing.json index f56cfcc..a8b6f42 100644 --- a/examples/output/mpa-test/spacing.json +++ b/examples/output/mpa-test/spacing.json @@ -315,6 +315,13 @@ ], "paths": [] }, + { + "id": "kelp", + "replicates": [ + "29784" + ], + "paths": [] + }, { "id": "eelgrass", "replicates": [], diff --git a/examples/output/network/kelp.json b/examples/output/network/kelp.json new file mode 100644 index 0000000..5560f62 --- /dev/null +++ b/examples/output/network/kelp.json @@ -0,0 +1,362 @@ +[ + { + "geographyId": "central_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 14.140685, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "central_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 7.483337, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "central_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 6.657349, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "central_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "central_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 14.140685, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "central_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 7.483337, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "central_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 6.657349, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "central_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "north_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "north_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "north_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "north_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "north_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "north_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "north_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "north_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "northcentral_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "northcentral_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "northcentral_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "northcentral_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "south_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 17.313865, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "south_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "south_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 7.306198, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "south_br", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 10.007667, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "south_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 17.313865, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "south_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 0, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "south_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 7.306198, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "south_sr", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 10.007667, + "extra": { + "sketchName": "anacapa" + } + }, + { + "geographyId": "world", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34588", + "groupId": null, + "value": 31.454549999999998, + "extra": { + "sketchName": "network", + "isCollection": true + } + }, + { + "geographyId": "world", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34589", + "groupId": null, + "value": 7.483337, + "extra": { + "sketchName": "mpa-test" + } + }, + { + "geographyId": "world", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34590", + "groupId": null, + "value": 13.963547, + "extra": { + "sketchName": "split" + } + }, + { + "geographyId": "world", + "metricId": "kelp", + "classId": "kelp", + "sketchId": "34591", + "groupId": null, + "value": 10.007667, + "extra": { + "sketchName": "anacapa" + } + } +] \ No newline at end of file diff --git a/examples/output/network/spacing.json b/examples/output/network/spacing.json index 3395f70..01dd7f1 100644 --- a/examples/output/network/spacing.json +++ b/examples/output/network/spacing.json @@ -995,6 +995,13 @@ ], "paths": [] }, + { + "id": "kelp", + "replicates": [ + "34589" + ], + "paths": [] + }, { "id": "eelgrass", "replicates": [], diff --git a/project/datasources.json b/project/datasources.json index 411554c..a0089dc 100644 --- a/project/datasources.json +++ b/project/datasources.json @@ -45,81 +45,6 @@ "classKeys": [], "url": "https://gp-global-datasources-datasets.s3.us-west-1.amazonaws.com/global-eez-mr-v12.fgb" }, - { - "datasourceId": "bo-present-surface-ph", - "geo_type": "raster", - "formats": ["tif"], - "precalc": false, - "metadata": { - "name": "BioOracle Present Day Surface pH", - "description": "BioOracle Present Day Surface pH global raster", - "version": "2.2", - "publisher": "BioOracle", - "publishDate": "2021-09-24", - "publishLink": "https://www.bio-oracle.org/" - }, - "measurementType": "quantitative", - "band": 1, - "noDataValue": -3.3999999521443642e38, - "created": "2023-12-11T11:55:31.053Z", - "lastUpdated": "2023-12-11T12:52:22.966Z", - "src": "https://gp-global-datasources-datasets.s3.us-west-1.amazonaws.com/bo-present-surface-ph.tif" - }, - { - "datasourceId": "bo-present-surface-temp-max", - "geo_type": "raster", - "formats": ["tif"], - "precalc": false, - "metadata": { - "name": "BioOracle Present Day Surface Temperature Maximum", - "description": "BioOracle Present Day Surface Temperature Maximum global raster", - "version": "2.2", - "publisher": "BioOracle", - "publishDate": "2021-09-24", - "publishLink": "https://www.bio-oracle.org/" - }, - "measurementType": "quantitative", - "band": 1, - "noDataValue": -1.7e308, - "url": "https://gp-global-datasources-datasets.s3.us-west-1.amazonaws.com/bo-present-surface-temp-max.tif" - }, - { - "datasourceId": "bo-present-surface-temp-min", - "geo_type": "raster", - "formats": ["tif"], - "precalc": false, - "metadata": { - "name": "BioOracle Present Day Surface Temperature Minimum", - "description": "BioOracle Present Day Surface Temperature Minimum global raster", - "version": "2.2", - "publisher": "BioOracle", - "publishDate": "2021-09-24", - "publishLink": "https://www.bio-oracle.org/" - }, - "measurementType": "quantitative", - "band": 1, - "noDataValue": -1.7e308, - "url": "https://gp-global-datasources-datasets.s3.us-west-1.amazonaws.com/bo-present-surface-temp-min.tif" - }, - { - "datasourceId": "meow-ecos", - "geo_type": "vector", - "formats": ["fgb"], - "precalc": false, - "metadata": { - "name": "Marine Ecoregions of the World", - "description": "A biogeographic classification of the world's coastal and continental shelf waters following a nested hierarchy of realms, provinces and ecoregions", - "version": "20190911", - "publisher": "The Nature Conservancy", - "publishDate": "20190911", - "publishLink": "https://tnc.maps.arcgis.com/home/item.html?id=ed2be4cf8b7a451f84fd093c2e7660e3" - }, - "idProperty": "ECOREGION", - "nameProperty": "ECOREGION", - "layerName": "meow_ecos", - "classKeys": [], - "url": "https://gp-global-datasources-datasets.s3.us-west-1.amazonaws.com/meow-ecos.fgb" - }, { "datasourceId": "study_regions", "geo_type": "vector", @@ -128,7 +53,7 @@ "layerName": "MAN_CA_MLPA_StudyRegionBoundaries", "classKeys": ["NAME"], "created": "2024-05-21T22:23:21.520Z", - "lastUpdated": "2024-06-10T20:13:56.859Z", + "lastUpdated": "2025-02-03T18:42:42.989Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MLPA_StudyRegionBoundaries/MAN_CA_MLPA_StudyRegionBoundaries.shp", "propertiesToKeep": ["NAME"], "explodeMulti": true @@ -141,7 +66,7 @@ "layerName": "MAN_CA_MPA_BioRegions", "classKeys": ["NAME"], "created": "2024-05-28T18:42:44.795Z", - "lastUpdated": "2024-06-10T20:14:20.948Z", + "lastUpdated": "2025-02-03T18:42:43.353Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MPA_BioRegions/MAN_CA_MPA_BioRegions.shp", "propertiesToKeep": ["NAME"], "explodeMulti": true @@ -154,7 +79,7 @@ "layerName": "world", "classKeys": [], "created": "2024-05-31T20:58:18.854Z", - "lastUpdated": "2024-06-04T18:07:38.320Z", + "lastUpdated": "2025-02-03T18:42:43.391Z", "src": "data/bin/world.json", "propertiesToKeep": [], "explodeMulti": false @@ -167,7 +92,7 @@ "layerName": "clipped_offshorerock", "classKeys": [], "created": "2024-06-05T22:34:23.307Z", - "lastUpdated": "2025-01-13T22:06:58.887Z", + "lastUpdated": "2025-02-03T18:42:43.550Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_offshorerock.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -180,7 +105,7 @@ "layerName": "clipped_beaches", "classKeys": [], "created": "2024-06-06T17:12:11.406Z", - "lastUpdated": "2025-01-13T22:05:27.049Z", + "lastUpdated": "2025-02-03T18:42:43.697Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_beaches.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -193,7 +118,7 @@ "layerName": "clipped_coastalmarsh", "classKeys": [], "created": "2024-06-06T17:12:34.817Z", - "lastUpdated": "2025-01-13T22:05:27.114Z", + "lastUpdated": "2025-02-03T18:42:43.762Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_coastalmarsh.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -206,7 +131,7 @@ "layerName": "clipped_hardenedshores", "classKeys": [], "created": "2024-06-06T17:12:34.817Z", - "lastUpdated": "2025-01-13T22:05:27.223Z", + "lastUpdated": "2025-02-03T18:42:43.824Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_hardenedshores.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -219,7 +144,7 @@ "layerName": "clipped_rockyshores", "classKeys": [], "created": "2024-06-06T17:12:49.625Z", - "lastUpdated": "2025-01-13T22:05:27.467Z", + "lastUpdated": "2025-02-03T18:42:43.938Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_rockyshores.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -232,7 +157,7 @@ "layerName": "clipped_tidalflats", "classKeys": [], "created": "2024-06-06T17:13:03.351Z", - "lastUpdated": "2025-01-13T22:05:59.989Z", + "lastUpdated": "2025-02-03T18:42:44.001Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_tidalflats.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -245,7 +170,7 @@ "layerName": "clipped_unclassified", "classKeys": [], "created": "2024-06-06T17:13:15.110Z", - "lastUpdated": "2025-01-13T22:05:27.583Z", + "lastUpdated": "2025-02-03T18:42:44.042Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_unclassified.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -258,7 +183,7 @@ "layerName": "MPA_Petitions_bioregions_nofed_PairwiseDisso selection", "classKeys": [], "created": "2024-06-14T19:10:34.383Z", - "lastUpdated": "2024-07-08T21:33:40.610Z", + "lastUpdated": "2025-02-03T18:42:44.343Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/ClippingLayer/MPA_Petitions_bioregions_nofed_PairwiseDisso selection.shp", "propertiesToKeep": [], "explodeMulti": true @@ -271,7 +196,7 @@ "layerName": "estuaries_clipped", "classKeys": [], "created": "2024-06-17T20:49:40.597Z", - "lastUpdated": "2024-10-07T18:17:39.455Z", + "lastUpdated": "2025-02-03T18:42:44.480Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/estuaries/estuaries_clipped.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -284,7 +209,7 @@ "layerName": "central_br_extent", "classKeys": [], "created": "2024-06-17T21:27:54.623Z", - "lastUpdated": "2024-06-18T16:38:37.516Z", + "lastUpdated": "2025-02-03T18:42:44.530Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MPA_BioRegions/central_br_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -297,7 +222,7 @@ "layerName": "north_br_extent", "classKeys": [], "created": "2024-06-17T21:42:36.167Z", - "lastUpdated": "2024-06-18T16:38:37.584Z", + "lastUpdated": "2025-02-03T18:42:44.573Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MPA_BioRegions/north_br_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -310,7 +235,7 @@ "layerName": "south_br_extent", "classKeys": [], "created": "2024-06-17T22:04:50.182Z", - "lastUpdated": "2024-06-18T16:38:37.676Z", + "lastUpdated": "2025-02-03T18:42:44.614Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MPA_BioRegions/south_br_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -323,7 +248,7 @@ "layerName": "eelgrass_simplified5m_1mRemoved", "classKeys": [], "created": "2024-06-25T16:22:19.705Z", - "lastUpdated": "2024-09-19T20:07:47.782Z", + "lastUpdated": "2025-02-03T18:42:45.688Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/eelgrass/eelgrass_simplified5m_1mRemoved.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -336,7 +261,7 @@ "layerName": "north_sr_extent", "classKeys": [], "created": "2024-06-27T18:42:26.181Z", - "lastUpdated": "2024-06-27T18:42:26.181Z", + "lastUpdated": "2025-02-03T18:42:45.769Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MLPA_StudyRegionBoundaries/north_sr_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -349,7 +274,7 @@ "layerName": "northcentral_sr_extent", "classKeys": [], "created": "2024-06-27T18:43:48.206Z", - "lastUpdated": "2024-06-27T18:43:48.206Z", + "lastUpdated": "2025-02-03T18:42:45.886Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MLPA_StudyRegionBoundaries/northcentral_sr_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -362,7 +287,7 @@ "layerName": "central_sr_extent", "classKeys": [], "created": "2024-06-27T18:44:12.053Z", - "lastUpdated": "2024-06-27T18:44:12.053Z", + "lastUpdated": "2025-02-03T18:42:45.979Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MLPA_StudyRegionBoundaries/central_sr_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -375,7 +300,7 @@ "layerName": "south_sr_extent", "classKeys": [], "created": "2024-06-27T18:44:33.505Z", - "lastUpdated": "2024-08-12T18:18:34.820Z", + "lastUpdated": "2025-02-03T18:42:46.067Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/MAN_CA_MLPA_StudyRegionBoundaries/south_sr_extent.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -389,21 +314,9 @@ "band": 1, "noDataValue": -9999, "created": "2024-06-28T18:37:50.902Z", - "lastUpdated": "2024-06-28T18:37:50.902Z", + "lastUpdated": "2025-02-03T18:42:50.836Z", "src": "data/src/California MPAs 2024/Data_Received/NOAA_NCEI/CAbathyClipped.tif" }, - { - "datasourceId": "kelpPersist", - "geo_type": "raster", - "formats": ["tif"], - "precalc": true, - "measurementType": "categorical", - "band": 1, - "noDataValue": 15, - "created": "2024-07-24T16:15:49.909Z", - "lastUpdated": "2024-07-24T16:15:49.909Z", - "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/KelpPersistence/lookup/lookup30.tif" - }, { "datasourceId": "hab_ca", "geo_type": "raster", @@ -413,34 +326,9 @@ "band": 1, "noDataValue": -32768, "created": "2024-08-05T16:20:51.668Z", - "lastUpdated": "2024-08-05T16:20:51.668Z", + "lastUpdated": "2025-02-03T18:43:46.492Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/hab_ca/hab_ca30.tif" }, - { - "datasourceId": "kelpMax", - "geo_type": "raster", - "formats": ["tif"], - "precalc": true, - "measurementType": "quantitative", - "band": 1, - "noDataValue": 65535, - "created": "2024-08-12T20:59:52.498Z", - "lastUpdated": "2024-08-12T20:59:52.498Z", - "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Bio_ca_kelp_max_cdfw/kelpMax.tif" - }, - { - "datasourceId": "test", - "geo_type": "vector", - "formats": ["fgb"], - "precalc": true, - "layerName": "rockyshores", - "classKeys": [], - "created": "2024-09-04T19:12:05.432Z", - "lastUpdated": "2024-09-04T19:12:05.432Z", - "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/hab_ca_shoretypes_2010_update_rockislands_proj/rockyshores.fgb", - "propertiesToKeep": [], - "explodeMulti": true - }, { "datasourceId": "shoretypes", "geo_type": "vector", @@ -449,7 +337,7 @@ "layerName": "clipped_shoretypes", "classKeys": [], "created": "2024-09-04T19:57:56.137Z", - "lastUpdated": "2025-01-14T18:26:11.047Z", + "lastUpdated": "2025-02-03T18:44:05.229Z", "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/Updated_ShoreTypes_01092025/clipped_shoretypes.fgb", "propertiesToKeep": [], "explodeMulti": true @@ -463,19 +351,19 @@ "band": 1, "noDataValue": -9999, "created": "2024-10-15T16:10:31.893Z", - "lastUpdated": "2024-10-29T21:15:31.933Z", + "lastUpdated": "2025-02-03T18:47:57.990Z", "src": "data/src/California MPAs 2024/Plus_Depth_Substrate.tif" }, { - "datasourceId": "beaches_line", + "datasourceId": "kelp", "geo_type": "vector", "formats": ["fgb"], "precalc": true, - "layerName": "beaches", + "layerName": "LinearKelp_Maximum_1984_2023", "classKeys": [], - "created": "2025-01-10T20:16:17.566Z", - "lastUpdated": "2025-01-10T20:16:17.566Z", - "src": "data/src/California MPAs 2024/Data_Received/CDFW/unzipped/hab_ca_shoretypes_2010_update_rockislands_proj/beaches.fgb", + "created": "2025-02-03T18:29:25.981Z", + "lastUpdated": "2025-02-03T18:47:58.328Z", + "src": "data/src/California MPAs 2024/Data_Received/CDFW/LinearKelp_Maximum_1984_2023.shp", "propertiesToKeep": [], "explodeMulti": true } diff --git a/project/geoprocessing.json b/project/geoprocessing.json index 3545e53..bcb0588 100644 --- a/project/geoprocessing.json +++ b/project/geoprocessing.json @@ -22,10 +22,8 @@ "src/functions/boundaryAreaOverlap.ts", "src/functions/boundaryAreaOverlapWorker.ts", "src/functions/classification.ts", - "src/functions/kelpMax.ts", - "src/functions/kelpMaxWorker.ts", - "src/functions/kelpPersist.ts", - "src/functions/kelpPersistWorker.ts", + "src/functions/kelp.ts", + "src/functions/kelpWorker.ts", "src/functions/shoretypes.ts", "src/functions/shoretypesWorker.ts", "src/functions/estuaries.ts", diff --git a/project/metrics.json b/project/metrics.json index cdd6c0c..6ec5104 100644 --- a/project/metrics.json +++ b/project/metrics.json @@ -24,13 +24,13 @@ ] }, { - "metricId": "kelpMax", + "metricId": "kelp", "type": "areaOverlap", - "datasourceId": "kelpMax", "layerId": "kx7B7uIAa", "classes": [ { - "classId": "kelpMax", + "classId": "kelp", + "datasourceId": "kelp", "display": "Kelp (Maximum)" } ] @@ -156,85 +156,6 @@ } ] }, - { - "metricId": "kelpPersist", - "type": "areaOverlap", - "datasourceId": "kelpPersist", - "classes": [ - { - "classId": "1", - "classKey": "1", - "display": "1 year", - "layerId": "bRNhvDeAo" - }, - { - "classId": "2", - "classKey": "2", - "display": "2 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "3", - "classKey": "3", - "display": "3 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "4", - "classKey": "4", - "display": "4 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "5", - "classKey": "5", - "display": "5 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "6", - "classKey": "6", - "display": "6 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "7", - "classKey": "7", - "display": "7 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "8", - "classKey": "8", - "display": "8 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "9", - "classKey": "9", - "display": "9 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "10", - "classKey": "10", - "display": "10 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "11", - "classKey": "11", - "display": "11 years", - "layerId": "bRNhvDeAo" - }, - { - "classId": "12", - "classKey": "12", - "display": "12 years", - "layerId": "bRNhvDeAo" - } - ] - }, { "metricId": "bathymetry", "type": "valueOverlap", @@ -261,6 +182,11 @@ "display": "Rocky Shores", "datasourceId": "rocky_shores" }, + { + "classId": "kelp", + "display": "Kelp", + "datasourceId": "kelp" + }, { "classId": "eelgrass", "display": "Eelgrass", diff --git a/project/precalc.json b/project/precalc.json index 729867e..629da8a 100644 --- a/project/precalc.json +++ b/project/precalc.json @@ -39,14 +39,6 @@ "groupId": null, "value": 30532486.936149113 }, - { - "geographyId": "central_br", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 105906837.780095 - }, { "geographyId": "central_br", "metricId": "area", @@ -175,14 +167,6 @@ "groupId": null, "value": 68 }, - { - "geographyId": "central_br", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 84132952 - }, { "geographyId": "central_br", "metricId": "count", @@ -271,14 +255,6 @@ "groupId": null, "value": 281 }, - { - "geographyId": "central_br", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 25484182 - }, { "geographyId": "central_br", "metricId": "valid", @@ -287,110 +263,6 @@ "groupId": "band-0", "value": 1016215 }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 125235 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-1", - "sketchId": null, - "groupId": "band-0", - "value": 54259 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-10", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-11", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-12", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-2", - "sketchId": null, - "groupId": "band-0", - "value": 29565 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-3", - "sketchId": null, - "groupId": "band-0", - "value": 20123 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-4", - "sketchId": null, - "groupId": "band-0", - "value": 14589 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-5", - "sketchId": null, - "groupId": "band-0", - "value": 11121 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-6", - "sketchId": null, - "groupId": "band-0", - "value": 8539 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-7", - "sketchId": null, - "groupId": "band-0", - "value": 6522 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-8", - "sketchId": null, - "groupId": "band-0", - "value": 4070 - }, - { - "geographyId": "central_br", - "metricId": "valid", - "classId": "kelpPersist-9", - "sketchId": null, - "groupId": "band-0", - "value": 1171 - }, { "geographyId": "central_br", "metricId": "valid", @@ -527,14 +399,6 @@ "groupId": null, "value": 20396117.138282564 }, - { - "geographyId": "central_sr", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 105229460.233388 - }, { "geographyId": "central_sr", "metricId": "area", @@ -663,14 +527,6 @@ "groupId": null, "value": 55 }, - { - "geographyId": "central_sr", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 63623252 - }, { "geographyId": "central_sr", "metricId": "count", @@ -759,14 +615,6 @@ "groupId": null, "value": 228 }, - { - "geographyId": "central_sr", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 25303955 - }, { "geographyId": "central_sr", "metricId": "valid", @@ -775,110 +623,6 @@ "groupId": "band-0", "value": 752385 }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 124434 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-1", - "sketchId": null, - "groupId": "band-0", - "value": 58895 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-10", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-11", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-12", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-2", - "sketchId": null, - "groupId": "band-0", - "value": 32312 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-3", - "sketchId": null, - "groupId": "band-0", - "value": 22025 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-4", - "sketchId": null, - "groupId": "band-0", - "value": 15975 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-5", - "sketchId": null, - "groupId": "band-0", - "value": 12195 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-6", - "sketchId": null, - "groupId": "band-0", - "value": 9328 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-7", - "sketchId": null, - "groupId": "band-0", - "value": 7072 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-8", - "sketchId": null, - "groupId": "band-0", - "value": 4442 - }, - { - "geographyId": "central_sr", - "metricId": "valid", - "classId": "kelpPersist-9", - "sketchId": null, - "groupId": "band-0", - "value": 1265 - }, { "geographyId": "central_sr", "metricId": "valid", @@ -1015,14 +759,6 @@ "groupId": null, "value": 171315574.7712489 }, - { - "geographyId": "north_br", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 43385143.918491 - }, { "geographyId": "north_br", "metricId": "area", @@ -1151,14 +887,6 @@ "groupId": null, "value": 114 }, - { - "geographyId": "north_br", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 98924852 - }, { "geographyId": "north_br", "metricId": "count", @@ -1247,14 +975,6 @@ "groupId": null, "value": 181 }, - { - "geographyId": "north_br", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 15653313 - }, { "geographyId": "north_br", "metricId": "valid", @@ -1266,215 +986,111 @@ { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpMax-total", + "classId": "substrate_depth-0", "sketchId": null, "groupId": "band-0", - "value": 51303 + "value": 1362551 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-1", + "classId": "substrate_depth-1", "sketchId": null, "groupId": "band-0", - "value": 35128 + "value": 2983091 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-10", + "classId": "substrate_depth-100", "sketchId": null, "groupId": "band-0", - "value": 0 + "value": 4248 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-11", + "classId": "substrate_depth-101", "sketchId": null, "groupId": "band-0", - "value": 0 + "value": 21476 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-12", + "classId": "substrate_depth-102", "sketchId": null, "groupId": "band-0", - "value": 0 + "value": 1785934 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-2", + "classId": "substrate_depth-2", "sketchId": null, "groupId": "band-0", - "value": 10455 + "value": 13810608 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-3", + "classId": "substrate_depth-200", "sketchId": null, "groupId": "band-0", - "value": 4621 + "value": 5558 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-4", + "classId": "substrate_depth-201", "sketchId": null, "groupId": "band-0", - "value": 2150 + "value": 1993 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-5", + "classId": "substrate_depth-202", "sketchId": null, "groupId": "band-0", - "value": 905 + "value": 207968 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-6", + "classId": "substrate_depth-30", "sketchId": null, "groupId": "band-0", - "value": 315 + "value": 107207 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-7", + "classId": "substrate_depth-31", "sketchId": null, "groupId": "band-0", - "value": 60 + "value": 1815740 }, { "geographyId": "north_br", "metricId": "valid", - "classId": "kelpPersist-8", + "classId": "substrate_depth-32", "sketchId": null, "groupId": "band-0", - "value": 6 + "value": 22359035 }, { - "geographyId": "north_br", - "metricId": "valid", - "classId": "kelpPersist-9", + "geographyId": "north_sr", + "metricId": "area", + "classId": "beaches-total", "sketchId": null, - "groupId": "band-0", - "value": 0 + "groupId": null, + "value": 396966.70101520425 }, { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-0", - "sketchId": null, - "groupId": "band-0", - "value": 1362551 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-1", - "sketchId": null, - "groupId": "band-0", - "value": 2983091 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-100", - "sketchId": null, - "groupId": "band-0", - "value": 4248 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-101", - "sketchId": null, - "groupId": "band-0", - "value": 21476 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-102", - "sketchId": null, - "groupId": "band-0", - "value": 1785934 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-2", - "sketchId": null, - "groupId": "band-0", - "value": 13810608 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-200", - "sketchId": null, - "groupId": "band-0", - "value": 5558 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-201", - "sketchId": null, - "groupId": "band-0", - "value": 1993 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-202", - "sketchId": null, - "groupId": "band-0", - "value": 207968 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-30", - "sketchId": null, - "groupId": "band-0", - "value": 107207 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-31", - "sketchId": null, - "groupId": "band-0", - "value": 1815740 - }, - { - "geographyId": "north_br", - "metricId": "valid", - "classId": "substrate_depth-32", - "sketchId": null, - "groupId": "band-0", - "value": 22359035 - }, - { - "geographyId": "north_sr", - "metricId": "area", - "classId": "beaches-total", - "sketchId": null, - "groupId": null, - "value": 396966.70101520425 - }, - { - "geographyId": "north_sr", - "metricId": "area", - "classId": "clipLayer-total", + "geographyId": "north_sr", + "metricId": "area", + "classId": "clipLayer-total", "sketchId": null, "groupId": null, "value": 2657876174.4624553 @@ -1503,14 +1119,6 @@ "groupId": null, "value": 112789814.88951634 }, - { - "geographyId": "north_sr", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 16841415.533921 - }, { "geographyId": "north_sr", "metricId": "area", @@ -1639,14 +1247,6 @@ "groupId": null, "value": 90 }, - { - "geographyId": "north_sr", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 24553568 - }, { "geographyId": "north_sr", "metricId": "count", @@ -1735,14 +1335,6 @@ "groupId": null, "value": 122 }, - { - "geographyId": "north_sr", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 6116599 - }, { "geographyId": "north_sr", "metricId": "valid", @@ -1751,110 +1343,6 @@ "groupId": "band-0", "value": 1000465 }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 19915 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-1", - "sketchId": null, - "groupId": "band-0", - "value": 16758 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-10", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-11", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-12", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-2", - "sketchId": null, - "groupId": "band-0", - "value": 1986 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-3", - "sketchId": null, - "groupId": "band-0", - "value": 263 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-4", - "sketchId": null, - "groupId": "band-0", - "value": 58 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-5", - "sketchId": null, - "groupId": "band-0", - "value": 16 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-6", - "sketchId": null, - "groupId": "band-0", - "value": 3 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-7", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-8", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "north_sr", - "metricId": "valid", - "classId": "kelpPersist-9", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, { "geographyId": "north_sr", "metricId": "valid", @@ -1991,14 +1479,6 @@ "groupId": null, "value": 68662145.96285066 }, - { - "geographyId": "northcentral_sr", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 27221105.931277 - }, { "geographyId": "northcentral_sr", "metricId": "area", @@ -2127,14 +1607,6 @@ "groupId": null, "value": 37 }, - { - "geographyId": "northcentral_sr", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 28453299 - }, { "geographyId": "northcentral_sr", "metricId": "count", @@ -2223,14 +1695,6 @@ "groupId": null, "value": 112 }, - { - "geographyId": "northcentral_sr", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 9716941 - }, { "geographyId": "northcentral_sr", "metricId": "valid", @@ -2239,110 +1703,6 @@ "groupId": "band-0", "value": 587762 }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 32189 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-1", - "sketchId": null, - "groupId": "band-0", - "value": 19249 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-10", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-11", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-12", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-2", - "sketchId": null, - "groupId": "band-0", - "value": 8745 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-3", - "sketchId": null, - "groupId": "band-0", - "value": 4402 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-4", - "sketchId": null, - "groupId": "band-0", - "value": 2120 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-5", - "sketchId": null, - "groupId": "band-0", - "value": 900 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-6", - "sketchId": null, - "groupId": "band-0", - "value": 321 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-7", - "sketchId": null, - "groupId": "band-0", - "value": 61 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-8", - "sketchId": null, - "groupId": "band-0", - "value": 5 - }, - { - "geographyId": "northcentral_sr", - "metricId": "valid", - "classId": "kelpPersist-9", - "sketchId": null, - "groupId": "band-0", - "value": 0 - }, { "geographyId": "northcentral_sr", "metricId": "valid", @@ -2479,14 +1839,6 @@ "groupId": null, "value": 148740094.04058143 }, - { - "geographyId": "south_br", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 211660610.221921 - }, { "geographyId": "south_br", "metricId": "area", @@ -2618,218 +1970,98 @@ { "geographyId": "south_br", "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 82543916 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "rock_islands-total", - "sketchId": null, - "groupId": null, - "value": 145 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "rocky_shores-total", - "sketchId": null, - "groupId": null, - "value": 1714 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "shoretypes-total", - "sketchId": null, - "groupId": null, - "value": 746 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "study_regions-Central Coast", - "sketchId": null, - "groupId": null, - "value": 1 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "study_regions-North Central Coast", - "sketchId": null, - "groupId": null, - "value": 0 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "study_regions-North Coast", - "sketchId": null, - "groupId": null, - "value": 0 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "study_regions-San Francisco Bay", - "sketchId": null, - "groupId": null, - "value": 0 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "study_regions-South Coast", - "sketchId": null, - "groupId": null, - "value": 7 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "study_regions-total", - "sketchId": null, - "groupId": null, - "value": 8 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "tidal_flats-total", - "sketchId": null, - "groupId": null, - "value": 457 - }, - { - "geographyId": "south_br", - "metricId": "count", - "classId": "unclassified-total", - "sketchId": null, - "groupId": null, - "value": 1181 - }, - { - "geographyId": "south_br", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 19050312 - }, - { - "geographyId": "south_br", - "metricId": "valid", - "classId": "hab_ca-0", - "sketchId": null, - "groupId": "band-0", - "value": 1475463 - }, - { - "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 250289 - }, - { - "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-1", + "classId": "rock_islands-total", "sketchId": null, - "groupId": "band-0", - "value": 126396 + "groupId": null, + "value": 145 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-10", + "metricId": "count", + "classId": "rocky_shores-total", "sketchId": null, - "groupId": "band-0", - "value": 815 + "groupId": null, + "value": 1714 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-11", + "metricId": "count", + "classId": "shoretypes-total", "sketchId": null, - "groupId": "band-0", - "value": 184 + "groupId": null, + "value": 746 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-12", + "metricId": "count", + "classId": "study_regions-Central Coast", "sketchId": null, - "groupId": "band-0", - "value": 19 + "groupId": null, + "value": 1 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-2", + "metricId": "count", + "classId": "study_regions-North Central Coast", "sketchId": null, - "groupId": "band-0", - "value": 69922 + "groupId": null, + "value": 0 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-3", + "metricId": "count", + "classId": "study_regions-North Coast", "sketchId": null, - "groupId": "band-0", - "value": 47537 + "groupId": null, + "value": 0 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-4", + "metricId": "count", + "classId": "study_regions-San Francisco Bay", "sketchId": null, - "groupId": "band-0", - "value": 32078 + "groupId": null, + "value": 0 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-5", + "metricId": "count", + "classId": "study_regions-South Coast", "sketchId": null, - "groupId": "band-0", - "value": 22279 + "groupId": null, + "value": 7 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-6", + "metricId": "count", + "classId": "study_regions-total", "sketchId": null, - "groupId": "band-0", - "value": 14401 + "groupId": null, + "value": 8 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-7", + "metricId": "count", + "classId": "tidal_flats-total", "sketchId": null, - "groupId": "band-0", - "value": 8326 + "groupId": null, + "value": 457 }, { "geographyId": "south_br", - "metricId": "valid", - "classId": "kelpPersist-8", + "metricId": "count", + "classId": "unclassified-total", "sketchId": null, - "groupId": "band-0", - "value": 4674 + "groupId": null, + "value": 1181 }, { "geographyId": "south_br", "metricId": "valid", - "classId": "kelpPersist-9", + "classId": "hab_ca-0", "sketchId": null, "groupId": "band-0", - "value": 2227 + "value": 1475463 }, { "geographyId": "south_br", @@ -2967,14 +2199,6 @@ "groupId": null, "value": 148739456.4273119 }, - { - "geographyId": "south_sr", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 211217481.839306 - }, { "geographyId": "south_sr", "metricId": "area", @@ -3103,14 +2327,6 @@ "groupId": null, "value": 89 }, - { - "geographyId": "south_sr", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 81704056 - }, { "geographyId": "south_sr", "metricId": "count", @@ -3199,14 +2415,6 @@ "groupId": null, "value": 1178 }, - { - "geographyId": "south_sr", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 19034507 - }, { "geographyId": "south_sr", "metricId": "valid", @@ -3215,110 +2423,6 @@ "groupId": "band-0", "value": 1475463 }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 249765 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-1", - "sketchId": null, - "groupId": "band-0", - "value": 145587 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-10", - "sketchId": null, - "groupId": "band-0", - "value": 934 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-11", - "sketchId": null, - "groupId": "band-0", - "value": 212 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-12", - "sketchId": null, - "groupId": "band-0", - "value": 21 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-2", - "sketchId": null, - "groupId": "band-0", - "value": 80904 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-3", - "sketchId": null, - "groupId": "band-0", - "value": 55020 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-4", - "sketchId": null, - "groupId": "band-0", - "value": 37062 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-5", - "sketchId": null, - "groupId": "band-0", - "value": 25785 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-6", - "sketchId": null, - "groupId": "band-0", - "value": 16661 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-7", - "sketchId": null, - "groupId": "band-0", - "value": 9657 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-8", - "sketchId": null, - "groupId": "band-0", - "value": 5326 - }, - { - "geographyId": "south_sr", - "metricId": "valid", - "classId": "kelpPersist-9", - "sketchId": null, - "groupId": "band-0", - "value": 2578 - }, { "geographyId": "south_sr", "metricId": "valid", @@ -3455,14 +2559,6 @@ "groupId": null, "value": 350588170.4862 }, - { - "geographyId": "world", - "metricId": "area", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 360952591.920507 - }, { "geographyId": "world", "metricId": "area", @@ -3591,14 +2687,6 @@ "groupId": null, "value": 271 }, - { - "geographyId": "world", - "metricId": "count", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 265601720 - }, { "geographyId": "world", "metricId": "count", @@ -3687,14 +2775,6 @@ "groupId": null, "value": 1643 }, - { - "geographyId": "world", - "metricId": "sum", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 60187807 - }, { "geographyId": "world", "metricId": "valid", @@ -3703,110 +2783,6 @@ "groupId": "band-0", "value": 3816075 }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpMax-total", - "sketchId": null, - "groupId": "band-0", - "value": 426827 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-1", - "sketchId": null, - "groupId": "band-0", - "value": 240489 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-10", - "sketchId": null, - "groupId": "band-0", - "value": 934 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-11", - "sketchId": null, - "groupId": "band-0", - "value": 212 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-12", - "sketchId": null, - "groupId": "band-0", - "value": 21 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-2", - "sketchId": null, - "groupId": "band-0", - "value": 123947 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-3", - "sketchId": null, - "groupId": "band-0", - "value": 81710 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-4", - "sketchId": null, - "groupId": "band-0", - "value": 55215 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-5", - "sketchId": null, - "groupId": "band-0", - "value": 38896 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-6", - "sketchId": null, - "groupId": "band-0", - "value": 26313 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-7", - "sketchId": null, - "groupId": "band-0", - "value": 16790 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-8", - "sketchId": null, - "groupId": "band-0", - "value": 9773 - }, - { - "geographyId": "world", - "metricId": "valid", - "classId": "kelpPersist-9", - "sketchId": null, - "groupId": "band-0", - "value": 3843 - }, { "geographyId": "world", "metricId": "valid", diff --git a/src/components/KelpMax.tsx b/src/components/Kelp.tsx similarity index 71% rename from src/components/KelpMax.tsx rename to src/components/Kelp.tsx index 863e1c9..3f37bb2 100644 --- a/src/components/KelpMax.tsx +++ b/src/components/Kelp.tsx @@ -18,38 +18,34 @@ import { toPercentMetric, } from "@seasketch/geoprocessing/client-core"; import project from "../../project/projectClient.js"; -import { genSketchTable } from "../util/genSketchTable.js"; +import precalc from "../../data/precalc/precalcKelp.json"; import { GeographyTable } from "../util/GeographyTable.js"; +import { genLengthSketchTable } from "./Shoretypes.js"; const Number = new Intl.NumberFormat("en", { style: "decimal" }); /** - * KelpMax component + * Kelp component * * @param props - geographyId * @returns A react component which displays an overlap report */ -export const KelpMax: React.FunctionComponent = (props) => { +export const Kelp: React.FunctionComponent = (props) => { const { t } = useTranslation(); const [{ isCollection, id, childProperties }] = useSketchProperties(); const geographies = project.geographies; // Metrics - const metricGroup = project.getMetricGroup("kelpMax", t); - const precalcMetrics = geographies - .map((geography) => - project.getPrecalcMetrics(metricGroup, "area", geography.geographyId), - ) - .reduce((metrics, curMetrics) => metrics.concat(curMetrics), []); + const metricGroup = project.getMetricGroup("kelp", t); // Labels - const titleLabel = t("Kelp (Maximum)"); - const withinLabel = t("Area Within MPA(s)"); - const percWithinLabel = t("% Total Kelp Area"); - const unitsLabel = t("mi²"); + const titleLabel = t("Kelp"); + const withinLabel = t("Length Within MPA(s)"); + const percWithinLabel = t("% Total Kelp Length"); + const unitsLabel = t("mi"); return ( - + {(metricResults: Metric[]) => { const percMetricIdName = `${metricGroup.metricId}Perc`; @@ -57,25 +53,24 @@ export const KelpMax: React.FunctionComponent = (props) => { metricResults.filter((m) => m.metricId === metricGroup.metricId), [id], ); - const percentMetrics = toPercentMetric(valueMetrics, precalcMetrics, { + const percentMetrics = toPercentMetric(valueMetrics, precalc, { metricIdOverride: percMetricIdName, idProperty: "geographyId", }); const metrics = [...valueMetrics, ...percentMetrics]; - const objectives = (() => { - const objectives = project.getMetricGroupObjectives(metricGroup, t); - if (!objectives.length) return undefined; - else return objectives; - })(); - return ( - +

Potential kelp forest is a key habitat. This report summarizes - the overlap of the selected MPA(s) with the maximum kelp canopy - coverage over the years 2002-2016. + the overlap of the selected MPA(s) with the maximum extent of + kelp canopy between 1984 and 2023. +

+

+ The minimum extent necessary to encompass 90% of local + biodiversity in a kelp forest is 1.1 linear miles, as determined + from biological surveys.

@@ -101,11 +96,7 @@ export const KelpMax: React.FunctionComponent = (props) => { valueFormatter: (val: string | number) => Number.format( roundDecimal( - squareMeterToMile( - typeof val === "string" ? parseInt(val) : val, - ), - 2, - { keepSmallValues: true }, + typeof val === "string" ? parseInt(val) : val, ), ), colStyle: { textAlign: "center" }, @@ -135,7 +126,6 @@ export const KelpMax: React.FunctionComponent = (props) => { geographies={geographies.filter((g) => g.geographyId?.endsWith("_sr"), )} - objective={objectives} columnConfig={[ { columnLabel: "Kelp (Maximum)", @@ -149,11 +139,7 @@ export const KelpMax: React.FunctionComponent = (props) => { valueFormatter: (val: string | number) => Number.format( roundDecimal( - squareMeterToMile( - typeof val === "string" ? parseInt(val) : val, - ), - 2, - { keepSmallValues: true }, + typeof val === "string" ? parseInt(val) : val, ), ), colStyle: { textAlign: "center" }, @@ -184,7 +170,6 @@ export const KelpMax: React.FunctionComponent = (props) => { geographies={geographies.filter((g) => g.geographyId?.endsWith("_br"), )} - objective={objectives} columnConfig={[ { columnLabel: "Kelp (Maximum)", @@ -198,11 +183,7 @@ export const KelpMax: React.FunctionComponent = (props) => { valueFormatter: (val: string | number) => Number.format( roundDecimal( - squareMeterToMile( - typeof val === "string" ? parseInt(val) : val, - ), - 2, - { keepSmallValues: true }, + typeof val === "string" ? parseInt(val) : val, ), ), colStyle: { textAlign: "center" }, @@ -228,10 +209,10 @@ export const KelpMax: React.FunctionComponent = (props) => { {isCollection && ( - {genSketchTable( + {genLengthSketchTable( childProperties || [], metricResults.filter((m) => m.geographyId === "world"), - precalcMetrics.filter((m) => m.geographyId === "world"), + precalc.filter((m) => m.geographyId === "world"), metricGroup, t, )} @@ -239,25 +220,18 @@ export const KelpMax: React.FunctionComponent = (props) => { )} - -

- ℹ️ Overview: Overview: This layer shows the maximum extent of - kelp canopy based on 13 years of aerial surveys conducted - between 2002 and 2016. -

+

🗺️ Source Data: CDFW

- 📈 Report: This report calculates the total value of kelp - canopy coverage within the selected MPA(s). This value is - divided by the total value of kelp canopy coverage to obtain + 📈 Report: This report calculates the total length of maximum + linear kelp canopy within the selected MPA(s). This value is + divided by the total length of linear kelp canopy to obtain the % contained within the selected MPA(s). If the selected - area includes multiple areas that overlap, the overlap is only - counted once. Kelp data has been downsampled to a 30m x 30m - raster grid for efficiency, so area calculations are - estimates. Final reported statistics should be calculated in - Desktop GIS tools. + MPA(s) includes multiple areas that overlap, the overlap is + only counted once. Final plans should check area totals in GIS + tools before publishing final area statistics.

-

Last updated: January 24, 2025.

+

Last updated: February 3, 2025.

diff --git a/src/components/KelpPersist.tsx b/src/components/KelpPersist.tsx deleted file mode 100644 index 25341be..0000000 --- a/src/components/KelpPersist.tsx +++ /dev/null @@ -1,313 +0,0 @@ -import React from "react"; -import { Trans, useTranslation } from "react-i18next"; -import { - ClassTable, - Collapse, - LayerToggle, - ReportError, - ResultsCard, - VerticalSpacer, - useSketchProperties, -} from "@seasketch/geoprocessing/client-ui"; -import { - GeogProp, - Metric, - metricsWithSketchId, - roundDecimal, - squareMeterToMile, - toPercentMetric, -} from "@seasketch/geoprocessing/client-core"; -import project from "../../project/projectClient.js"; -import { GeographyTable } from "../util/GeographyTable.js"; -import { genSketchTable } from "../util/genSketchTable.js"; -const Number = new Intl.NumberFormat("en", { style: "decimal" }); - -/** - * KelpPersist component - * - * @param props - geographyId - * @returns A react component which displays an overlap report - */ -export const KelpPersist: React.FunctionComponent = (props) => { - const { t } = useTranslation(); - const [{ isCollection, id, childProperties }] = useSketchProperties(); - const geographies = project.geographies; - - // Metrics - const metricGroup = project.getMetricGroup("kelpPersist", t); - - // Labels - const titleLabel = t("Kelp (Persistence)"); - const withinLabel = t("Area Within MPA(s)"); - const percWithinLabel = t("% Total Kelp Area"); - const unitsLabel = t("mi²"); - - return ( - - {(metricResults: Metric[]) => { - const percMetricIdName = `${metricGroup.metricId}Perc`; - - let valueMetrics: Metric[] = []; - let precalcMetrics: Metric[] = []; - let percMetrics: Metric[] = []; - - geographies.forEach((g) => { - const vMetrics = metricsWithSketchId( - metricResults.filter( - (m) => - m.metricId === metricGroup.metricId && - m.geographyId === g.geographyId, - ), - [id], - ); - valueMetrics = valueMetrics.concat(vMetrics); - - const preMetrics = project.getPrecalcMetrics( - metricGroup, - "valid", - g.geographyId, - ); - precalcMetrics = precalcMetrics.concat(preMetrics); - - percMetrics = percMetrics.concat( - toPercentMetric(vMetrics, preMetrics, { - metricIdOverride: percMetricIdName, - }), - ); - }); - - const metrics = [...valueMetrics, ...percMetrics]; - - const objectives = (() => { - const objectives = project.getMetricGroupObjectives(metricGroup, t); - if (!objectives.length) return undefined; - else return objectives; - })(); - - return ( - -

- - Potential kelp forest is a key habitat. This report summarizes - the overlap of the selected MPA(s) with the number of years of - kelp canopy coverage between 2002-2016. - -

- - - - - m.geographyId === "world")} - metricGroup={metricGroup} - objective={objectives} - columnConfig={[ - { - columnLabel: t("Kelp Persistence"), - type: "class", - width: 30, - }, - { - columnLabel: withinLabel, - type: "metricValue", - metricId: metricGroup.metricId, - valueFormatter: (val: string | number) => - Number.format( - roundDecimal( - squareMeterToMile( - typeof val === "string" - ? parseInt(val) * - 23.21062239466359856 * - 23.21062239466359856 - : val * 23.21062239466359856 * 23.21062239466359856, - ), - 2, - { keepSmallValues: true }, - ), - ), - colStyle: { textAlign: "center" }, - valueLabel: unitsLabel, - chartOptions: { - showTitle: true, - }, - width: 30, - }, - { - columnLabel: percWithinLabel, - type: "metricChart", - metricId: percMetricIdName, - valueFormatter: "percent", - chartOptions: { - showTitle: true, - }, - width: 40, - }, - ]} - /> - - - {metricGroup.classes.map((curClass) => ( - - m.geographyId?.endsWith("_sr") && - m.classId === curClass.classId, - )} - metricGroup={metricGroup} - geographies={geographies.filter((g) => - g.geographyId.endsWith("_sr"), - )} - objective={objectives} - columnConfig={[ - { - columnLabel: t("Kelp (" + curClass.display + ")"), - type: "class", - width: 40, - }, - { - columnLabel: withinLabel, - type: "metricValue", - metricId: metricGroup.metricId, - valueFormatter: (val: string | number) => - Number.format( - roundDecimal( - squareMeterToMile( - typeof val === "string" - ? parseInt(val) * - 23.21062239466359856 * - 23.21062239466359856 - : val * - 23.21062239466359856 * - 23.21062239466359856, - ), - 2, - { keepSmallValues: true }, - ), - ), - colStyle: { textAlign: "center" }, - valueLabel: unitsLabel, - chartOptions: { - showTitle: true, - }, - width: 20, - }, - { - columnLabel: percWithinLabel, - type: "metricChart", - metricId: percMetricIdName, - valueFormatter: "percent", - chartOptions: { - showTitle: true, - }, - width: 30, - }, - ]} - /> - ))} - - - - {metricGroup.classes.map((curClass) => ( - - m.geographyId?.endsWith("_br") && - m.classId === curClass.classId, - )} - metricGroup={metricGroup} - geographies={geographies.filter((g) => - g.geographyId.endsWith("_br"), - )} - objective={objectives} - columnConfig={[ - { - columnLabel: t("Kelp (" + curClass.display + ")"), - type: "class", - width: 25, - }, - { - columnLabel: withinLabel, - type: "metricValue", - metricId: metricGroup.metricId, - valueFormatter: (val: string | number) => - Number.format( - roundDecimal( - squareMeterToMile( - typeof val === "string" - ? parseInt(val) * - 23.21062239466359856 * - 23.21062239466359856 - : val * - 23.21062239466359856 * - 23.21062239466359856, - ), - 2, - { keepSmallValues: true }, - ), - ), - colStyle: { textAlign: "center" }, - valueLabel: unitsLabel, - chartOptions: { - showTitle: true, - }, - width: 30, - }, - { - columnLabel: percWithinLabel, - type: "metricChart", - metricId: percMetricIdName, - valueFormatter: "percent", - chartOptions: { - showTitle: true, - }, - width: 30, - }, - ]} - /> - ))} - - - {isCollection && ( - - {genSketchTable( - childProperties || [], - metricResults.filter((m) => m.geographyId === "world"), - precalcMetrics.filter((m) => m.geographyId === "world"), - metricGroup, - t, - { - valueFormatter: (val) => - val * 23.21062239466359856 * 23.21062239466359856, - }, - )} - - )} - - - -

🗺️ Source Data: CDFW

-

- 📈 Report: This report calculates the total value of kelp - canopy coverage and number of years present within the - selected MPA(s). This value is divided by the total value of - kelp canopy coverage to obtain the % contained within the - selected MPA(s). If the selected area includes multiple areas - that overlap, the overlap is only counted once. Kelp data has - been downsampled to a 30 m x 30 m raster grid for efficiency, - so area calculations are estimates. Final statistics should be - calculated in desktop GIS tools. -

-

Last updated: October 29, 2024.

-
-
-
- ); - }} -
- ); -}; diff --git a/src/components/RepresentationPage.tsx b/src/components/RepresentationPage.tsx index 3c3107b..e623c7e 100644 --- a/src/components/RepresentationPage.tsx +++ b/src/components/RepresentationPage.tsx @@ -1,9 +1,8 @@ import React from "react"; -import { KelpMax } from "./KelpMax.js"; +import { Kelp } from "./Kelp.js"; import { Shoretypes } from "./Shoretypes.js"; import { Estuaries } from "./Estuaries.js"; import { Eelgrass } from "./Eelgrass.js"; -import { KelpPersist } from "./KelpPersist.js"; import { Depth } from "./Depth.js"; import { Habitat } from "./Habitat.js"; @@ -11,8 +10,7 @@ const ReportPage = () => { return ( <> - - + diff --git a/src/components/Shoretypes.tsx b/src/components/Shoretypes.tsx index dc09597..1bd1206 100644 --- a/src/components/Shoretypes.tsx +++ b/src/components/Shoretypes.tsx @@ -287,11 +287,6 @@ export const Shoretypes: React.FunctionComponent = (props) => { ); }; -const replicateMap: Record = { - beaches: 1.1, - rocky_shores: 0.55, -}; - /** * Creates "Show by Zone" report, with length + percent length * @param data data returned from lambda diff --git a/src/components/Spacing.tsx b/src/components/Spacing.tsx index 8ac80ed..58b5a5b 100644 --- a/src/components/Spacing.tsx +++ b/src/components/Spacing.tsx @@ -28,7 +28,7 @@ export const Spacing: React.FunctionComponent = (props) => { }); const spacingTitle: Record = { - kelpMax: "Kelp", + kelp: "Kelp", estuaries: "Estuary", rocky_shores: "Rocky Shore", beaches: "Beach", diff --git a/src/components/Span.tsx b/src/components/Span.tsx index d7952cd..af6f5f8 100644 --- a/src/components/Span.tsx +++ b/src/components/Span.tsx @@ -286,20 +286,17 @@ export const genLengthSketchTable = ( mg: MetricGroup, t: any, ) => { - console.log(metrics); const sketchesById = keyBy(childProperties, (sk) => sk.id); const sketchIds = childProperties.map((sk) => sk.id); const sketchMetrics = metrics.filter( (m) => m.sketchId && sketchIds.includes(m.sketchId), ); - console.log(sketchMetrics); const finalMetrics = [ ...sketchMetrics, ...toPercentMetric(sketchMetrics, precalcMetrics, { metricIdOverride: project.getMetricGroupPercId(mg), }), ]; - console.log(finalMetrics); const aggMetrics = nestMetrics(finalMetrics, [ "sketchId", diff --git a/src/functions/kelpMax.ts b/src/functions/kelp.ts similarity index 81% rename from src/functions/kelpMax.ts rename to src/functions/kelp.ts index 6d73317..b781099 100644 --- a/src/functions/kelpMax.ts +++ b/src/functions/kelp.ts @@ -16,23 +16,23 @@ import { rekeyMetrics, sortMetrics, } from "@seasketch/geoprocessing/client-core"; -import { kelpMaxWorker } from "./kelpMaxWorker.js"; import { genWorldMetrics } from "../util/genWorldMetrics.js"; +import { kelpWorker } from "./kelpWorker.js"; /** - * kelpMax: A geoprocessing function that calculates overlap metrics + * kelp: A geoprocessing function that calculates overlap metrics * @param sketch - A sketch or collection of sketches * @param extraParams * @returns Calculated metrics and a null sketch */ -export async function kelpMax( +export async function kelp( sketch: | Sketch | SketchCollection, extraParams: DefaultExtraParams = {}, request?: GeoprocessingRequestModel, ): Promise { - const metricGroup = project.getMetricGroup("kelpMax"); + const metricGroup = project.getMetricGroup("kelp"); const geographies = project.geographies.filter( (g) => g.geographyId !== "world", ); @@ -47,11 +47,11 @@ export async function kelpMax( }; return process.env.NODE_ENV === "test" - ? kelpMaxWorker(sketch, parameters) + ? kelpWorker(sketch, parameters) : runLambdaWorker( sketch, project.package.name, - "kelpMaxWorker", + "kelpWorker", project.geoprocessing.region, parameters, request!, @@ -76,13 +76,13 @@ export async function kelpMax( ); } -export default new GeoprocessingHandler(kelpMax, { - title: "kelpMax", - description: "kelpMax overlap", +export default new GeoprocessingHandler(kelp, { + title: "kelp", + description: "kelp overlap", timeout: 500, // seconds memory: 1024, // megabytes executionMode: "async", // Specify any Sketch Class form attributes that are required requiresProperties: [], - workers: ["kelpMaxWorker"], + workers: ["kelpWorker"], }); diff --git a/src/functions/kelpPersist.ts b/src/functions/kelpPersist.ts deleted file mode 100644 index 584ad2c..0000000 --- a/src/functions/kelpPersist.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { - Sketch, - SketchCollection, - Polygon, - MultiPolygon, - GeoprocessingHandler, - DefaultExtraParams, - runLambdaWorker, - parseLambdaResponse, -} from "@seasketch/geoprocessing"; -import project from "../../project/projectClient.js"; -import { - GeoprocessingRequestModel, - Metric, - ReportResult, - isMetricArray, - rekeyMetrics, - sortMetrics, - toNullSketch, -} from "@seasketch/geoprocessing/client-core"; -import { kelpPersistWorker } from "./kelpPersistWorker.js"; -import { genWorldMetrics } from "../util/genWorldMetrics.js"; - -/** - * kelpPersist: A geoprocessing function that calculates overlap metrics - * @param sketch - A sketch or collection of sketches - * @param extraParams - * @returns Calculated metrics and a null sketch - */ -export async function kelpPersist( - sketch: - | Sketch - | SketchCollection, - extraParams: DefaultExtraParams = {}, - request?: GeoprocessingRequestModel, -): Promise { - const metricGroup = project.getMetricGroup("kelpPersist"); - const geographies = project.geographies.filter( - (g) => g.geographyId !== "world", - ); - - const metrics = ( - await Promise.all( - geographies.map(async (geography) => { - const parameters = { - ...extraParams, - geography: geography, - metricGroup, - }; - - return process.env.NODE_ENV === "test" - ? kelpPersistWorker(sketch, parameters) - : runLambdaWorker( - sketch, - project.package.name, - "kelpPersistWorker", - project.geoprocessing.region, - parameters, - request!, - ); - }), - ) - ).reduce( - (metrics, result) => - metrics.concat( - isMetricArray(result) - ? result - : (parseLambdaResponse(result) as Metric[]), - ), - [], - ); - - return sortMetrics( - rekeyMetrics([ - ...metrics, - ...genWorldMetrics(sketch, metrics, metricGroup), - ]), - ); -} - -export default new GeoprocessingHandler(kelpPersist, { - title: "kelpPersist", - description: "kelpPersist overlap", - timeout: 500, // seconds - memory: 1024, // megabytes - executionMode: "async", - // Specify any Sketch Class form attributes that are required - requiresProperties: [], - workers: ["kelpPersistWorker"], -}); diff --git a/src/functions/kelpPersistSmoke.test.ts b/src/functions/kelpPersistSmoke.test.ts deleted file mode 100644 index e77e091..0000000 --- a/src/functions/kelpPersistSmoke.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @jest-environment node - * @group smoke - */ -import { - getExamplePolygonSketchAll, - writeResultOutput, -} from "@seasketch/geoprocessing/scripts/testing"; -import { describe, test, expect } from "vitest"; -import { kelpPersist } from "./kelpPersist.js"; - -describe("Basic smoke tests", () => { - test("handler function is present", () => { - expect(typeof kelpPersist).toBe("function"); - }); - test("kelpPersist - tests run against all examples", async () => { - const examples = await getExamplePolygonSketchAll(); - for (const example of examples) { - const result = await kelpPersist(example); - expect(result).toBeTruthy(); - writeResultOutput(result, "kelpPersist", example.properties.name); - } - }, 180000); -}); diff --git a/src/functions/kelpPersistWorker.ts b/src/functions/kelpPersistWorker.ts deleted file mode 100644 index ea2065d..0000000 --- a/src/functions/kelpPersistWorker.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { - Sketch, - SketchCollection, - Polygon, - MultiPolygon, - GeoprocessingHandler, - splitSketchAntimeridian, - rasterMetrics, -} from "@seasketch/geoprocessing"; -import project from "../../project/projectClient.js"; -import { - Geography, - Metric, - MetricGroup, - isRasterDatasource, -} from "@seasketch/geoprocessing/client-core"; -import { clipToGeography } from "../util/clipToGeography.js"; -import { loadCog } from "@seasketch/geoprocessing/dataproviders"; -import { bbox } from "@turf/turf"; - -/** - * substrate: A geoprocessing function that calculates overlap metrics - * @param sketch - A sketch or collection of sketches - * @param extraParams - * @returns Calculated metrics and a null sketch - */ -export async function kelpPersistWorker( - sketch: - | Sketch - | SketchCollection, - extraParams: { - geography: Geography; - metricGroup: MetricGroup; - }, -) { - const geography = extraParams.geography; - const metricGroup = extraParams.metricGroup; - - if (!metricGroup.datasourceId) - throw new Error(`Expected datasourceId for ${metricGroup.metricId}`); - - // Support sketches crossing antimeridian - const splitSketch = splitSketchAntimeridian(sketch); - - // Clip sketch to geography - const clippedSketch = await clipToGeography(splitSketch, geography); - - // Get bounding box of sketch remainder - const sketchBox = clippedSketch.bbox || bbox(clippedSketch); - - const ds = project.getDatasourceById(metricGroup.datasourceId); - if (!isRasterDatasource(ds)) - throw new Error(`Expected raster datasource for ${ds.datasourceId}`); - - const url = project.getDatasourceUrl(ds); - - // Start raster load and move on in loop while awaiting finish - const raster = await loadCog(url); - - // Start analysis when raster load finishes - const overlapResult = await rasterMetrics(raster, { - metricId: metricGroup.metricId, - feature: clippedSketch, - ...(ds.measurementType === "quantitative" && { stats: ["area"] }), - ...(ds.measurementType === "categorical" && { - categorical: true, - categoryMetricValues: metricGroup.classes.map((c) => c.classId), - }), - }); - - return overlapResult.map( - (metrics): Metric => ({ - ...metrics, - geographyId: geography.geographyId, - }), - ); -} - -export default new GeoprocessingHandler(kelpPersistWorker, { - title: "kelpPersistWorker", - description: "", - timeout: 500, // seconds - memory: 1024, // megabytes - executionMode: "sync", - // Specify any Sketch Class form attributes that are required - requiresProperties: [], -}); diff --git a/src/functions/kelpMaxSmoke.test.ts b/src/functions/kelpSmoke.test.ts similarity index 63% rename from src/functions/kelpMaxSmoke.test.ts rename to src/functions/kelpSmoke.test.ts index 9bb6b05..fdbe2c1 100644 --- a/src/functions/kelpMaxSmoke.test.ts +++ b/src/functions/kelpSmoke.test.ts @@ -7,18 +7,18 @@ import { writeResultOutput, } from "@seasketch/geoprocessing/scripts/testing"; import { describe, test, expect } from "vitest"; -import { kelpMax } from "./kelpMax.js"; +import { kelp } from "./kelp.js"; describe("Basic smoke tests", () => { test("handler function is present", () => { - expect(typeof kelpMax).toBe("function"); + expect(typeof kelp).toBe("function"); }); - test("kelpMax - tests run against all examples", async () => { + test("kelp - tests run against all examples", async () => { const examples = await getExamplePolygonSketchAll(); for (const example of examples) { - const result = await kelpMax(example); + const result = await kelp(example); expect(result).toBeTruthy(); - writeResultOutput(result, "kelpMax", example.properties.name); + writeResultOutput(result, "kelp", example.properties.name); } }, 180000); }); diff --git a/src/functions/kelpMaxWorker.ts b/src/functions/kelpWorker.ts similarity index 51% rename from src/functions/kelpMaxWorker.ts rename to src/functions/kelpWorker.ts index 32a8689..3e6148c 100644 --- a/src/functions/kelpMaxWorker.ts +++ b/src/functions/kelpWorker.ts @@ -5,8 +5,9 @@ import { MultiPolygon, GeoprocessingHandler, splitSketchAntimeridian, - isRasterDatasource, - rasterMetrics, + isVectorDatasource, + getDatasourceFeatures, + LineString, } from "@seasketch/geoprocessing"; import { bbox } from "@turf/turf"; import project from "../../project/projectClient.js"; @@ -16,15 +17,15 @@ import { MetricGroup, } from "@seasketch/geoprocessing/client-core"; import { clipToGeography } from "../util/clipToGeography.js"; -import { loadCog } from "@seasketch/geoprocessing/dataproviders"; +import { overlapLineLength } from "../util/overlapLineLength.js"; /** - * kelpMaxWorker: A geoprocessing function that calculates overlap metrics + * kelpWorker: A geoprocessing function that calculates overlap metrics * @param sketch - A sketch or collection of sketches * @param extraParams * @returns Calculated metrics and a null sketch */ -export async function kelpMaxWorker( +export async function kelpWorker( sketch: | Sketch | SketchCollection, @@ -35,50 +36,63 @@ export async function kelpMaxWorker( ) { const geography = extraParams.geography; const metricGroup = extraParams.metricGroup; - - if (!metricGroup.datasourceId) - throw new Error(`Expected datasourceId for ${metricGroup.metricId}`); + const curClass = metricGroup.classes[0]; // Support sketches crossing antimeridian const splitSketch = splitSketchAntimeridian(sketch); + if (!curClass || !curClass.datasourceId) + throw new Error(`Expected datasourceId for ${curClass}`); + // Clip sketch to geography const clippedSketch = await clipToGeography(splitSketch, geography); // Get bounding box of sketch remainder const sketchBox = clippedSketch.bbox || bbox(clippedSketch); - const ds = project.getDatasourceById(metricGroup.datasourceId); - if (!isRasterDatasource(ds)) - throw new Error(`Expected raster datasource for ${ds.datasourceId}`); + const ds = project.getDatasourceById(curClass.datasourceId); + if (!isVectorDatasource(ds)) + throw new Error(`Expected vector datasource for ${ds.datasourceId}`); const url = project.getDatasourceUrl(ds); - // Start raster load and move on in loop while awaiting finish - const raster = await loadCog(url); - - // Start analysis when raster load finishes - const overlapResult = await rasterMetrics(raster, { - metricId: metricGroup.metricId, - feature: clippedSketch, - ...(ds.measurementType === "quantitative" && { stats: ["area"] }), - ...(ds.measurementType === "categorical" && { - categorical: true, - categoryMetricValues: metricGroup.classes.map((c) => c.classId), - }), + // Fetch features overlapping with sketch, pull from cache if already fetched + const features = await getDatasourceFeatures(ds, url, { + sketch: clippedSketch, }); + // If this is a sub-class, filter by class name + const finalFeatures = + curClass.classKey && curClass.classId !== `${ds.datasourceId}_all` + ? features.filter((feat) => { + return ( + feat.geometry && + feat.properties![ds.classKeys[0]] === curClass.classId + ); + }, []) + : features; + + // Calculate overlap metrics + const overlapResult = await overlapLineLength( + metricGroup.metricId, + finalFeatures, + clippedSketch, + { + units: "miles", + }, + ); + return overlapResult.map( - (metrics): Metric => ({ - ...metrics, - classId: "kelpMax", + (metric): Metric => ({ + ...metric, + classId: curClass.classId, geographyId: geography.geographyId, }), ); } -export default new GeoprocessingHandler(kelpMaxWorker, { - title: "kelpMaxWorker", +export default new GeoprocessingHandler(kelpWorker, { + title: "kelpWorker", description: "", timeout: 500, // seconds memory: 1024, // megabytes diff --git a/src/functions/spacingWorker.ts b/src/functions/spacingWorker.ts index ecf49bc..892c745 100644 --- a/src/functions/spacingWorker.ts +++ b/src/functions/spacingWorker.ts @@ -25,8 +25,8 @@ const replicateTest: Record< string, { valueFormatter: (val: number) => number; replicateVal: number } > = { - kelpMax: { - valueFormatter: (val: number) => squareMeterToMile(val), + kelp: { + valueFormatter: (val: number) => val, replicateVal: 1.1, }, beaches: { @@ -104,9 +104,11 @@ export async function spacingWorker( }), ]; + // Overlap lines if ( extraParams.datasourceId === "beaches" || - extraParams.datasourceId === "rocky_shores" + extraParams.datasourceId === "rocky_shores" || + extraParams.datasourceId === "kelp" ) { const features = await getDatasourceFeatures(ds, url, { sketch, @@ -120,6 +122,8 @@ export async function spacingWorker( }, ); } + + // Overlap polygons const features = await getDatasourceFeatures( ds, url, diff --git a/src/util/genSketchTable.tsx b/src/util/genSketchTable.tsx index b263d8c..a851fe4 100644 --- a/src/util/genSketchTable.tsx +++ b/src/util/genSketchTable.tsx @@ -124,7 +124,6 @@ export const genSketchTable = ( (curClass, index) => { const transString = t(curClass.display); const columns = []; - if (size) { columns.push({ Header: t("Minimum") + " ".repeat(index), @@ -184,7 +183,7 @@ export const genSketchTable = ( }); return { - Header: transString, + Header: size ? " " : transString, style: { color: "#777" }, columns: columns, };