Last active
May 15, 2023 22:08
-
-
Save schwehr/63e45d036e971bb4a353ddde889492a8 to your computer and use it in GitHub Desktop.
USGS rcmap manifests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "projects/ee-rcmap/assets/RCMAP_V5_TRENDS/TRENDS", | |
| "tilesets": [ | |
| { | |
| "id": "annual_herbaceous_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_annual_herbaceous_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "bare_ground_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_bare_ground_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "herbaceous_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_herbaceous_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "litter_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_litter_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "sagebrush_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_sagebrush_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "shrub_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_shrub_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_non_sagebrush_shrub_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "perennial_herbaceous_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_perennial_herbaceous_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "tree_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_tree_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "annual_herbaceous_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_annual_herbaceous_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "bare_ground_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_bare_ground_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "herbaceous_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_herbaceous_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "litter_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_litter_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "sagebrush_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_sagebrush_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "shrub_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_shrub_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_non_sagebrush_shrub_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "perennial_herbaceous_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_perennial_herbaceous_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "tree_linear_model_slope", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_tree_linear_model_slope.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "annual_herbaceous_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_annual_herbaceous_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "bare_ground_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_bare_ground_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "herbaceous_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_herbaceous_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "litter_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_litter_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "sagebrush_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_sagebrush_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "shrub_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_shrub_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_non_sagebrush_shrub_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "perennial_herbaceous_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_perennial_herbaceous_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "tree_linear_model_pvalue", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_tree_linear_model_pvalue.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "annual_herbaceous_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_annual_herbaceous_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "bare_ground_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_bare_ground_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "herbaceous_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_herbaceous_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "litter_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_litter_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "sagebrush_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_sagebrush_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "shrub_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_shrub_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_non_sagebrush_shrub_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "perennial_herbaceous_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_perennial_herbaceous_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "tree_most_recent_break_point", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_tree_most_recent_break_point.tif" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "total_change_intensity_index", | |
| "sources": [ | |
| { | |
| "uris": "gs://ee-nlcd-upload/rcmap_total_change_intensity_index.tif" | |
| } | |
| ] | |
| } | |
| ], | |
| "bands": [ | |
| { | |
| "id": "annual_herbaceous_break_point", | |
| "tilesetId": "annual_herbaceous_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "bare_ground_break_point", | |
| "tilesetId": "bare_ground_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "herbaceous_break_point", | |
| "tilesetId": "herbaceous_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "litter_break_point", | |
| "tilesetId": "litter_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "sagebrush_break_point", | |
| "tilesetId": "sagebrush_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "shrub_break_point", | |
| "tilesetId": "shrub_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_break_point", | |
| "tilesetId": "non_sagebrush_shrub_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "perennial_herbaceous_break_point", | |
| "tilesetId": "perennial_herbaceous_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "tree_break_point", | |
| "tilesetId": "tree_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "annual_herbaceous_linear_model_slope", | |
| "tilesetId": "annual_herbaceous_linear_model_slope" | |
| }, | |
| { | |
| "id": "bare_ground_linear_model_slope", | |
| "tilesetId": "bare_ground_linear_model_slope" | |
| }, | |
| { | |
| "id": "herbaceous_linear_model_slope", | |
| "tilesetId": "herbaceous_linear_model_slope" | |
| }, | |
| { | |
| "id": "litter_linear_model_slope", | |
| "tilesetId": "litter_linear_model_slope" | |
| }, | |
| { | |
| "id": "sagebrush_linear_model_slope", | |
| "tilesetId": "sagebrush_linear_model_slope" | |
| }, | |
| { | |
| "id": "shrub_linear_model_slope", | |
| "tilesetId": "shrub_linear_model_slope" | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_linear_model_slope", | |
| "tilesetId": "non_sagebrush_shrub_linear_model_slope" | |
| }, | |
| { | |
| "id": "perennial_herbaceous_linear_model_slope", | |
| "tilesetId": "perennial_herbaceous_linear_model_slope" | |
| }, | |
| { | |
| "id": "tree_linear_model_slope", | |
| "tilesetId": "tree_linear_model_slope" | |
| }, | |
| { | |
| "id": "annual_herbaceous_linear_model_pvalue", | |
| "tilesetId": "annual_herbaceous_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "bare_ground_linear_model_pvalue", | |
| "tilesetId": "bare_ground_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "herbaceous_linear_model_pvalue", | |
| "tilesetId": "herbaceous_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "litter_linear_model_pvalue", | |
| "tilesetId": "litter_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "sagebrush_linear_model_pvalue", | |
| "tilesetId": "sagebrush_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "shrub_linear_model_pvalue", | |
| "tilesetId": "shrub_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_linear_model_pvalue", | |
| "tilesetId": "non_sagebrush_shrub_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "perennial_herbaceous_linear_model_pvalue", | |
| "tilesetId": "perennial_herbaceous_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "tree_linear_model_pvalue", | |
| "tilesetId": "tree_linear_model_pvalue" | |
| }, | |
| { | |
| "id": "annual_herbaceous_most_recent_break_point", | |
| "tilesetId": "annual_herbaceous_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "bare_ground_most_recent_break_point", | |
| "tilesetId": "bare_ground_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "herbaceous_most_recent_break_point", | |
| "tilesetId": "herbaceous_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "litter_most_recent_break_point", | |
| "tilesetId": "litter_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "sagebrush_most_recent_break_point", | |
| "tilesetId": "sagebrush_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "shrub_most_recent_break_point", | |
| "tilesetId": "shrub_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "non_sagebrush_shrub_most_recent_break_point", | |
| "tilesetId": "non_sagebrush_shrub_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "perennial_herbaceous_most_recent_break_point", | |
| "tilesetId": "perennial_herbaceous_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "tree_most_recent_break_point", | |
| "tilesetId": "tree_most_recent_break_point", | |
| "pyramidingPolicy": "mode" | |
| }, | |
| { | |
| "id": "total_change_intensity_index", | |
| "tilesetId": "total_change_intensity_index" | |
| } | |
| ], | |
| "startTime": "1985-01-01T00:00:00Z", | |
| "endTime": "2022-01-01T00:00:00Z" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # Copyright 2023 Google Inc. All Rights Reserved. | |
| """ | |
| USGS RCMAP Manifest generation. | |
| gs://ee-nlcd-upload | |
| var trends = ee.Image('projects/ee-rcmap/assets/RCMAP_V5_TRENDS/TRENDS'); | |
| var dataset = ee.ImageCollection('projects/ee-rcmap/assets/RCMAP_V5_TRENDS/YEAR'); | |
| print(dataset); | |
| """ | |
| import json | |
| BASE_ID = 'projects/ee-rcmap/assets/RCMAP_V5_TRENDS/' | |
| BUCKET = 'gs://ee-nlcd-upload/rcmap_' | |
| MODE = 'mode' | |
| MEAN = 'mean' | |
| STATS_NON_YEAR = [ | |
| ['break_point', MODE], | |
| ['linear_model_slope', MEAN], | |
| ['linear_model_pvalue', MEAN], | |
| ['most_recent_break_point', MODE]] | |
| # total_change_intensity_index is the band name too - MEAN | |
| TOTAL_CHANGE_INTENSITY_INDEX = 'total_change_intensity_index' | |
| def trends() -> dict[str, object]: | |
| """Returns a manifest structure.""" | |
| tilesets = [] | |
| for stat, unused_averaging in STATS_NON_YEAR: | |
| for land in LAND_TYPES: | |
| name = f'{land}_{stat}' | |
| tilesets.append({ | |
| 'id': name, | |
| 'sources': [{'uris': BUCKET + name + '.tif'}]}) | |
| tilesets.append({ | |
| 'id': TOTAL_CHANGE_INTENSITY_INDEX, | |
| 'sources': [{'uris': BUCKET + TOTAL_CHANGE_INTENSITY_INDEX + '.tif'}]}) | |
| bands = [] | |
| for stat, averaging in STATS_NON_YEAR: | |
| for land in LAND_TYPES: | |
| name = f'{land}_{stat}' | |
| entry = {'id': name, 'tilesetId': name} | |
| if averaging == MODE: | |
| entry['pyramidingPolicy'] = MODE | |
| bands.append(entry) | |
| bands.append({ | |
| 'id': TOTAL_CHANGE_INTENSITY_INDEX, | |
| 'tilesetId': TOTAL_CHANGE_INTENSITY_INDEX, | |
| }) | |
| result = { | |
| 'name': BASE_ID + 'TRENDS', | |
| 'tilesets': tilesets, | |
| 'bands': bands, | |
| 'startTime': '1985-01-01T00:00:00Z', | |
| 'endTime': '2022-01-01T00:00:00Z', | |
| } | |
| return result | |
| LAND_TYPES = [ | |
| 'annual_herbaceous', 'bare_ground', 'herbaceous', 'litter', 'sagebrush', | |
| 'shrub', 'non_sagebrush_shrub', 'perennial_herbaceous', 'tree', | |
| ] | |
| STAT_TYPES = ['break_point', 'segment_pvalue', 'segment_slope'] | |
| def yearly(year: int) -> dict[str, object]: | |
| """Returns a manifest structure.""" | |
| tilesets = [] | |
| for stat_type in STAT_TYPES: | |
| for land_type in LAND_TYPES: | |
| name = f'{land_type}_{stat_type}' | |
| path = f'{BUCKET}{land_type}_{stat_type}_{year}.tif' | |
| tilesets.append({'id': name, 'sources': [{'uris': [path]}]}) | |
| bands = [] | |
| for stat in STAT_TYPES: | |
| for land in LAND_TYPES: | |
| name = f'{land}_{stat}' | |
| entry = {'id': name, 'tilesetId': name} | |
| bands.append(entry) | |
| result = { | |
| 'name': f'{BASE_ID}YEAR/{year}', | |
| 'tilesets': tilesets, | |
| 'bands': bands, | |
| 'startTime': f'{year}-01-01T00:00:00Z', | |
| 'endTime': f'{year+1}-01-01T00:00:00Z', | |
| } | |
| return result | |
| def main(): | |
| trends_json = json.dumps(trends(), indent=2) | |
| print(trends_json) | |
| with open('rcmap_trends_manifest.json', 'w') as out: | |
| out.write(trends_json) | |
| print('\n\n========================\n\n') | |
| print(json.dumps(yearly(2021), indent=2)) | |
| for year in range(1985, 2022): | |
| yearly_json = json.dumps(yearly(year), indent=2) | |
| with open(f'rcmap_{year}_manifest.json', 'w') as out: | |
| out.write(yearly_json) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment