Skip to content

Instantly share code, notes, and snippets.

View emileten's full-sized avatar

Emile Tenezakis emileten

  • Development Seed
  • Seoul, Korea
View GitHub Profile
@emileten
emileten / count_items_in_collection_pystac.py
Created April 27, 2023 02:52
count_items_in_collection_pystac
from pystac_client import Client
CATALOG_URL = '' # Replace with your catalog URL
COLLECTION_ID = '' # Replace with your collection ID
# Create a client to connect to the catalog
client = Client.open(CATALOG_URL)
for collection in client.get_all_collections():
print(f'Collection ID: {collection.id}')
@emileten
emileten / rrequest-python-lambda-construct
Created April 13, 2023 00:30
request-python-lambda-construct
#!/usr/bin/env python3
from aws_cdk import aws_lambda, Stack, App
import aws_cdk.aws_lambda_python_alpha as aws_lambda_python
class LambdaStack(Stack):
def __init__(self, app, construct_id, **kwargs) -> None:
super().__init__(app, construct_id, **kwargs)
self.construct_id = construct_id
def python_lambda(name, directory, **kwargs):
return aws_lambda_python.PythonFunction(
@emileten
emileten / collection-example.json
Created April 10, 2023 22:03
collection-example
{
"id": "ESACCI_Biomass_L4_AGB_V3_100m_2018",
"links":[],
"item_assets":{},
"stac_version": "1.0.0",
"license": "ESA CCI Data Policy: free and open access",
"title": "ESA CCI above-ground biomass product level 4, year 2018",
"type": "Collection",
"description": "This dataset comprises estimates of forest above-ground biomass for the years 2010, 2017 and 2018. They are derived from a combination of Earth observation data, depending on the year, from the Copernicus Sentinel-1 mission, Envisat’s ASAR instrument and JAXA’s Advanced Land Observing Satellite (ALOS-1 and ALOS-2), along with additional information from Earth observation sources. The data has been produced as part of the European Space Agency's (ESA's) Climate Change Initiative (CCI) programme by the Biomass CCI team.",
"extent": {
@emileten
emileten / use-pypgstac.py
Created April 10, 2023 22:01
use-pypgstac
"""Utilities to bulk load data into pgstac from json/ndjson."""
import logging
from pypgstac.load import Loader as BaseLoader
logger = logging.getLogger(__name__)
from typing import Dict
from pypgstac.load import Methods
from stac_pydantic import Collection
from pypgstac.db import PgstacDB
@emileten
emileten / example_collection.json
Created April 5, 2023 06:07
example collection
{
"id": "AfriSAR_AGB_Maps_1681",
"stac_version": "1.0.0",
"links": [],
"license": "not-provided",
"title": "AfriSAR: Aboveground Biomass for Lope, Mabounie, Mondah, and Rabi Sites, Gabon",
"type": "Collection",
"description": "This dataset provides gridded estimates of aboveground biomass (AGB) for four sites in Gabon at 0.25 ha (50 m) resolution derived with field measurements and airborne LiDAR data collected from 2010 to 2016. The sites represent a mix of forested, savannah, and some agricultural and disturbed landcover types: Lope site, within Lope National Park; Mabounie, mostly forested site; Mondah Forest, protected area; and the Rabi forest site, part of the Smithsonian Institution of Global Earth Observatories world-wide network of forest plots. Plot-level biophysical measurements of tree diameter and tree height (or estimated by allometry) were performed at 1 ha and 0.25 ha scales on multiple plots at each site and used to derive AGB for each tree and then summed for each plot. Aerial
@emileten
emileten / cli_mfa_auth_aws.sh
Last active March 31, 2023 08:39
cli_mfa_auth_aws
# set ARN_MFA_DEVICE to the ARN of the MFA device associated with your SMCE account.
# and AWS_PROFILE to your AWS credentials profile associated with the SMCE MAAP account (in ~/.aws/credentials)
# first argument (positional) of this function is the MFA code that is displayed by your MFA app at the moment
# you run the function (e.g. Google Auth)
mfa_authentication_smce_maap () {
export AWS_PROFILE="YOUR_SMCE_MAAP_PROFILE"
export ARN_MFA_DEVICE="ARN_OF_MFA_DEVICE"
tokens=$(aws sts get-session-token --serial-number $ARN_MFA_DEVICE --token-code $1 --output json)
@emileten
emileten / explore-sentinel1-rtc.ipynb
Created March 15, 2023 10:01
explore-sentinel1-rtc
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@emileten
emileten / sentinel1-rtc-exploration.yaml
Created March 15, 2023 09:59
sentinel1-rtc-exploration-environment
name: explore-sentinel1-rtc
channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- ipykernel
- pip
- pip:
- stackstac
@emileten
emileten / stackstac_dupl_coords.ipynb
Created March 10, 2023 07:52
stackstac returns xarray data array with duplicated time coordinates
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@emileten
emileten / some_notebook.ipynb
Last active March 10, 2023 00:38
some-notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.