Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
zyang91 committed Jun 2, 2024
1 parent c48bc88 commit 1ea0e32
Show file tree
Hide file tree
Showing 2 changed files with 357 additions and 0 deletions.
17 changes: 17 additions & 0 deletions notes/download_data/stats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
zone,stat
11,164.74717638195287
12,2057.6558227539062
21,200.14814316511763
22,234.37018477457337
23,239.25033435053547
24,184.14536772614176
31,1161.049748573519
41,408.02281919984944
42,1154.1838450652367
43,295.7722617252539
52,1389.8195304965748
71,975.4061958771471
81,261.59692828066926
82,433.5063117442873
90,162.39648147168023
95,315.73280671916626
340 changes: 340 additions & 0 deletions notes/lecture16.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,346 @@
"stats.getInfo()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Zonal statistics for two image layer"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" .geemap-dark {\n",
" --jp-widgets-color: white;\n",
" --jp-widgets-label-color: white;\n",
" --jp-ui-font-color1: white;\n",
" --jp-layout-color2: #454545;\n",
" background-color: #383838;\n",
" }\n",
"\n",
" .geemap-dark .jupyter-button {\n",
" --jp-layout-color3: #383838;\n",
" }\n",
"\n",
" .geemap-colab {\n",
" background-color: var(--colab-primary-surface-color, white);\n",
" }\n",
"\n",
" .geemap-colab .jupyter-button {\n",
" --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3dd1744771af4fc8bc9630ef1817b5b0",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[40, -100], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(ch…"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"Map = geemap.Map(center=[40, -100], zoom=4)\n",
"dem = ee.Image('USGS/3DEP/10m')\n",
"vis = {'min': 0, 'max': 4000, 'palette': 'terrain'}\n",
"Map.addLayer(dem, vis, 'DEM')\n",
"Map"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" .geemap-dark {\n",
" --jp-widgets-color: white;\n",
" --jp-widgets-label-color: white;\n",
" --jp-ui-font-color1: white;\n",
" --jp-layout-color2: #454545;\n",
" background-color: #383838;\n",
" }\n",
"\n",
" .geemap-dark .jupyter-button {\n",
" --jp-layout-color3: #383838;\n",
" }\n",
"\n",
" .geemap-colab {\n",
" background-color: var(--colab-primary-surface-color, white);\n",
" }\n",
"\n",
" .geemap-colab .jupyter-button {\n",
" --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"landcover = ee.Image(\"USGS/NLCD_RELEASES/2019_REL/NLCD/2019\").select('landcover')\n",
"Map.addLayer(landcover, {}, 'NLCD 2019')\n",
"Map.add_legend(title='NLCD Land Cover Classification', builtin_legend='NLCD')"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" .geemap-dark {\n",
" --jp-widgets-color: white;\n",
" --jp-widgets-label-color: white;\n",
" --jp-ui-font-color1: white;\n",
" --jp-layout-color2: #454545;\n",
" background-color: #383838;\n",
" }\n",
"\n",
" .geemap-dark .jupyter-button {\n",
" --jp-layout-color3: #383838;\n",
" }\n",
"\n",
" .geemap-colab {\n",
" background-color: var(--colab-primary-surface-color, white);\n",
" }\n",
"\n",
" .geemap-colab .jupyter-button {\n",
" --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>zone</th>\n",
" <th>stat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>11</td>\n",
" <td>164.747176</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>12</td>\n",
" <td>2057.655823</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>21</td>\n",
" <td>200.148143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>22</td>\n",
" <td>234.370185</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>23</td>\n",
" <td>239.250334</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>24</td>\n",
" <td>184.145368</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>31</td>\n",
" <td>1161.049749</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>41</td>\n",
" <td>408.022819</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>42</td>\n",
" <td>1154.183845</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>43</td>\n",
" <td>295.772262</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>52</td>\n",
" <td>1389.819530</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>71</td>\n",
" <td>975.406196</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>81</td>\n",
" <td>261.596928</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>82</td>\n",
" <td>433.506312</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>90</td>\n",
" <td>162.396481</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>95</td>\n",
" <td>315.732807</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" zone stat\n",
"0 11 164.747176\n",
"1 12 2057.655823\n",
"2 21 200.148143\n",
"3 22 234.370185\n",
"4 23 239.250334\n",
"5 24 184.145368\n",
"6 31 1161.049749\n",
"7 41 408.022819\n",
"8 42 1154.183845\n",
"9 43 295.772262\n",
"10 52 1389.819530\n",
"11 71 975.406196\n",
"12 81 261.596928\n",
"13 82 433.506312\n",
"14 90 162.396481\n",
"15 95 315.732807"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stats = geemap.image_stats_by_zone(dem, landcover, reducer='MEAN')\n",
"stats"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" .geemap-dark {\n",
" --jp-widgets-color: white;\n",
" --jp-widgets-label-color: white;\n",
" --jp-ui-font-color1: white;\n",
" --jp-layout-color2: #454545;\n",
" background-color: #383838;\n",
" }\n",
"\n",
" .geemap-dark .jupyter-button {\n",
" --jp-layout-color3: #383838;\n",
" }\n",
"\n",
" .geemap-colab {\n",
" background-color: var(--colab-primary-surface-color, white);\n",
" }\n",
"\n",
" .geemap-colab .jupyter-button {\n",
" --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"stats.to_csv('stats.csv', index=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 1ea0e32

Please sign in to comment.