Skip to content

Instantly share code, notes, and snippets.

@schwehr
Last active February 10, 2021 16:55
Show Gist options
  • Save schwehr/b72a7c7dad9edc10ea9ebc987c5620f1 to your computer and use it in GitHub Desktop.
Save schwehr/b72a7c7dad9edc10ea9ebc987c5620f1 to your computer and use it in GitHub Desktop.
STAC jsonnet Prototype / demonstration of using jsonnet to build STAC json for Google Earth Engine. These files likely have issues. The goal is to show what it might look like to have the source-of-truth (sot) for a STAC catalog be in jsonnet.

Experimentation with jsonnet with the goal of generating Earth Engine STAC json files from templates.

Running the files

The files can be used directly from the command line. e.g. using 000-hello-world.jsonnet

{
  hello: 'world',  // → {"hello": "world"}
}
sudo apt-get install jsonnet

jsonnet hello-world.jsonnet

The output to stdout will be:

{
   "hello": "world"
}
// Original JSON output from Earth Engine works as jsonnet input.
// Shows that an existing STAC json catalog can be switched to jsonnet
// by just renaming the files from .json to .jsonnet.
//
// Generates a STAC Collection JSON file.
{
"stac_version": "1.0.0-beta.2",
"stac_extensions": [
"scientific",
"version"
],
"id": "FAO/GHG/1/DROSE_A",
"title": "Drained Organic Soils Emissions (Annual)",
"version": "1.0",
"gee:type": "image_collection",
"description": "The two related FAO datasets on Drained Organic Soils provide estimates of:\n\n1. DROSA-A: area of Organic Soils (in hectares) drained for agricultural activities (cropland and grazed grassland)\n\n2. DROSE-A: carbon (C) and nitrous oxide (N2O) estimates (in gigagrams) from the agricultural drainage of\norganic soils under these land uses.\n\nAnnual data are available at 0.0083333 X 0.0083333 resolution (~1 km at the equator), with global coverage\nfor the period 1992 - 2018.\n\nFAOSTAT estimates follow the Intergovernmental Panel on Climate Change Guidelines\n(IPCC) and use histosols as proxy for the presence of organic soils and annual land cover maps as time-\ndependent component. Additionally, soils characteristics, land use, and climate information are applied\nin the analysis. The carbon emissions can be converted to CO2, multiplying pixel values by the ratio of\nthe molecular weight of carbon dioxide (CO2) to that of C (44/12).\n\nOrganic soils develop in wet soil ecosystems. They include tropical and boreal peatlands, high-latitude\nbogs, ferns, and mires. Organic soils cover globally a mere 3 percent of the terrestrial land area but\nrepresent up to 30 percent of the total soil carbon, thus playing an important role in maintaining the\nearth\u2019s carbon balance. Agriculture is a major cause of drainage of organic soils around the world.\nDrainage exposes to aerobic conditions the organic matter of organic soils that oxidizes releasing large\namounts of harmful greenhouse gases (GHG) to the atmosphere.\n\nDROSA-A and DROSE-A are the basis for country and regional statistics on drained organic soils\ndisseminated in three FAOSTAT datasets (Cultivation of Organic Soils; Cropland; and Grassland).\n",
"license": "proprietary",
"links": [
{
"rel": "self",
"href": "https://earthengine-stac.storage.googleapis.com/catalog/FAO_GHG_1_DROSE_A.json"
},
{
"rel": "parent",
"href": "https://earthengine-stac.storage.googleapis.com/catalog/catalog.json"
},
{
"rel": "root",
"href": "https://earthengine-stac.storage.googleapis.com/catalog/catalog.json"
},
{
"rel": "preview",
"href": "https://mw1.google.com/ges/dd/images/FAO_GHG_1_sample.png"
},
{
"rel": "license",
"href": "https://developers.google.com/earth-engine/datasets/catalog/FAO_GHG_1_DROSE_A#terms-of-use"
},
{
"rel": "cite-as",
"href": "https://doi.org/10.5194/essd"
}
],
"keywords": [
"Agriculture",
"Climate_change",
"Emissions",
"FAO",
"GHG",
"Organic_soils"
],
"providers": [
{
"name": "FAO UN",
"roles": [
"producer",
"licensor"
],
"url": "http://fao.org/economic/ess/environment/data/organic-soils/la/"
},
{
"name": "Google Earth Engine",
"roles": [
"host"
],
"url": "https://developers.google.com/earth-engine/datasets/catalog/FAO_GHG_1_DROSE_A"
}
],
"extent": {
"spatial": {
"bbox": [
[
-180,
-90,
180,
90
]
]
},
"temporal": {
"interval": [
[
"1992-01-01T00:00:00Z",
null
]
]
}
},
"properties": {
"gsd": 928,
"eo:bands": [
{
"name": "croplandc",
"description": "C emissions from cropland organic soils",
"gee:unit": "gigagrams"
},
{
"name": "croplandn2o",
"description": "N2O emissions from cropland organic soils",
"gee:unit": "gigagrams"
},
{
"name": "grasslandc",
"description": "C emissions from grassland organic soils",
"gee:unit": "gigagrams"
},
{
"name": "grasslandn2o",
"description": "N2O emissions from grassland organic soils",
"gee:unit": "gigagrams"
}
],
"gee:cadence": "year",
"gee:terms_of_use": "The Food and Agriculture Organization of the United Nations (FAO) is mandated to collect, analyze,\ninterpret, and disseminate information related to nutrition, food, and agriculture. In this regard,\nit publishes a number of databases on topics related to FAO's mandate, and encourages the use of\nthem for scientific and research purposes. Consistent with the principles of openness and sharing\nenvisioned under the Open Data Licensing For Statistical Databases, and consistent with the mandate\nof FAO, data on GHG emissions from agriculture activities on organic soils as part of FAOSTAT\n- FAO's database on Food and Agriculture data, is available free to the user community.\n",
"gee:visualizations": [
{
"display_name": "Cropland C emissions (Annual)",
"lookat": {
"lat": -0.4,
"lon": 108.0,
"zoom": 6
},
"image_visualization": {
"global_vis": {
"min": [
0.1
],
"max": [
0.1
],
"palette": [
"yellow",
"red"
],
"bands": [
"croplandc"
]
}
}
}
]
},
"sci:citation": "[FAO 2020. Drained organic soils 1990 - 2019. Global, regional and country trends. FAOSTAT Analytical Brief Series No 4, FAO, Rome.](http://www.fao.org/3/cb0489en/cb0489en.pdf)",
"sci:publications": [
{
"citation": "Conchedda, G. and Tubiello, F. N.: Drainage of organic soils and GHG emissions: Validation with country data, Earth Syst. Sci. Data Discuss.[doi:10.5194/essd-2020-202](https://doi.org/10.5194/essd-2020-202), in review, 2020",
"doi": "10.5194/essd"
}
]
}
// Same as FAO_GHG_1_DROSE_A_0.jsonnet, except:
// - Removed unnecessary quotes
// - Convert " to '
//
// Generates a STAC Collection JSON file.
{
stac_version: '1.0.0-beta.2',
stac_extensions: [
'scientific',
'version'
],
id: 'FAO/GHG/1/DROSE_A',
title: 'Drained Organic Soils Emissions (Annual)',
version: '1.0',
'gee:type': 'image_collection',
description: 'The two related FAO datasets on Drained Organic Soils provide estimates of:\n\n1. DROSA-A: area of Organic Soils (in hectares) drained for agricultural activities (cropland and grazed grassland)\n\n2. DROSE-A: carbon (C) and nitrous oxide (N2O) estimates (in gigagrams) from the agricultural drainage of\norganic soils under these land uses.\n\nAnnual data are available at 0.0083333 X 0.0083333 resolution (~1 km at the equator), with global coverage\nfor the period 1992 - 2018.\n\nFAOSTAT estimates follow the Intergovernmental Panel on Climate Change Guidelines\n(IPCC) and use histosols as proxy for the presence of organic soils and annual land cover maps as time-\ndependent component. Additionally, soils characteristics, land use, and climate information are applied\nin the analysis. The carbon emissions can be converted to CO2, multiplying pixel values by the ratio of\nthe molecular weight of carbon dioxide (CO2) to that of C (44/12).\n\nOrganic soils develop in wet soil ecosystems. They include tropical and boreal peatlands, high-latitude\nbogs, ferns, and mires. Organic soils cover globally a mere 3 percent of the terrestrial land area but\nrepresent up to 30 percent of the total soil carbon, thus playing an important role in maintaining the\nearth\u2019s carbon balance. Agriculture is a major cause of drainage of organic soils around the world.\nDrainage exposes to aerobic conditions the organic matter of organic soils that oxidizes releasing large\namounts of harmful greenhouse gases (GHG) to the atmosphere.\n\nDROSA-A and DROSE-A are the basis for country and regional statistics on drained organic soils\ndisseminated in three FAOSTAT datasets (Cultivation of Organic Soils; Cropland; and Grassland).\n',
license: 'proprietary',
links: [
{
rel: 'self',
href: 'https://earthengine-stac.storage.googleapis.com/catalog/FAO_GHG_1_DROSE_A.json'
},
{
rel: 'parent',
href: 'https://earthengine-stac.storage.googleapis.com/catalog/catalog.json'
},
{
rel: 'root',
href: 'https://earthengine-stac.storage.googleapis.com/catalog/catalog.json'
},
{
rel: 'preview',
href: 'https://mw1.google.com/ges/dd/images/FAO_GHG_1_sample.png'
},
{
rel: 'license',
href: 'https://developers.google.com/earth-engine/datasets/catalog/FAO_GHG_1_DROSE_A#terms-of-use'
},
{
rel: 'cite-as',
href: 'https://doi.org/10.5194/essd'
}
],
keywords: [
'Agriculture',
'Climate_change',
'Emissions',
'FAO',
'GHG',
'Organic_soils'
],
providers: [
{
name: 'FAO UN',
roles: [
'producer',
'licensor'
],
url: 'http://fao.org/economic/ess/environment/data/organic-soils/la/'
},
{
name: 'Google Earth Engine',
roles: [
'host'
],
url: 'https://developers.google.com/earth-engine/datasets/catalog/FAO_GHG_1_DROSE_A'
}
],
extent: {
spatial: {
bbox: [
[
-180,
-90,
180,
90
]
]
},
temporal: {
interval: [
[
'1992-01-01T00:00:00Z',
null
]
]
}
},
properties: {
gsd: 928,
'eo:bands': [
{
name: 'croplandc',
description: 'C emissions from cropland organic soils',
'gee:unit': 'gigagrams'
},
{
name: 'croplandn2o',
description: 'N2O emissions from cropland organic soils',
'gee:unit': 'gigagrams'
},
{
name: 'grasslandc',
description: 'C emissions from grassland organic soils',
'gee:unit': 'gigagrams'
},
{
name: 'grasslandn2o',
description: 'N2O emissions from grassland organic soils',
'gee:unit': 'gigagrams'
}
],
'gee:cadence': 'year',
'gee:terms_of_use': 'The Food and Agriculture Organization of the United Nations (FAO) is mandated to collect, analyze,\ninterpret, and disseminate information related to nutrition, food, and agriculture. In this regard,\nit publishes a number of databases on topics related to FAO\'s mandate, and encourages the use of\nthem for scientific and research purposes. Consistent with the principles of openness and sharing\nenvisioned under the Open Data Licensing For Statistical Databases, and consistent with the mandate\nof FAO, data on GHG emissions from agriculture activities on organic soils as part of FAOSTAT\n- FAO\'s database on Food and Agriculture data, is available free to the user community.\n',
'gee:visualizations': [
{
display_name: 'Cropland C emissions (Annual)',
lookat: {
lat: -0.4,
lon: 108.0,
zoom: 6
},
image_visualization: {
global_vis: {
min: [
0.1
],
max: [
0.1
],
palette: [
'yellow',
'red'
],
bands: [
'croplandc'
]
}
}
}
]
},
'sci:citation': '[FAO 2020. Drained organic soils 1990 - 2019. Global, regional and country trends. FAOSTAT Analytical Brief Series No 4, FAO, Rome.](http://www.fao.org/3/cb0489en/cb0489en.pdf)',
'sci:publications': [
{
citation: 'Conchedda, G. and Tubiello, F. N.: Drainage of organic soils and GHG emissions: Validation with country data, Earth Syst. Sci. Data Discuss.[doi:10.5194/essd-2020-202](https://doi.org/10.5194/essd-2020-202), in review, 2020',
doi: '10.5194/essd'
}
]
}
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Demonstrate templating for multiple outputs that are similar.
// Generates 4 STAC Collection JSON files for Earth Engine ImageCollections.
local stac_const = import "stac_const.libsonnet";
local stac = import "stac_lib.libsonnet";
// Constants specific to NOAA GOES and FDC Fire/Hot Spot
local noaa_fdc_url =
'https://data.noaa.gov/dataset/dataset/' +
'noaa-goes-r-series-advanced-baseline-imager-abi-level-2' +
'-fire-hot-spot-characterization-fdc';
local goes_keywords = [
'abi',
'climate',
'goes',
'nesdis',
'noaa',
'ospo',
];
local fdc_keywords = goes_keywords + [
'fdc',
'fire',
'hotspot',
'wildfire'
];
local sat_info = {
'16': { region: 'goes-east', letter: 'goes-r'},
'17': { region: 'goes-west', letter: 'goes-s'},
};
// local sat_region = { '16': 'goes-east', '17': 'goes-west' };
// local sat_letter = { '16': 'goes-r', '17': 'goes-s' };
local start_16 = '2017-05-24T00:00:00Z';
local start_17 = '2018-08-27T00:00:00Z';
local extents = {
FDCC_16: stac.extent(-152.11, 14.0, -49.18, 56.77, start_16, null),
FDCF_16: stac.extent_global(start_16, null),
FDCC_17: stac.extent(-180, 14.57, 180, 53.51, start_17, null),
FDCF_17: stac.extent_global(start_17, null),
};
local primary_doi = '10.1175/BAMS';
local goes_id(sat, product) = 'NOAA/GOES/'+ sat +'/' + product;
// Primary template.
local goes_fdc_template(sat, product) = {
local basename = 'NOAA_GOES_' + sat + '_' + product,
local basefilename = basename + '.json',
local self_ee_catalog_url = stac_const.ee_catalog_url + basename,
local self_url = stac_const.catalog_base + basefilename,
local sample_url = stac_const.sample_url(basename),
local gcs_bucket = 'gcp-public-data-goes-' + sat,
local gcs_path = stac_const.gcs_base + gcs_bucket + '/ABI-L2-' + product,
id: goes_id(sat, product),
'gee:type': 'image_collection',
stac_version: stac_const.stac_version,
stac_extensions: ['scientific'],
title: 'GOES-' + sat + ' ' + product + ' Series ABI Level 2 Fire/Hot Spot',
description: |||
[GOES](https://www.goes.noaa.gov) satellites are geostationary weather
satellites run by NOAA.
The Fire (HSC) product contains four images: one in the form of a fire
mask and the other three with pixel values identifying fire temperature,
fire area, and fire radiative power.
The ABI L2+ FHS metadata mask assigns a flag to every earth-navigated
pixel that indicates its disposition with respect to the FHS
algorithm. Operational users who have the lowest tolerance for false
alarms should focus on the "processed" and "saturated" categories (mask
codes 10, 11, 30, and 31), but within these categories there can still
be false alarms.
[README](https://www.ncdc.noaa.gov/data-access/satellite-data/goes-r-series-satellites#FDC)
NOAA provides the following scripts for suggested categories, color
maps, and visualizations:
- [GOES-16-17_FireDetection.js](https://github.com/google/earthengine-community/blob/master/datasets/scripts/GOES-16-17_FireDetection.js)
- [GOES-16-17_FireReclassification.js](https://github.com/google/earthengine-community/blob/master/datasets/scripts/GOES-16-17_FireReclassification.js)
|||,
// TODO(schwehr): Can we use https://spdx.org/licenses/CC0-1.0.html for GOES?
license: 'proprietary',
links: [
{rel: 'self', href: self_url},
{rel: 'parent', href: stac_const.catalog_url},
{rel: 'root', href: stac_const.catalog_url},
{rel: 'preview', href: sample_url},
{rel: 'license', href: self_ee_catalog_url + '#terms-of-use'},
{rel: 'source', href: gcs_path},
{rel: 'cite-as', href: stac.doi_url(primary_doi)}
],
local this_sat = sat_info[std.toString(sat)],
keywords: fdc_keywords + [
'goes-' + sat,
this_sat['letter'],
this_sat['region'],
],
providers: [
stac.producer_provider('NOAA', noaa_fdc_url),
stac.host_provider(self_ee_catalog_url),
],
extent: extents[product + '_' + std.toString(sat)],
properties: {
gsd: 2000.0,
'eo:bands': [
{
name: 'Area',
description: 'Fire area',
'gee:unit': 'm^2',
'gee:scale': 60.98,
'gee:offset': 4000.0
},
{
name: 'Mask',
description: |||
Fire mask categories. Pixel values in the fire mask image identify a
fire category and diagnostic information associated with algorithm
execution. The six fire categories include: Good quality or temporally
filtered good quality fire pixel; Saturated fire pixel or temporally
filtered saturated fire pixel; Cloud contaminated or temporally
filtered cloud contaminated fire pixel; High probability or temporally
filtered high probability fire pixel; Medium probability or temporally
filtered high probability fire pixel; Low probability or temporally
filtered high probability fire. Temporally filtered fire pixels are
those resulting from fire pixels that are in close proximity in both
space and time.
|||,
'gee:classes': [
stac.class_entry(10, 'red', 'Processed fire'),
stac.class_entry(11, 'white', 'Saturated fire'),
// [SNIP]
stac.class_entry(35, 'darkblue', 'Low probability fire, filtered'),
]
},
// SNIP
],
'gee:cadence': 'minutes',
'gee:terms_of_use': 'NOAA data, information, and products, [SNIP]',
'gee:visualizations': [
{
display_name: 'Data Quality Flags (DQF)',
lookat: { lon: -75.0, zoom: 3 },
image_visualization: { /* SNIP */ }
}
],
},
'sci:citation': 'Early characterization of the active [SNIP]',
'sci:publications': [
{
citation: 'Schmit, T., Griffith, P., et al, (2016), A [SNIP]',
doi: '10.1175/BAMS'
}
],
summaries: {
Area: stac.stats_obj(0, 16723, true),
Temp: stac.stats_obj(0, 32642, true),
Power: stac.stats_obj(0, 200000, false),
DQF: stac.stats_obj(0, 5, false),
},
};
// Generate the files.
{
['NOAA_GOES_' + sat + '_' + product + '.json']: goes_fdc_template(sat, product)
for sat in [16, 17]
for product in ['FDCC', 'FDCF']
}
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Demonstrate templating for multiple outputs that are similar - tables.
// Generates 2 STAC Collection JSON files for Earth Engine FeatureCollections.
local stac_const = import "stac_const.libsonnet";
local stac = import "stac_lib.libsonnet";
local basin_info = {
'atlantic': {
description: 'Atlantic basin 1851-2018.',
source: 'https://www.nhc.noaa.gov/data/hurdat/hurdat2-1851-2018-051019.txt',
extent: stac.extent(
-109.5, 7.2, 63.0, 81.0, '1851-06-25T00:00:00Z', '2018-11-04T12:00:00Z')
},
'pacific': {
description: 'Pacific basin 1949-2018.',
source:
'https://www.nhc.noaa.gov/data/hurdat/hurdat2-nepac-1949-2018-071519.txt',
extent: stac.extent(
-180.0, 0.4, 180.0, 63.1, '1949-06-11T00:00:00Z', '2018-11-09T00:00:00Z'),
}
};
local noaa_nhc_hurdat2(basin) = {
local id = 'NOAA/NHC/HURDAT2/atlantic',
local basename = std.strReplace(id, '/', '_'),
local basefilename = basename + '.json',
local self_ee_catalog_url = stac_const.ee_catalog_url + basename,
local self_url = stac_const.catalog_base + basefilename,
local sample_url = stac_const.sample_url(basename),
local info = basin_info[basin],
id: id,
stac_version: stac_const.stac_version,
stac_extensions: ['version'],
version: '2019-05-10',
'gee:type': 'table',
description:
'Hurricane best track database (HURDAT2).\n\n' + info['description'],
license: 'proprietary',
links: [
{rel: 'self', href: self_url},
{rel: 'parent', href: stac_const.catalog_url},
{rel: 'root', href: stac_const.catalog_url},
{rel: 'preview', href: sample_url},
{rel: 'license', href: self_ee_catalog_url + '#terms-of-use'},
{rel: 'source', href: info['source']},
],
keywords: [
basin,
'hurricane',
'nhc',
'noaa',
'weather'
],
providers: [
stac.producer_provider('NOAA NHC', 'https://www.nhc.noaa.gov/data/'),
stac.host_provider(self_ee_catalog_url),
],
extent: info['extent'],
properties: {
'gee:schema': {
seq: stac.schema_entry(
'ATCF cyclone number for that year', stac_const.DOUBLE),
datetime: stac.schema_entry(
'Observation time in UTC. Format is YYYY-MM-DDTHH:MM:SS.\n',
stac_const.STRING),
// SNIP
},
'gee:terms_of_use': |||
NOAA data, information, and products, regardless of the method of
delivery, are not subject to copyright and carry no restrictions on their
subsequent\nuse by the public. Once obtained, they may be put to any
lawful use.
|||,
'gee:visualizations': [
{
display_name: 'Hurricane locations',
lookat: {lat: 36.0, lon: -53.0, zoom: 3},
table_visualization: {color: 'black', point_size: 1}
}
]
},
summaries: {
// Demo assert fail for min > max.
// garbarge: stac.stats_obj(9999, 1, true),
seq: stac.stats_obj(1.0, 31.0, true),
max_wind_kts: stac.stats_obj(10.0, 185.0, true),
// SNIP
year: stac.stats_obj(1851.0, 2018.0, false),
}
};
// Generate the files.
{
['NOAA_NHC_HURDAT2_' + basin + '.json']: noaa_nhc_hurdat2(basin)
for basin in ['atlantic', 'pacific']
}
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Constants used in Earth Engine jsonnet to build STAC json.
{
stac_version: '1.0.0-beta.2',
// Earth Engine human readable catalog
ee_catalog_url:
'https://developers.google.com/earth-engine/datasets/catalog/',
// STAC Catalog
catalog_base: 'https://earthengine-stac.storage.googleapis.com/catalog/',
catalog_url: self.catalog_base + 'catalog.json',
image_base_url: 'https://mw1.google.com/ges/dd/images/',
sample_url(basename): self.image_base_url + basename + '_sample.png',
gcs_base: 'https://console.cloud.google.com/storage/browser/',
// Schema types.
DOUBLE: 'DOUBLE',
STRING: 'STRING',
INT: 'INT',
}
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Things to make generating STAC json with jsonnet easier or at least more compact.
// There is a lot of work required to make these of more general use to the
// STAC community.
{
producer_provider(name, url):
{ name: name, roles: ['producer', 'licensor'], url: url },
host_provider(ee_catalog_url):
{ name: 'Google Earth Engine', roles: ['host'], url: ee_catalog_url },
link(_rel, _href):: { rel: _rel, href: _href },
doi_url(doi):: 'https://doi.org/' + doi,
extent(xmin, ymin, xmax, ymax, start, end):: {
spatial: { bbox: [[xmin, ymin, xmax, ymax]] },
temporal: { interval: [[start, end]] },
},
extent_global(start, end):: {
spatial: { bbox: [[-180, -90, 180, 90]] },
temporal: { interval: [[start, end]] },
},
// Enumerated entries in gee:class.
class_entry(val, col, des):: {
assert std.isNumber(val) :
'class_entry 1st parameter should be a number, got ' + std.type(val),
assert std.isString(col) :
'class_entry 2nd parameter should be a string, got ' + std.type(col),
assert std.isString(des) :
'class_entry 3rd parameter should be a string, got ' + std.type(des),
value: val,
color: col,
description: des,
},
// Statistics objects in summaries.
stats_obj(_min, _max, est):: {
assert std.isNumber(_min) :
'stats_obj 1st parameter should be a number, got ' + std.type(_min),
assert std.isNumber(_max) :
'stats_obj 2nd parameter should be a number, got ' + std.type(_max),
assert _min <= _max:
'stats_obj must have min <= max',
assert std.isBoolean(est) :
'stats_obj 3rd parameter should be a number, got ' + std.type(est),
min: _min,
max: _max,
'gee:estimated_range': est,
},
schema_entry(description, type):: {
assert std.isString(description) :
'schema_entry 1st parameter should be a string, got ' +
std.type(description),
assert std.isString(type) :
'schema_entry 2nd parameter should be a string, got ' +
std.type(type),
description: description,
type: type
},
}
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Demonstrate using jsonnet refactoring of a single Earth Engine Image asset.
// Generates a STAC Collection JSON file.
//
// This file was generated from a yaml definition plus a CSV file defining the class values.
local stac_const = import "stac_const.libsonnet";
local stac = import "stac_lib.libsonnet";
{
local year = 2011,
local id = 'USGS/GAP/CONUS/' + year,
local basename = std.strReplace(id, '/', '_'),
local basefilename = basename + '.json',
local self_ee_catalog_url = stac_const.ee_catalog_url + basename,
local self_url = stac_const.catalog_base + basefilename,
local sample_url = stac_const.sample_url(basename),
// TODO(schwehr): Broken?
// local doi = '10.14358/PERS.81.5.345',
id: id,
stac_version: stac_const.stac_version,
stac_extensions: [
'scientific',
'version'
],
title: std.strReplace(id, '/', ' '),
version: '2012',
'gee:type': 'image',
description: |||
The GAP/LANDFIRE National Terrestrial Ecosystems data represents a detailed
vegetation and land cover classification for the Conterminous U.S., Alaska,
Hawaii, and Puerto Rico.GAP/LF 2011 Ecosystems for the Conterminous U.S. is
an update of the National Gap Analysis Program Land Cover Data - Version
2.2. Alaska ecosystems have been updated by LANDFIRE to 2012 conditions
(LANDFIRE 2012). Hawaii and Puerto Rico data represent the 2001 time-frame
(Gon et al. 2006, Gould et al. 2008). The classification scheme used for
the Alaska and the lower 48 states is based on NatureServe\u2019s Ecological
System Classification (Comer et al. 2003), while Puerto Rico and
Hawaii\u2019s map legend are based on island specific classification systems
(Gon et al. 2006, Gould et al. 2008).
|||,
license: 'proprietary',
links: [
{rel: 'self', href: self_url},
{rel: 'parent', href: stac_const.catalog_url},
{rel: 'root', href: stac_const.catalog_url},
{rel: 'preview', href: sample_url},
{rel: 'license', href: self_ee_catalog_url + '#terms-of-use'},
// {rel: 'cite-as', href: stac.doi_url(doi)}
],
keywords: [
'gap',
'landcover',
'landfire',
'usgs',
'vegetation'
],
providers: [
stac.producer_provider('USGS', 'http://gapanalysis.usgs.gov/gaplandcover/'),
stac.host_provider(self_ee_catalog_url),
],
extent: stac.extent(
-127.98, 22.79, -65.27, 52.57,
'2011-01-01T00:00:00Z', '2012-01-01T00:00:00Z'),
properties: {
gsd: 30.0,
'eo:bands': [
{
name: 'landcover',
description: 'Landcover class descriptions',
'gee:classes': [
stac.class_entry(1, '00847d', 'South Florida Bayhead Swamp'),
stac.class_entry(2, '00847d', 'South Florida Cypress Dome'),
stac.class_entry(3, '00847d', 'South Florida Dwarf Cypress Savanna'),
// SNIP
stac.class_entry(128, '266d00', 'Crowley\'s Ridge Mesic Loess Slope Forest'),
// SNIP
stac.class_entry(583, 'c94c41', 'Developed, Medium Intensity'),
stac.class_entry(584, 'c94c41', 'Developed, High Intensity'),
]
}
],
'gee:terms_of_use': |||
Most U.S. Geological Survey (USGS) information resides in the public
domain and may be used without restriction. Additional information on
[Acknowledging or Crediting USGS as Information Source](https://www.usgs.gov/information-policies-and-instructions/crediting-usgs)
is available.
|||,
'gee:visualizations': [{
display_name: 'GAP CONUS',
lookat: {lat: 38.14, lon: -98.58, zoom: 4},
image_visualization: {
band_vis: {min: [1.0], max: [584.0], bands: ['landcover']}
}
}]
},
'sci:citation': |||
Homer, C.G., Dewitz, J.A., Yang, L., Jin, S., Danielson, P., Xian, G.,
Coulston, J., Herold, N.D., Wickham, J.D., and Megown, K., 2015,
Completion of the 2011 National Land Cover Database for the conterminous
United States-Representing a decade of land cover change information.
Photogrammetric Engineering and Remote Sensing, v. 81, no. 5, p. 345-354.
http://www.asprs.org/a/publications/pers/2015journals/PERS_May_2015/HTML/index.html
|||,
summaries: {
landcover: {
min: 1.0,
max: 584.0,
'gee:estimated_range': false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment