{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Change the units of `edge_size`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this tutorial we will learn how to change the units of `edge_size`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import cubo" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default, the units of `edge_size` are pixels:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/dmontero/anaconda3/envs/cubo/lib/python3.9/site-packages/stackstac/prepare.py:364: UserWarning: The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n", " times = pd.to_datetime(\n" ] }, { "data": { "text/html": [ "
<xarray.DataArray 'sentinel-2-l2a' (time: 2, band: 3, y: 64, x: 64)>\n",
"dask.array<fetch_raster_window, shape=(2, 3, 64, 64), dtype=float64, chunksize=(1, 1, 64, 64), chunktype=numpy.ndarray>\n",
"Coordinates: (12/47)\n",
" * time (time) datetime64[ns] 2021-06-13...\n",
" id (time) <U54 'S2B_MSIL2A_20210613...\n",
" * band (band) <U3 'B02' 'B03' 'B04'\n",
" * x (x) float64 6.011e+05 ... 6.023e+05\n",
" * y (y) float64 5.66e+06 ... 5.659e+06\n",
" s2:water_percentage (time) float64 0.1445 0.1281\n",
" ... ...\n",
" title (band) <U20 'Band 2 - Blue - 10m...\n",
" common_name (band) <U5 'blue' 'green' 'red'\n",
" center_wavelength (band) float64 0.49 0.56 0.665\n",
" full_width_half_max (band) float64 0.098 0.045 0.038\n",
" epsg int64 32632\n",
" cubo:distance_from_center (y, x) float64 908.2 ... 873.7\n",
"Attributes:\n",
" collection: sentinel-2-l2a\n",
" stac: https://planetarycomputer.microsoft.com/api/stac/v1\n",
" epsg: 32632\n",
" resolution: 20\n",
" edge_size: 64\n",
" edge_size_m: 1280\n",
" central_lat: 51.079225\n",
" central_lon: 10.452173\n",
" central_y: 5659638.0946523\n",
" central_x: 601722.4825156148\n",
" time_coverage_start: 2021-06-01\n",
" time_coverage_end: 2021-07-01<xarray.DataArray 'sentinel-2-l2a' (time: 2, band: 3, y: 64, x: 64)>\n",
"dask.array<fetch_raster_window, shape=(2, 3, 64, 64), dtype=float64, chunksize=(1, 1, 64, 64), chunktype=numpy.ndarray>\n",
"Coordinates: (12/47)\n",
" * time (time) datetime64[ns] 2021-06-13...\n",
" id (time) <U54 'S2B_MSIL2A_20210613...\n",
" * band (band) <U3 'B02' 'B03' 'B04'\n",
" * x (x) float64 6.011e+05 ... 6.023e+05\n",
" * y (y) float64 5.66e+06 ... 5.659e+06\n",
" s2:water_percentage (time) float64 0.1445 0.1281\n",
" ... ...\n",
" title (band) <U20 'Band 2 - Blue - 10m...\n",
" common_name (band) <U5 'blue' 'green' 'red'\n",
" center_wavelength (band) float64 0.49 0.56 0.665\n",
" full_width_half_max (band) float64 0.098 0.045 0.038\n",
" epsg int64 32632\n",
" cubo:distance_from_center (y, x) float64 908.2 ... 873.7\n",
"Attributes:\n",
" collection: sentinel-2-l2a\n",
" stac: https://planetarycomputer.microsoft.com/api/stac/v1\n",
" epsg: 32632\n",
" resolution: 20\n",
" edge_size: 64\n",
" edge_size_m: 1280\n",
" central_lat: 51.079225\n",
" central_lon: 10.452173\n",
" central_y: 5659638.0946523\n",
" central_x: 601722.4825156148\n",
" time_coverage_start: 2021-06-01\n",
" time_coverage_end: 2021-07-01"
],
"text/plain": [
"<xarray.DataArray 'sentinel-2-l2a' (time: 2, band: 3, y: 76, x: 76)>\n",
"dask.array<fetch_raster_window, shape=(2, 3, 76, 76), dtype=float64, chunksize=(1, 1, 76, 76), chunktype=numpy.ndarray>\n",
"Coordinates: (12/47)\n",
" * time (time) datetime64[ns] 2021-06-13...\n",
" id (time) <U54 'S2B_MSIL2A_20210613...\n",
" * band (band) <U3 'B02' 'B03' 'B04'\n",
" * x (x) float64 6.01e+05 ... 6.025e+05\n",
" * y (y) float64 5.66e+06 ... 5.659e+06\n",
" s2:water_percentage (time) float64 0.1445 0.1281\n",
" ... ...\n",
" title (band) <U20 'Band 2 - Blue - 10m...\n",
" common_name (band) <U5 'blue' 'green' 'red'\n",
" center_wavelength (band) float64 0.49 0.56 0.665\n",
" full_width_half_max (band) float64 0.098 0.045 0.038\n",
" epsg int64 32632\n",
" cubo:distance_from_center (y, x) float64 1.078e+03 ... 1.0...\n",
"Attributes:\n",
" collection: sentinel-2-l2a\n",
" stac: https://planetarycomputer.microsoft.com/api/stac/v1\n",
" epsg: 32632\n",
" resolution: 20\n",
" edge_size: 76\n",
" edge_size_m: 1520\n",
" central_lat: 51.079225\n",
" central_lon: 10.452173\n",
" central_y: 5659638.0946523\n",
" central_x: 601722.4825156148\n",
" time_coverage_start: 2021-06-01\n",
" time_coverage_end: 2021-07-01"
],
"text/plain": [
"<xarray.DataArray 'sentinel-2-l2a' (time: 2, band: 3, y: 142, x: 142)>\n",
"dask.array<fetch_raster_window, shape=(2, 3, 142, 142), dtype=float64, chunksize=(1, 1, 142, 142), chunktype=numpy.ndarray>\n",
"Coordinates: (12/47)\n",
" * time (time) datetime64[ns] 2021-06-13...\n",
" id (time) <U54 'S2B_MSIL2A_20210613...\n",
" * band (band) <U3 'B02' 'B03' 'B04'\n",
" * x (x) float64 6.003e+05 ... 6.031e+05\n",
" * y (y) float64 5.661e+06 ... 5.658e+06\n",
" s2:water_percentage (time) float64 0.1445 0.1281\n",
" ... ...\n",
" title (band) <U20 'Band 2 - Blue - 10m...\n",
" common_name (band) <U5 'blue' 'green' 'red'\n",
" center_wavelength (band) float64 0.49 0.56 0.665\n",
" full_width_half_max (band) float64 0.098 0.045 0.038\n",
" epsg int64 32632\n",
" cubo:distance_from_center (y, x) float64 2.011e+03 ... 1.9...\n",
"Attributes:\n",
" collection: sentinel-2-l2a\n",
" stac: https://planetarycomputer.microsoft.com/api/stac/v1\n",
" epsg: 32632\n",
" resolution: 20\n",
" edge_size: 142\n",
" edge_size_m: 2840\n",
" central_lat: 51.079225\n",
" central_lon: 10.452173\n",
" central_y: 5659638.0946523\n",
" central_x: 601722.4825156148\n",
" time_coverage_start: 2021-06-01\n",
" time_coverage_end: 2021-07-01"
],
"text/plain": [
"