Skip to content

Commit 8576792

Browse files
authored
fix focal notebook imports (#481)
1 parent 9c84a59 commit 8576792

File tree

2 files changed

+189
-27
lines changed

2 files changed

+189
-27
lines changed

docs/source/user_guide/focal.ipynb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@
6060
"W = 800\n",
6161
"H = 600\n",
6262
"\n",
63-
"cvs = ds.Canvas(plot_width=W, plot_height=H, x_range=(-20e6, 20e6), y_range=(-20e6, 20e6))\n",
63+
"cvs = ds.Canvas(\n",
64+
" plot_width=W, plot_height=H, x_range=(-20e6, 20e6), y_range=(-20e6, 20e6)\n",
65+
")\n",
6466
"terrain = generate_terrain(canvas=cvs)\n",
6567
"\n",
66-
"shade(terrain, cmap=['black', 'white'], how='linear')"
68+
"shade(terrain, cmap=[\"black\", \"white\"], how=\"linear\")"
6769
]
6870
},
6971
{
@@ -89,10 +91,10 @@
8991
"cvs = ds.Canvas(plot_width=W, plot_height=H, x_range=(-20, 20), y_range=(-20, 20))\n",
9092
"\n",
9193
"terrain = generate_terrain(canvas=cvs)\n",
92-
"terrain_shaded = shade(terrain, cmap=Elevation, alpha=128, how='linear')\n",
94+
"terrain_shaded = shade(terrain, cmap=Elevation, alpha=128, how=\"linear\")\n",
9395
"\n",
9496
"illuminated = hillshade(terrain)\n",
95-
"illuminated_shaded = shade(illuminated, cmap=['gray', 'white'], alpha=255, how='linear')\n",
97+
"illuminated_shaded = shade(illuminated, cmap=[\"gray\", \"white\"], alpha=255, how=\"linear\")\n",
9698
"\n",
9799
"stack(illuminated_shaded, terrain_shaded)"
98100
]
@@ -127,13 +129,14 @@
127129
"metadata": {},
128130
"outputs": [],
129131
"source": [
132+
"from xrspatial import convolution\n",
130133
"from xrspatial import focal\n",
131134
"\n",
132-
"cellsize_x, cellsize_y = focal.calc_cellsize(terrain)\n",
135+
"cellsize_x, cellsize_y = convolution.calc_cellsize(terrain)\n",
133136
"# Use an annulus kernel with a ring at a distance from 25-30 cells away from focal point\n",
134137
"outer_radius = cellsize_x * 30\n",
135138
"inner_radius = cellsize_x * 25\n",
136-
"kernel = focal.annulus_kernel(cellsize_x, cellsize_y, outer_radius, inner_radius)\n",
139+
"kernel = convolution.annulus_kernel(cellsize_x, cellsize_y, outer_radius, inner_radius)\n",
137140
"tpi = terrain - focal.apply(terrain, kernel)\n",
138141
"tpi_terrain = hillshade(terrain - focal.apply(terrain, kernel))\n",
139142
"tpi_terrain_shaded = shade(\n",
@@ -211,7 +214,7 @@
211214
"name": "python",
212215
"nbconvert_exporter": "python",
213216
"pygments_lexer": "ipython3",
214-
"version": "3.8.8"
217+
"version": "3.8.10"
215218
}
216219
},
217220
"nbformat": 4,

examples/user_guide/4_Focal.ipynb

Lines changed: 179 additions & 20 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)