Skip to content

Instantly share code, notes, and snippets.

@jhamman
Created November 12, 2020 17:00
Show Gist options
  • Save jhamman/2a95102567025b3b69e2873a89aaed22 to your computer and use it in GitHub Desktop.
Save jhamman/2a95102567025b3b69e2873a89aaed22 to your computer and use it in GitHub Desktop.
Public zarr dataset
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"import zarr\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"ds = xr.open_rasterio(\n",
" 'https://carbonplan.blob.core.windows.net/carbonplan-data/raw/nftd/conus_foresttype/250m/raster.tif',\n",
" chunks={'x': 256, 'y': 256}).to_dataset(name='nftd')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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, 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.Dataset&gt;\n",
"Dimensions: (band: 1, x: 18493, y: 11658)\n",
"Coordinates:\n",
" * band (band) int64 1\n",
" * y (y) float64 3.177e+06 3.177e+06 3.177e+06 ... 2.634e+05 2.631e+05\n",
" * x (x) float64 -2.36e+06 -2.36e+06 -2.359e+06 ... 2.263e+06 2.263e+06\n",
"Data variables:\n",
" nftd (band, y, x) uint16 dask.array&lt;chunksize=(1, 256, 256), meta=np.ndarray&gt;</pre><div class='xr-wrap' hidden><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-e75bf353-92b0-4a9b-b838-bc636c430a95' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-e75bf353-92b0-4a9b-b838-bc636c430a95' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>band</span>: 1</li><li><span class='xr-has-index'>x</span>: 18493</li><li><span class='xr-has-index'>y</span>: 11658</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-ff005929-b749-411b-9854-2b180be34812' class='xr-section-summary-in' type='checkbox' checked><label for='section-ff005929-b749-411b-9854-2b180be34812' class='xr-section-summary' >Coordinates: <span>(3)</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 class='xr-has-index'>band</span></div><div class='xr-var-dims'>(band)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>1</div><input id='attrs-894441c3-a8b3-4119-a6c1-66e1a4b17a2c' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-894441c3-a8b3-4119-a6c1-66e1a4b17a2c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-fb65fabd-2fab-4845-b81a-d76a18f220c7' class='xr-var-data-in' type='checkbox'><label for='data-fb65fabd-2fab-4845-b81a-d76a18f220c7' 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([1])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>y</span></div><div class='xr-var-dims'>(y)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>3.177e+06 3.177e+06 ... 2.631e+05</div><input id='attrs-bf65eaa4-4ca9-4374-bbaa-d66244b09a53' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bf65eaa4-4ca9-4374-bbaa-d66244b09a53' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2c80c1a1-6c8e-481a-b569-135908016cdf' class='xr-var-data-in' type='checkbox'><label for='data-2c80c1a1-6c8e-481a-b569-135908016cdf' 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([3177375., 3177125., 3176875., ..., 263625., 263375., 263125.])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>x</span></div><div class='xr-var-dims'>(x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-2.36e+06 -2.36e+06 ... 2.263e+06</div><input id='attrs-d8f53fff-065d-47f6-b9c5-9c24c34ff81c' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-d8f53fff-065d-47f6-b9c5-9c24c34ff81c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-1edd399f-288c-41ec-af18-50f126e4dc39' class='xr-var-data-in' type='checkbox'><label for='data-1edd399f-288c-41ec-af18-50f126e4dc39' 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([-2359875., -2359625., -2359375., ..., 2262625., 2262875., 2263125.])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-5871e1b1-e389-4be8-a89d-e2371d31435f' class='xr-section-summary-in' type='checkbox' checked><label for='section-5871e1b1-e389-4be8-a89d-e2371d31435f' class='xr-section-summary' >Data variables: <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>nftd</span></div><div class='xr-var-dims'>(band, y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1, 256, 256), meta=np.ndarray&gt;</div><input id='attrs-baf7f586-2869-41a5-a82d-0730bc9ce124' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-baf7f586-2869-41a5-a82d-0730bc9ce124' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-63f7d459-da24-410f-843a-41a364bbd653' class='xr-var-data-in' type='checkbox'><label for='data-63f7d459-da24-410f-843a-41a364bbd653' 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'><dt><span>transform :</span></dt><dd>(250.00000000000003, 0.0, -2360000.0, 0.0, -250.00000000000003, 3177500.0)</dd><dt><span>crs :</span></dt><dd>+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD27 +units=m +no_defs=True</dd><dt><span>res :</span></dt><dd>(250.00000000000003, 250.00000000000003)</dd><dt><span>is_tiled :</span></dt><dd>1</dd><dt><span>nodatavals :</span></dt><dd>(nan,)</dd><dt><span>scales :</span></dt><dd>(1.0,)</dd><dt><span>offsets :</span></dt><dd>(0.0,)</dd><dt><span>descriptions :</span></dt><dd>(&#x27;Layer_1&#x27;,)</dd><dt><span>AREA_OR_POINT :</span></dt><dd>Area</dd><dt><span>OVR_RESAMPLING_ALG :</span></dt><dd>NEAREST</dd></dl></div><div class='xr-var-data'><table>\n",
"<tr>\n",
"<td>\n",
"<table>\n",
" <thead>\n",
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr><th> Bytes </th><td> 431.18 MB </td> <td> 131.07 kB </td></tr>\n",
" <tr><th> Shape </th><td> (1, 11658, 18493) </td> <td> (1, 256, 256) </td></tr>\n",
" <tr><th> Count </th><td> 3359 Tasks </td><td> 3358 Chunks </td></tr>\n",
" <tr><th> Type </th><td> uint16 </td><td> numpy.ndarray </td></tr>\n",
" </tbody>\n",
"</table>\n",
"</td>\n",
"<td>\n",
"<svg width=\"194\" height=\"140\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"24\" y2=\"14\" style=\"stroke-width:2\" />\n",
" <line x1=\"10\" y1=\"3\" x2=\"24\" y2=\"18\" />\n",
" <line x1=\"10\" y1=\"6\" x2=\"24\" y2=\"21\" />\n",
" <line x1=\"10\" y1=\"11\" x2=\"24\" y2=\"26\" />\n",
" <line x1=\"10\" y1=\"14\" x2=\"24\" y2=\"29\" />\n",
" <line x1=\"10\" y1=\"19\" x2=\"24\" y2=\"34\" />\n",
" <line x1=\"10\" y1=\"23\" x2=\"24\" y2=\"38\" />\n",
" <line x1=\"10\" y1=\"26\" x2=\"24\" y2=\"41\" />\n",
" <line x1=\"10\" y1=\"31\" x2=\"24\" y2=\"46\" />\n",
" <line x1=\"10\" y1=\"34\" x2=\"24\" y2=\"49\" />\n",
" <line x1=\"10\" y1=\"39\" x2=\"24\" y2=\"54\" />\n",
" <line x1=\"10\" y1=\"43\" x2=\"24\" y2=\"58\" />\n",
" <line x1=\"10\" y1=\"48\" x2=\"24\" y2=\"63\" />\n",
" <line x1=\"10\" y1=\"51\" x2=\"24\" y2=\"66\" />\n",
" <line x1=\"10\" y1=\"54\" x2=\"24\" y2=\"69\" />\n",
" <line x1=\"10\" y1=\"59\" x2=\"24\" y2=\"74\" />\n",
" <line x1=\"10\" y1=\"63\" x2=\"24\" y2=\"78\" />\n",
" <line x1=\"10\" y1=\"68\" x2=\"24\" y2=\"83\" />\n",
" <line x1=\"10\" y1=\"71\" x2=\"24\" y2=\"86\" />\n",
" <line x1=\"10\" y1=\"75\" x2=\"24\" y2=\"90\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"75\" style=\"stroke-width:2\" />\n",
" <line x1=\"24\" y1=\"14\" x2=\"24\" y2=\"90\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"10.0,0.0 24.9485979497544,14.948597949754403 24.9485979497544,90.59668100820895 10.0,75.64808305845455\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"130\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"24\" y1=\"14\" x2=\"144\" y2=\"14\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"24\" y2=\"14\" style=\"stroke-width:2\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"29\" y2=\"14\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"36\" y2=\"14\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"43\" y2=\"14\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"49\" y2=\"14\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"56\" y2=\"14\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"63\" y2=\"14\" />\n",
" <line x1=\"53\" y1=\"0\" x2=\"68\" y2=\"14\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"74\" y2=\"14\" />\n",
" <line x1=\"66\" y1=\"0\" x2=\"81\" y2=\"14\" />\n",
" <line x1=\"73\" y1=\"0\" x2=\"88\" y2=\"14\" />\n",
" <line x1=\"79\" y1=\"0\" x2=\"94\" y2=\"14\" />\n",
" <line x1=\"86\" y1=\"0\" x2=\"101\" y2=\"14\" />\n",
" <line x1=\"91\" y1=\"0\" x2=\"106\" y2=\"14\" />\n",
" <line x1=\"98\" y1=\"0\" x2=\"112\" y2=\"14\" />\n",
" <line x1=\"104\" y1=\"0\" x2=\"119\" y2=\"14\" />\n",
" <line x1=\"111\" y1=\"0\" x2=\"126\" y2=\"14\" />\n",
" <line x1=\"117\" y1=\"0\" x2=\"132\" y2=\"14\" />\n",
" <line x1=\"124\" y1=\"0\" x2=\"139\" y2=\"14\" />\n",
" <line x1=\"130\" y1=\"0\" x2=\"144\" y2=\"14\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"10.0,0.0 130.0,0.0 144.9485979497544,14.948597949754403 24.9485979497544,14.948597949754403\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"24\" y1=\"14\" x2=\"144\" y2=\"14\" style=\"stroke-width:2\" />\n",
" <line x1=\"24\" y1=\"18\" x2=\"144\" y2=\"18\" />\n",
" <line x1=\"24\" y1=\"21\" x2=\"144\" y2=\"21\" />\n",
" <line x1=\"24\" y1=\"26\" x2=\"144\" y2=\"26\" />\n",
" <line x1=\"24\" y1=\"29\" x2=\"144\" y2=\"29\" />\n",
" <line x1=\"24\" y1=\"34\" x2=\"144\" y2=\"34\" />\n",
" <line x1=\"24\" y1=\"38\" x2=\"144\" y2=\"38\" />\n",
" <line x1=\"24\" y1=\"41\" x2=\"144\" y2=\"41\" />\n",
" <line x1=\"24\" y1=\"46\" x2=\"144\" y2=\"46\" />\n",
" <line x1=\"24\" y1=\"49\" x2=\"144\" y2=\"49\" />\n",
" <line x1=\"24\" y1=\"54\" x2=\"144\" y2=\"54\" />\n",
" <line x1=\"24\" y1=\"58\" x2=\"144\" y2=\"58\" />\n",
" <line x1=\"24\" y1=\"63\" x2=\"144\" y2=\"63\" />\n",
" <line x1=\"24\" y1=\"66\" x2=\"144\" y2=\"66\" />\n",
" <line x1=\"24\" y1=\"69\" x2=\"144\" y2=\"69\" />\n",
" <line x1=\"24\" y1=\"74\" x2=\"144\" y2=\"74\" />\n",
" <line x1=\"24\" y1=\"78\" x2=\"144\" y2=\"78\" />\n",
" <line x1=\"24\" y1=\"83\" x2=\"144\" y2=\"83\" />\n",
" <line x1=\"24\" y1=\"86\" x2=\"144\" y2=\"86\" />\n",
" <line x1=\"24\" y1=\"90\" x2=\"144\" y2=\"90\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"24\" y1=\"14\" x2=\"24\" y2=\"90\" style=\"stroke-width:2\" />\n",
" <line x1=\"29\" y1=\"14\" x2=\"29\" y2=\"90\" />\n",
" <line x1=\"36\" y1=\"14\" x2=\"36\" y2=\"90\" />\n",
" <line x1=\"43\" y1=\"14\" x2=\"43\" y2=\"90\" />\n",
" <line x1=\"49\" y1=\"14\" x2=\"49\" y2=\"90\" />\n",
" <line x1=\"56\" y1=\"14\" x2=\"56\" y2=\"90\" />\n",
" <line x1=\"63\" y1=\"14\" x2=\"63\" y2=\"90\" />\n",
" <line x1=\"68\" y1=\"14\" x2=\"68\" y2=\"90\" />\n",
" <line x1=\"74\" y1=\"14\" x2=\"74\" y2=\"90\" />\n",
" <line x1=\"81\" y1=\"14\" x2=\"81\" y2=\"90\" />\n",
" <line x1=\"88\" y1=\"14\" x2=\"88\" y2=\"90\" />\n",
" <line x1=\"94\" y1=\"14\" x2=\"94\" y2=\"90\" />\n",
" <line x1=\"101\" y1=\"14\" x2=\"101\" y2=\"90\" />\n",
" <line x1=\"106\" y1=\"14\" x2=\"106\" y2=\"90\" />\n",
" <line x1=\"112\" y1=\"14\" x2=\"112\" y2=\"90\" />\n",
" <line x1=\"119\" y1=\"14\" x2=\"119\" y2=\"90\" />\n",
" <line x1=\"126\" y1=\"14\" x2=\"126\" y2=\"90\" />\n",
" <line x1=\"132\" y1=\"14\" x2=\"132\" y2=\"90\" />\n",
" <line x1=\"139\" y1=\"14\" x2=\"139\" y2=\"90\" />\n",
" <line x1=\"144\" y1=\"14\" x2=\"144\" y2=\"90\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"24.9485979497544,14.948597949754403 144.9485979497544,14.948597949754403 144.9485979497544,90.59668100820895 24.9485979497544,90.59668100820895\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"84.948598\" y=\"110.596681\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >18493</text>\n",
" <text x=\"164.948598\" y=\"52.772639\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,164.948598,52.772639)\">11658</text>\n",
" <text x=\"7.474299\" y=\"103.122382\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,7.474299,103.122382)\">1</text>\n",
"</svg>\n",
"</td>\n",
"</tr>\n",
"</table></div></li></ul></div></li><li class='xr-section-item'><input id='section-f363410d-ee2f-45a9-bdfd-9d00e9b2f331' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-f363410d-ee2f-45a9-bdfd-9d00e9b2f331' 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.Dataset>\n",
"Dimensions: (band: 1, x: 18493, y: 11658)\n",
"Coordinates:\n",
" * band (band) int64 1\n",
" * y (y) float64 3.177e+06 3.177e+06 3.177e+06 ... 2.634e+05 2.631e+05\n",
" * x (x) float64 -2.36e+06 -2.36e+06 -2.359e+06 ... 2.263e+06 2.263e+06\n",
"Data variables:\n",
" nftd (band, y, x) uint16 dask.array<chunksize=(1, 256, 256), meta=np.ndarray>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ds"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<xarray.backends.zarr.ZarrStore at 0x7f3cbd9234d0>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"store = zarr.storage.ABSStore(\n",
" 'carbonplan-share',\n",
" prefix='zarr-demo',\n",
" account_name=\"carbonplan\",\n",
" account_key=os.environ[\"BLOB_ACCOUNT_KEY\"],\n",
")\n",
"\n",
"ds.to_zarr(store, mode='w', encoding={k: {'compressor': None} for k in ds.variables}, consolidated=True)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"metadata\": {\n",
" \".zattrs\": {},\n",
" \".zgroup\": {\n",
" \"zarr_format\": 2\n",
" },\n",
" \"band/.zarray\": {\n",
" \"chunks\": [\n",
" 1\n",
" ],\n",
" \"compressor\": null,\n",
" \"dtype\": \"<i8\",\n",
" \"fill_value\": null,\n",
" \"filters\": null,\n",
" \"order\": \"C\",\n",
" \"shape\": [\n",
" 1\n",
" ],\n",
" \"zarr_format\": 2\n",
" },\n",
" \"band/.zattrs\": {\n",
" \"_ARRAY_DIMENSIONS\": [\n",
" \"band\"\n",
" ]\n",
" },\n",
" \"nftd/.zarray\": {\n",
" \"chunks\": [\n",
" 1,\n",
" 256,\n",
" 256\n",
" ],\n",
" \"compressor\": null,\n",
" \"dtype\": \"<u2\",\n",
" \"fill_value\": null,\n",
" \"filters\": null,\n",
" \"order\": \"C\",\n",
" \"shape\": [\n",
" 1,\n",
" 11658,\n",
" 18493\n",
" ],\n",
" \"zarr_format\": 2\n",
" },\n",
" \"nftd/.zattrs\": {\n",
" \"AREA_OR_POINT\": \"Area\",\n",
" \"OVR_RESAMPLING_ALG\": \"NEAREST\",\n",
" \"_ARRAY_DIMENSIONS\": [\n",
" \"band\",\n",
" \"y\",\n",
" \"x\"\n",
" ],\n",
" \"crs\": \"+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD27 +units=m +no_defs=True\",\n",
" \"descriptions\": [\n",
" \"Layer_1\"\n",
" ],\n",
" \"is_tiled\": 1,\n",
" \"nodatavals\": [\n",
" NaN\n",
" ],\n",
" \"offsets\": [\n",
" 0.0\n",
" ],\n",
" \"res\": [\n",
" 250.00000000000003,\n",
" 250.00000000000003\n",
" ],\n",
" \"scales\": [\n",
" 1.0\n",
" ],\n",
" \"transform\": [\n",
" 250.00000000000003,\n",
" 0.0,\n",
" -2360000.0,\n",
" 0.0,\n",
" -250.00000000000003,\n",
" 3177500.0\n",
" ]\n",
" },\n",
" \"x/.zarray\": {\n",
" \"chunks\": [\n",
" 18493\n",
" ],\n",
" \"compressor\": null,\n",
" \"dtype\": \"<f8\",\n",
" \"fill_value\": \"NaN\",\n",
" \"filters\": null,\n",
" \"order\": \"C\",\n",
" \"shape\": [\n",
" 18493\n",
" ],\n",
" \"zarr_format\": 2\n",
" },\n",
" \"x/.zattrs\": {\n",
" \"_ARRAY_DIMENSIONS\": [\n",
" \"x\"\n",
" ]\n",
" },\n",
" \"y/.zarray\": {\n",
" \"chunks\": [\n",
" 11658\n",
" ],\n",
" \"compressor\": null,\n",
" \"dtype\": \"<f8\",\n",
" \"fill_value\": \"NaN\",\n",
" \"filters\": null,\n",
" \"order\": \"C\",\n",
" \"shape\": [\n",
" 11658\n",
" ],\n",
" \"zarr_format\": 2\n",
" },\n",
" \"y/.zattrs\": {\n",
" \"_ARRAY_DIMENSIONS\": [\n",
" \"y\"\n",
" ]\n",
" }\n",
" },\n",
" \"zarr_consolidated_format\": 1\n",
"}\n"
]
}
],
"source": [
"print(store['.zmetadata'].decode())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.7.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment