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
| # Code via David Gavin | |
| import datacube | |
| # Connect to standard database for Sentinel 2 ARD | |
| dc = datacube.Datacube() | |
| # Set up a custom config to access s2tsmask database | |
| config = {'db_hostname': 'test.test.org.au', | |
| 'db_port': 1234, |
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
| # Code via Alex Leith | |
| from matplotlib.colors import LightSource | |
| import matplotlib.pyplot as plt | |
| # Sample elevation array | |
| elevation = data_cube.elevation.isel(time=0).values | |
| # Create hillsahde based on the array | |
| ls = LightSource(azdeg=315, altdeg=45) |
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
| import seaborn as sns | |
| import pandas as pd | |
| # Create test data | |
| pard_std_df = pd.DataFrame(data=[['Burdekin', 'Midshelf', 0.6, 0.5, 0.4], | |
| ['Burdekin', 'Offshore', 0.3, 0.5, 0.8], | |
| ['Burdekin', 'Coastal', 0.2, 0.4, 0.9], | |
| ['Fitzroy', 'Midshelf', 0.6, 0.5, 0.4], | |
| ['Fitzroy', 'Offshore', 0.3, 0.5, 0.8], | |
| ['Fitzroy', 'Coastal', 0.1, 0.2, 0.3]], |
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
| library(rayshader) | |
| library(magrittr) | |
| library(raster) | |
| library(lubridate) | |
| library(dplyr) | |
| smooth_sequence = function(from=0, to=1, cycles=2, n=180) { | |
| #' Produces a smooth sequence of any length between two values |
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
| # Source: https://bitbucket.org/kirill-ga/wofs-summary/src/0f1e4284085e2a65bd7a0b9fdb00e0f65c36f713/kk/wofs_summary/_wofs_stats.py?utm_term=file&utm_source=bb-slack&utm_medium=referral-external&atlOrigin=eyJpIjoiMWRiZjlmZjhkYmE3NDg0Mzk3NWI3ODZhZjczNGQyODQiLCJwIjoiYmItY2hhdHMtaW50ZWdyYXRpb24ifQ#lines-114:136 | |
| def wofs_stats(xx): | |
| attrs = {'crs': xx.crs} | |
| xx_wet = make_mask(xx.water, wet=True).sum(dim='time', dtype='int16') | |
| xx_dry = make_mask(xx.water, dry=True).sum(dim='time', dtype='int16') | |
| xx_clear = xx_wet + xx_dry | |
| xx_freq = xx_wet.astype('float32')/xx_clear |
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
| ds, = dc.find_datasets(product='ga_ls5t_ard_3', limit=1) | |
| dir(ds.metadata) |
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
| def time_index_from_filenames(filenames, string_slice=slice(0, 10)): | |
| ''' | |
| Helper function to generate a Pandas datetimeindex object | |
| from dates contained in a file path string | |
| ''' | |
| date_strings = [os.path.basename(i)[string_slice] for i in filenames] | |
| return pd.to_datetime(date_strings) |
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
| # Code from Kirill Kouzoubov, Digital Earth Australia | |
| import xarray as xr | |
| import datacube | |
| def from_xr_to_dc(xx): | |
| crs = xx.data_vars.get('crs') | |
| if crs is None: | |
| print('no crs var') | |
| return xx | |
| crs = crs.attrs.get('crs_wkt', None) |
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
| # Set up parameters to load Hotspots data | |
| from_date = '2020-01-27' | |
| to_date = '2020-02-12' | |
| y_max = -35.38 | |
| x_min = 148.68 | |
| y_min = -36.02 | |
| x_max = 149.32 | |
| min_confidence = 0 # minimum confidence value of hotspots to load from WFS | |
| max_features = 900000 # maximum features to load from WFS |
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
| # Code adapted from original by Andrew Hicks | |
| import numpy as np | |
| import datacube | |
| from datacube.api.query import query_group_by | |
| from datacube.model.utils import xr_apply | |
| dc = datacube.Datacube(app='Metadata') | |
| # Spatiotemporal query | |
| query = dict(product='ga_ls8c_ard_3', |