myco.geo¶
Geospatial data read, write and manipulation functions
block_windows(width, height, blockxsize=BLOCKSIZE, blockysize=BLOCKSIZE)
¶
Returns a tuple of iterables with custom window sizes for block-based read/write.
Designed to be used as a custom block size implementation of rasterio's src.block_windows()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width |
int
|
the raster width (xsize) in pixels. |
required |
height |
int
|
the raster height (ysize) in pixels. |
required |
blockxsize |
int
|
the size of the x (column) dimension to read per block. |
BLOCKSIZE
|
blockysize |
int
|
the size of the y (row) dimension to read per block. |
BLOCKSIZE
|
Returns:
Name | Type | Description |
---|---|---|
iter |
windows
|
an iterable with a tuple of block indexes ((0, 0), (0, 1) ... ) and rasterio read Windows (Window(col_off=0, row_off=0, width=blockxsize, height=blockysize), ... ). |
Source code in myco/geo.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
get_fio_drivers(writeable=False)
¶
Return a list of available fiona drivers
Source code in myco/geo.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
get_rio_drivers(writeable=False)
¶
Return a list of available rasterio drivers
Source code in myco/geo.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
get_rio_dtypes()
¶
Returns a list of rasterio-format data type strings
Source code in myco/geo.py
236 237 238 |
|
get_rio_resampling()
¶
Returns a list of rasterio-format resampling options
Source code in myco/geo.py
241 242 243 244 245 246 247 248 |
|
interior_window_idxs(window_shape, percent=0.5)
¶
Computes the xstart:xend, ystart:yend indices for the interior window of a 2d array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window_shape |
tuple
|
2d tuple of a window size (e.g. (64, 64)) |
required |
percent |
float
|
the percent of the interior window to include. |
0.5
|
Returns:
Type | Description |
---|---|
tuple
|
ymin, ymax, xmin, xmax indices for slicing the interior windows. |
Source code in myco/geo.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
is_raster(filepath)
¶
Verify a file is a valid, readable raster dataset
Source code in myco/geo.py
211 212 213 214 215 216 217 218 |
|
is_vector(filepath)
¶
Verify a sile is a valid, readable vector dataset
Source code in myco/geo.py
221 222 223 224 225 226 227 228 |
|
point_to_window_bounds(point, xsize, xres, ysize=None, yres=None)
¶
Computes the tile bounds for a window surrounding a point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point |
Point
|
the point sample centroid. |
required |
xsize |
int
|
the number of x pixels. |
required |
xres |
float
|
the size (resolution) of x pixels. |
required |
ysize |
int
|
the number of y pixels. uses xsize if not passed. |
None
|
yres |
float
|
the size (resolution) of y pixels. uses ysize if not passed. |
None
|
Returns:
Type | Description |
---|---|
Tuple[float, float, float, float]
|
[xmin, ymin, xmax, ymax] of the bounding box centered on the point. |
Source code in myco/geo.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
raster_interior_windows(overlapping_windows, interior_idxs)
¶
Get interior windows for data that match external read blocks
Source code in myco/geo.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
raster_overlapping_windows(width, height, window_shape, interior_idxs)
¶
Creates a list of block windows the size of the interior model application window.
Source code in myco/geo.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|