This file contains 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
""" | |
This code demonstrates how to load Digital Earth Australia Sentinel-2 Analysis Ready Data into R. | |
It uses `rstac` to search for available data for a time and location using DEA's STAC endpoint, | |
and `gdalcubes` to load and analyse the data. | |
Functionality includes: | |
* Creating a custom pixel grid to reproject data into | |
* Apply a cloud mask using the "s2cloudless" cloud mask | |
* Combine data into seasonal composites | |
* Create an RGB animation |
This file contains 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
from pystac import Item | |
from odc.stac import load | |
import rasterio | |
import odc.geo.xr | |
path = 'https://dea-public-data-dev.s3-ap-southeast-2.amazonaws.com/derivative/ga_s2ls_intertidal_cyear_3/1-0-0/x128/y165/2016--P1Y/ga_s2ls_intertidal_cyear_3_x128y165_2016--P1Y_final.stac-item.json' | |
# path = 'https://dea-public-data-dev.s3-ap-southeast-2.amazonaws.com/derivative/ga_s2ls_intertidal_cyear_3/1-0-0/x128/y165/2017--P1Y/ga_s2ls_intertidal_cyear_3_x128y165_2017--P1Y_final.stac-item.json' | |
items = [Item.from_file(path)] | |
data = load(items, chunks={}) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import s3fs | |
import pandas as pd | |
s3 = s3fs.S3FileSystem(anon=True) | |
file_list = s3.glob( | |
"dea-public-data-dev/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/*/*/2023--P1Y/ga_ls8cls9c_gm_cyear_3_*_2023--P1Y_final_nbart_red.tif" | |
) | |
pd.DataFrame(file_list).iloc[:, 0].str.replace( | |
"dea-public-data-dev/", |
This file contains 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
import glob | |
import warnings | |
import datetime | |
from odc.geo.geom import BoundingBox | |
def _load_gauge_metadata(metadata_path): | |
# Load metadata |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import otps | |
import pytz | |
def otps_tides(lats, lons, times, timezone=None): | |
""" | |
Model tide heights for one or more locations and times using the | |
OTPS TPXO8 tidal model. | |
Parameters: | |
----------- | |
lats, lons : numeric or list of numeric values |
This file contains 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
import numpy as np | |
import xarray as xr | |
def load_ls_s2( | |
x=None, | |
y=None, | |
geom=None, | |
start_date="2020", | |
end_date="2021", |
This file contains 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
# Source: https://www.arcgis.com/home/item.html?id=d5354dea41b14f0689860bf4b2cf5e8a | |
# 2*(M2+S2+K1+O1) | |
(0.01 * 2 * ( | |
xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/m2.nc") | |
+ xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/s2.nc") | |
+ xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/k1.nc") | |
+ xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/o1.nc") | |
)).amplitude.odc.assign_crs("EPSG:4326").plot() |
This file contains 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
import pandas as pd | |
import sys | |
sys.path.insert(1, '../Tools/') | |
from dea_tools.coastal import model_tides, tidal_tag, pixel_tides, tidal_stats | |
# Set of times to model tides for | |
date_list = pd.date_range(start="2022-09-01", end="2022-09-30", freq="1H") | |
# Run TPXO8 |
NewerOlder