<jupyter_start><jupyter_text>Getting Started with Open DatacubeThis notebook describe:1. How to query the datacube2. How to plot data of every image band3. How to save and read a Netcdf file.4. Hot to save into a geotif (this require a 2 dimention image), probably you have to remove the time dimention.<jupyter_code># Display the matplotlib plots in the notebook
%matplotlib inline

# Supress the warning in a notebook so that they 
# are not displayed when running cells.
import warnings
warnings.filterwarnings('ignore')
warnings.filterwarnings(action='ignore')

import numpy as np
np.seterr('ignore')

# Common imports
from algorithms.common import save_netcdf, read_netcdf, save_geotiff
import xarray as xr
import datacube<jupyter_output><empty_output><jupyter_text>Query the datacube<jupyter_code>dc = datacube.Datacube(app="Query")

xarr = dc.load(
    product="LS8_OLI_LASRC",
    latitude=(3,4),
    longitude=(-70, -69), 
    # Time format YYYY-MM-DD
    time=("2018-01-01","2018-12-31"), 
    measurements=['blue','green','red']
)

xarr<jupyter_output><empty_output><jupyter_text>Plot a single band data<jupyter_code>xarr.blue.plot()<jupyter_output><empty_output><jupyter_text>Save dataset into a netcdf and read<jupyter_code>save_netcdf(xarr,'data.nc')
read_netcdf('data.nc')<jupyter_output><empty_output><jupyter_text>Save into a geotiff<jupyter_code># As every data array (band) has 3 dimentions, we remove the time 
# dimention so it can be saved into the netcdf
# this works only when the dataset has 1 slice of time.
for band in xarr.data_vars.keys():
    xarr[band] = np.squeeze(xarr[band],0)
save_geotiff(xarr,'xarr10.tif')<jupyter_output>/usr/local/lib/python3.6/dist-packages/datacube/utils/__init__.py:223: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  return numpy.asscalar(res), numpy.asscalar(off)
/usr/local/lib/python3.6/dist-packages/datacube/utils/__init__.py:223: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  return numpy.asscalar(res), numpy.asscalar(off)
/usr/local/lib/python3.6/dist-packages/datacube/utils/__init__.py:223: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  return numpy.asscalar(res), numpy.asscalar(off)
/usr/local/lib/python3.6/dist-packages/datacube/utils/__init__.py:223: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  return numpy.asscalar(res), numpy.asscalar(off)
/usr/local/lib/python3.6/dist-packages/datacube/utils/__init__.py:223: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
[...]
{'fraction_non_alphanumeric': 0.11791212917761923, 'fraction_numerical': 0.02741269245212167, 'mean_word_length': 5.7272727272727275, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '391551', 'license': 'MIT', 'n_tokens_mistral': 1001, 'n_tokens_neox': 957, 'n_words': 229, 'path': 'version_1.6.1/notebooks/examples/1. Query.ipynb', 'repo_name': 'DonAurelio/open-datacube-workshop', 'size': '2663'}