|
60 | 60 | "W = 800\n", |
61 | 61 | "H = 600\n", |
62 | 62 | "\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", |
64 | 66 | "terrain = generate_terrain(canvas=cvs)\n", |
65 | 67 | "\n", |
66 | | - "shade(terrain, cmap=['black', 'white'], how='linear')" |
| 68 | + "shade(terrain, cmap=[\"black\", \"white\"], how=\"linear\")" |
67 | 69 | ] |
68 | 70 | }, |
69 | 71 | { |
|
89 | 91 | "cvs = ds.Canvas(plot_width=W, plot_height=H, x_range=(-20, 20), y_range=(-20, 20))\n", |
90 | 92 | "\n", |
91 | 93 | "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", |
93 | 95 | "\n", |
94 | 96 | "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", |
96 | 98 | "\n", |
97 | 99 | "stack(illuminated_shaded, terrain_shaded)" |
98 | 100 | ] |
|
127 | 129 | "metadata": {}, |
128 | 130 | "outputs": [], |
129 | 131 | "source": [ |
| 132 | + "from xrspatial import convolution\n", |
130 | 133 | "from xrspatial import focal\n", |
131 | 134 | "\n", |
132 | | - "cellsize_x, cellsize_y = focal.calc_cellsize(terrain)\n", |
| 135 | + "cellsize_x, cellsize_y = convolution.calc_cellsize(terrain)\n", |
133 | 136 | "# Use an annulus kernel with a ring at a distance from 25-30 cells away from focal point\n", |
134 | 137 | "outer_radius = cellsize_x * 30\n", |
135 | 138 | "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", |
137 | 140 | "tpi = terrain - focal.apply(terrain, kernel)\n", |
138 | 141 | "tpi_terrain = hillshade(terrain - focal.apply(terrain, kernel))\n", |
139 | 142 | "tpi_terrain_shaded = shade(\n", |
|
211 | 214 | "name": "python", |
212 | 215 | "nbconvert_exporter": "python", |
213 | 216 | "pygments_lexer": "ipython3", |
214 | | - "version": "3.8.8" |
| 217 | + "version": "3.8.10" |
215 | 218 | } |
216 | 219 | }, |
217 | 220 | "nbformat": 4, |
|
0 commit comments