Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RichardScottOZ/956019db57361a071f73d37192e9c690 to your computer and use it in GitHub Desktop.
Save RichardScottOZ/956019db57361a071f73d37192e9c690 to your computer and use it in GitHub Desktop.
using stackstac with NASA HLS S30 catalog
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "becoming-church",
"metadata": {},
"outputs": [],
"source": [
"#!/opt/conda/envs/py_geo/bin/pip3 install stackstac"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "angry-executive",
"metadata": {},
"outputs": [],
"source": [
"# from dask.distributed import LocalCluster, Client\n",
"# import dask\n",
"import os\n",
"env = dict(GDAL_DISABLE_READDIR_ON_OPEN='EMPTY_DIR', \n",
" AWS_NO_SIGN_REQUEST='YES',\n",
" GDAL_MAX_RAW_BLOCK_CACHE_SIZE='200000000',\n",
" GDAL_SWATH_SIZE='200000000',\n",
" VSI_CURL_CACHE_SIZE='200000000',\n",
" GDAL_HTTP_COOKIEFILE=os.path.expanduser('~/cookies.txt'),\n",
" GDAL_HTTP_COOKIEJAR=os.path.expanduser('~/cookies.txt'))\n",
"\n",
"\n",
"os.environ.update(env)\n",
" \n",
"# dask.config.set({'distributed.dashboard.link':'/proxy/{port}/status'})\n",
"# cluster = LocalCluster(threads_per_worker=1)\n",
"# cl = Client(cluster)\n",
"# cl"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "computational-noise",
"metadata": {},
"outputs": [],
"source": [
"from satsearch import Search\n",
"def get_STAC_items(url, collection, dates, bbox):\n",
" results = Search.search(url=url,\n",
" collections=collection, \n",
" datetime=dates,\n",
" bbox=bbox)\n",
"\n",
" return(results)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "radical-intensity",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"51"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url = 'https://cmr.earthdata.nasa.gov/stac/LPCLOUD/' \n",
"collection = ['HLSS30.v1.5']#'C1711924822-LPCLOUD' #HLS\n",
"bbox=[-104.79107047, 40.78311181, -104.67687336, 40.87008987]\n",
"dates = '2013-01-01/2021-03-01'\n",
"\n",
"stac_items_hls = get_STAC_items(url,collection,dates,','.join(map(str, bbox))).items()\n",
"s_col = stac_items_hls.geojson()['features']\n",
"\n",
"## Note HLSS30.v1.5 is missing the 'type' tag in the assets - add it back in\n",
"for i,f in enumerate(s_col):\n",
" for b in ['B8A', 'B08', 'B09', 'B04', 'B12', 'B02', 'B06', 'B11', 'B07', 'B05', 'B03', 'Fmask', 'B01', 'B10']:\n",
" try:\n",
" s_col[i]['assets'][b]['type']='image/tiff; application=geotiff; profile=cloud-optimized'\n",
" except:\n",
" pass\n",
" for b in ['SAA','SZA','VAA','VZA','browse','metadata']:\n",
" try:\n",
" del s_col[i]['assets'][b]\n",
" except:\n",
" pass\n",
"len(stac_items_hls)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "received-boost",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'https://lpdaac.earthdata.nasa.gov/lp-prod-protected/HLSS30.015/HLS.S30.T13TEF.2020192T174909.v1.5.B01.tif'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s_col[0]['assets']['B01']['href']"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "multiple-industry",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Driver: GTiff/GeoTIFF\n",
"Files: /vsicurl/https://lpdaac.earthdata.nasa.gov/lp-prod-protected/HLSS30.015/HLS.S30.T13TEF.2020192T174909.v1.5.B01.tif\n",
"Size is 3660, 3660\n",
"Coordinate System is:\n",
"PROJCRS[\"UTM Zone 13, Northern Hemisphere\",\n",
" BASEGEOGCRS[\"Unknown datum based upon the WGS 84 ellipsoid\",\n",
" DATUM[\"Not_specified_based_on_WGS_84_spheroid\",\n",
" ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n",
" LENGTHUNIT[\"metre\",1],\n",
" ID[\"EPSG\",7030]]],\n",
" PRIMEM[\"Greenwich\",0,\n",
" ANGLEUNIT[\"degree\",0.0174532925199433,\n",
" ID[\"EPSG\",9122]]]],\n",
" CONVERSION[\"Transverse Mercator\",\n",
" METHOD[\"Transverse Mercator\",\n",
" ID[\"EPSG\",9807]],\n",
" PARAMETER[\"Latitude of natural origin\",0,\n",
" ANGLEUNIT[\"degree\",0.0174532925199433],\n",
" ID[\"EPSG\",8801]],\n",
" PARAMETER[\"Longitude of natural origin\",-105,\n",
" ANGLEUNIT[\"degree\",0.0174532925199433],\n",
" ID[\"EPSG\",8802]],\n",
" PARAMETER[\"Scale factor at natural origin\",0.9996,\n",
" SCALEUNIT[\"unity\",1],\n",
" ID[\"EPSG\",8805]],\n",
" PARAMETER[\"False easting\",500000,\n",
" LENGTHUNIT[\"metre\",1],\n",
" ID[\"EPSG\",8806]],\n",
" PARAMETER[\"False northing\",0,\n",
" LENGTHUNIT[\"metre\",1],\n",
" ID[\"EPSG\",8807]]],\n",
" CS[Cartesian,2],\n",
" AXIS[\"easting\",east,\n",
" ORDER[1],\n",
" LENGTHUNIT[\"metre\",1,\n",
" ID[\"EPSG\",9001]]],\n",
" AXIS[\"northing\",north,\n",
" ORDER[2],\n",
" LENGTHUNIT[\"metre\",1,\n",
" ID[\"EPSG\",9001]]]]\n",
"Data axis to CRS axis mapping: 1,2\n",
"Origin = (499980.000000000000000,4600020.000000000000000)\n",
"Pixel Size = (30.000000000000000,-30.000000000000000)\n",
"Metadata:\n",
" ACCODE=LaSRC\n",
" add_offset=0.0\n",
" AREA_OR_POINT=Area\n",
" arop_ave_xshift(meters)=0\n",
" arop_ave_yshift(meters)=0\n",
" arop_ncp=0\n",
" arop_rmse(meters)=0\n",
" arop_s2_refimg=NONE\n",
" cloud_coverage=2\n",
" DATASTRIP_ID=S2B_OPER_MSI_L1C_DS_EPAE_20200710T213436_S20200710T175549_N02.09\n",
" HLS_PROCESSING_TIME=2020-08-26T10:42:16Z\n",
" HORIZONTAL_CS_CODE=EPSG:32613\n",
" HORIZONTAL_CS_NAME=WGS84 / UTM zone 13N\n",
" L1C_IMAGE_QUALITY=NONE\n",
" L1_PROCESSING_TIME=2020-07-10T22:07:35.514709Z\n",
" long_name=Coastal_Aerosol\n",
" MEAN_SUN_AZIMUTH_ANGLE=141.512151037981\n",
" MEAN_SUN_ZENITH_ANGLE=22.8485611602836\n",
" MEAN_VIEW_AZIMUTH_ANGLE=284.447540146177\n",
" MEAN_VIEW_ZENITH_ANGLE=8.19597510827437\n",
" MSI band 01 bandpass adjustment slope and offset=0.995900, -0.000200\n",
" MSI band 02 bandpass adjustment slope and offset=0.977800, -0.004000\n",
" MSI band 03 bandpass adjustment slope and offset=1.007500, -0.000800\n",
" MSI band 04 bandpass adjustment slope and offset=0.976100, 0.001000\n",
" MSI band 11 bandpass adjustment slope and offset=1.000000, -0.000300\n",
" MSI band 12 bandpass adjustment slope and offset=0.986700, 0.000400\n",
" MSI band 8a bandpass adjustment slope and offset=0.996600, 0.000000\n",
" NBAR_AngleBand=0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12\n",
" NBAR_SOLAR_ZENITH=24.7807801205817\n",
" NCOLS=3660\n",
" NROWS=3660\n",
" OVR_RESAMPLING_ALG=NEAREST\n",
" PROCESSING_BASELINE=02.09\n",
" PRODUCT_URI=S2B_MSIL1C_20200710T174909_N0209_R141_T13TEF_20200710T213436.SAFE\n",
" scale_factor=0.0001\n",
" SENSING_TIME=2020-07-10T18:02:38.62776Z\n",
" SPACECRAFT_NAME=Sentinel-2B\n",
" spatial_coverage=89\n",
" SPATIAL_RESOLUTION=30\n",
" TILE_ID=S2B_OPER_MSI_L1C_TL_EPAE_20200710T213436_A017470_T13TEF_N02.09\n",
" ULX=499980\n",
" ULY=4600020\n",
" _FillValue=-9999\n",
"Image Structure Metadata:\n",
" COMPRESSION=DEFLATE\n",
" INTERLEAVE=BAND\n",
"Corner Coordinates:\n",
"Upper Left ( 499980.000, 4600020.000) (105d 0' 0.86\"W, 41d33' 6.64\"N)\n",
"Lower Left ( 499980.000, 4490220.000) (105d 0' 0.85\"W, 40d33'45.90\"N)\n",
"Upper Right ( 609780.000, 4600020.000) (103d41' 1.68\"W, 41d32'39.52\"N)\n",
"Lower Right ( 609780.000, 4490220.000) (103d42'12.11\"W, 40d33'19.70\"N)\n",
"Center ( 554880.000, 4545120.000) (104d20'48.87\"W, 41d 3'19.68\"N)\n",
"Band 1 Block=256x256 Type=Int16, ColorInterp=Gray\n",
" Description = Coastal_Aerosol\n",
" NoData Value=-9999\n",
" Overviews: 1830x1830, 915x915, 458x458, 229x229\n",
" Offset: 0, Scale:0.0001\n"
]
}
],
"source": [
"!gdalinfo /vsicurl/https://lpdaac.earthdata.nasa.gov/lp-prod-protected/HLSS30.015/HLS.S30.T13TEF.2020192T174909.v1.5.B01.tif --config GDAL_DISABLE_READDIR_ON_OPEN EMPTY_DIR"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "refined-louis",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<xarray.DataArray 'stackstac-b699f8cdf661476c41177051d5cfeaf3' (time: 51, band: 14, y: 3715, x: 3717)>\n",
"dask.array<fetch_raster_window, shape=(51, 14, 3715, 3717), dtype=float64, chunksize=(1, 1, 3715, 3715), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * time (time) object 1594404158627000000 ... 1614276155393000000\n",
" id (time) <U19 'G1947862363-LPCLOUD' ... 'G2014001638-LPCLOUD'\n",
" * band (band) <U5 'B8A' 'B08' 'B09' 'B04' ... 'Fmask' 'B01' 'B10'\n",
" * x (x) float64 5e+05 5e+05 5e+05 ... 6.114e+05 6.114e+05\n",
" * y (y) float64 4.601e+06 4.601e+06 ... 4.489e+06 4.489e+06\n",
" eo:cloud_cover (time) int64 2 0 0 39 1 0 1 1 80 ... 42 39 97 100 40 0 4 81\n",
" start_datetime (time) <U24 '2020-07-10T18:02:38.627Z' ... '2021-02-25T18...\n",
" end_datetime (time) <U24 '2020-07-10T18:02:38.627Z' ... '2021-02-25T18...\n",
"Attributes:\n",
" spec: RasterSpec(epsg=32613, bounds=(499950, 4489410, 611460, 4600...\n",
" crs: epsg:32613\n",
" transform: | 30.00, 0.00, 499950.00|\\n| 0.00,-30.00, 4600860.00|\\n| 0.0...\n",
" resolution: 30\n"
]
}
],
"source": [
"import stackstac\n",
"s = stackstac.stack(s_col,epsg=32613,resolution=30,chunksize=3715)\n",
"print(s)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "aquatic-stevens",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;stackstac-b699f8cdf661476c41177051d5cfeaf3&#x27; ()&gt;\n",
"array(3167.58068519)\n",
"Coordinates:\n",
" band &lt;U5 &#x27;B01&#x27;</pre><div class='xr-wrap' hidden><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'stackstac-b699f8cdf661476c41177051d5cfeaf3'</div></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-0c1f2e60-12df-4b14-bab5-c5be2543f9b3' class='xr-array-in' type='checkbox' checked><label for='section-0c1f2e60-12df-4b14-bab5-c5be2543f9b3' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>3.168e+03</span></div><div class='xr-array-data'><pre>array(3167.58068519)</pre></div></div></li><li class='xr-section-item'><input id='section-7b4c0ce0-3aa1-4714-810c-e9ff72c2bd24' class='xr-section-summary-in' type='checkbox' checked><label for='section-7b4c0ce0-3aa1-4714-810c-e9ff72c2bd24' class='xr-section-summary' >Coordinates: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>band</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>&lt;U5</div><div class='xr-var-preview xr-preview'>&#x27;B01&#x27;</div><input id='attrs-53a08b03-7436-4820-a11e-5b2f1e83b961' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-53a08b03-7436-4820-a11e-5b2f1e83b961' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-823fd9f3-a487-45aa-8bb3-6fd3e48589ff' class='xr-var-data-in' type='checkbox'><label for='data-823fd9f3-a487-45aa-8bb3-6fd3e48589ff' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(&#x27;B01&#x27;, dtype=&#x27;&lt;U5&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-125102e8-8a8d-4f58-9ae3-78c7e0892277' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-125102e8-8a8d-4f58-9ae3-78c7e0892277' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.DataArray 'stackstac-b699f8cdf661476c41177051d5cfeaf3' ()>\n",
"array(3167.58068519)\n",
"Coordinates:\n",
" band <U5 'B01'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s.sel(band='B01').isel(x=slice(100,200),y=slice(100,200)).mean().compute()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:py_geo]",
"language": "python",
"name": "conda-env-py_geo-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment