pdemtools 1.0.0__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pdemtools-1.0.0/src/pdemtools.egg-info → pdemtools-1.1.0}/PKG-INFO +3 -2
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/__init__.py +1 -1
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/_accessor.py +6 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/data.py +3 -1
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/load.py +29 -7
- {pdemtools-1.0.0 → pdemtools-1.1.0/src/pdemtools.egg-info}/PKG-INFO +3 -2
- {pdemtools-1.0.0 → pdemtools-1.1.0}/LICENSE.md +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/README.md +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/pyproject.toml +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/setup.cfg +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/_coreg.py +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/_geomorphometry.py +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/_index_search.py +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/_utils.py +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/mosaic_index/ArcticDEM_Mosaic_Index_v3_gpkg.gpkg +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/mosaic_index/ArcticDEM_Mosaic_Index_v4_1_gpkg.gpkg +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/mosaic_index/REMA_Mosaic_Index_v2_gpkg.gpkg +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/test_data/test_arcticdem_index_kiv_steenstrup.parquet +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools.egg-info/SOURCES.txt +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools.egg-info/dependency_links.txt +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools.egg-info/requires.txt +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools.egg-info/top_level.txt +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/tests/test_download.py +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/tests/test_processing.py +0 -0
- {pdemtools-1.0.0 → pdemtools-1.1.0}/tests/test_search.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pdemtools
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Conveniently search, download, and preprocess ArcticDEM and REMA products.
|
|
5
5
|
Author-email: Tom Chudley <thomas.r.chudley@durham.ac.uk>
|
|
6
6
|
License: MIT
|
|
@@ -31,6 +31,7 @@ Requires-Dist: scipy
|
|
|
31
31
|
Requires-Dist: numba
|
|
32
32
|
Requires-Dist: pyarrow
|
|
33
33
|
Requires-Dist: fiona
|
|
34
|
+
Dynamic: license-file
|
|
34
35
|
|
|
35
36
|
# pDEMtools
|
|
36
37
|
|
|
@@ -647,6 +647,8 @@ class DemAccessor:
|
|
|
647
647
|
or ("unsphericity_curvature" in attribute)
|
|
648
648
|
or ("maximal_curvature" in attribute)
|
|
649
649
|
or ("minimal_curvature" in attribute)
|
|
650
|
+
or ("horizontal_excess" in attribute)
|
|
651
|
+
or ("vertical_excess" in attribute)
|
|
650
652
|
):
|
|
651
653
|
mean_curvature_arr = mean_curvature(p_arr, q_arr, t_arr, r_arr, s_arr)
|
|
652
654
|
|
|
@@ -655,6 +657,8 @@ class DemAccessor:
|
|
|
655
657
|
or ("unsphericity_curvature" in attribute)
|
|
656
658
|
or ("maximal_curvature" in attribute)
|
|
657
659
|
or ("minimal_curvature" in attribute)
|
|
660
|
+
or ("horizontal_excess" in attribute)
|
|
661
|
+
or ("vertical_excess" in attribute)
|
|
658
662
|
):
|
|
659
663
|
gaussian_curvature_arr = gaussian_curvature(
|
|
660
664
|
p_arr, q_arr, t_arr, r_arr, s_arr
|
|
@@ -664,6 +668,8 @@ class DemAccessor:
|
|
|
664
668
|
("unsphericity_curvature" in attribute)
|
|
665
669
|
or ("maximal_curvature" in attribute)
|
|
666
670
|
or ("minimal_curvature" in attribute)
|
|
671
|
+
or ("horizontal_excess" in attribute)
|
|
672
|
+
or ("vertical_excess" in attribute)
|
|
667
673
|
):
|
|
668
674
|
unsphericity_curvature_arr = unsphericity_curvature(
|
|
669
675
|
mean_curvature_arr, gaussian_curvature_arr
|
|
@@ -135,7 +135,9 @@ def bedrock_mask_from_bedmachine(bm_fpath: str, target_rxd: DataArray) -> DataAr
|
|
|
135
135
|
# Reample using bilinear resampling rather than nearest neighbour, as mask
|
|
136
136
|
# resolution is much larger than DEM resolution
|
|
137
137
|
mask = mask.squeeze().astype("float32").rio.write_crs(mask_crs)
|
|
138
|
-
mask = mask.rio.reproject_match(
|
|
138
|
+
mask = mask.rio.reproject_match(
|
|
139
|
+
match_data_array=target_rxd, resampling=Resampling.bilinear
|
|
140
|
+
)
|
|
139
141
|
|
|
140
142
|
# Set interpolated values to boolean (1/0) values again
|
|
141
143
|
mask = mask.round()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""This module contains functions necessary to open an ArcticDEM/REMA strip as an
|
|
2
|
-
xarray DataArray, from either local or AWS sources.
|
|
1
|
+
"""This module contains functions necessary to open an ArcticDEM/REMA strip as an
|
|
2
|
+
xarray DataArray, from either local or AWS sources.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import os
|
|
@@ -40,6 +40,7 @@ def from_fpath(
|
|
|
40
40
|
bounds: Optional[Union[tuple, Polygon]] = None,
|
|
41
41
|
bitmask_fpath: Optional[str] = None,
|
|
42
42
|
pad: Optional[bool] = False,
|
|
43
|
+
chunks: Optional[Union[int, tuple, dict]] = None,
|
|
43
44
|
) -> DataArray:
|
|
44
45
|
"""Given a filepath (local or an AWS link), loads the desired ArcticDEM/REMA DEM
|
|
45
46
|
strip as an ``xarray`` ``DataArray``. Option to filter to bounds and bitmask, if
|
|
@@ -59,6 +60,9 @@ def from_fpath(
|
|
|
59
60
|
:param pad: If the DEM strip is not the full extent of the given bounds,
|
|
60
61
|
pad with NaNs to match the full bounds. Defaults to False.
|
|
61
62
|
:type pad: bool
|
|
63
|
+
:param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
|
|
64
|
+
parallelisation and lazy evaluation/loading. Defaults to `None`.
|
|
65
|
+
:type chunks: int | tuple | dict
|
|
62
66
|
|
|
63
67
|
:returns: xarray DataArray of DEM strip
|
|
64
68
|
:rtype: DataArray
|
|
@@ -69,7 +73,7 @@ def from_fpath(
|
|
|
69
73
|
raise ValueError("pad must be True or False")
|
|
70
74
|
|
|
71
75
|
# Open dataarray using rioxarray
|
|
72
|
-
dem = rxr.open_rasterio(dem_fpath)
|
|
76
|
+
dem = rxr.open_rasterio(dem_fpath, chunks=chunks)
|
|
73
77
|
|
|
74
78
|
# Convert shapely geometry to bounds
|
|
75
79
|
if isinstance(bounds, Polygon):
|
|
@@ -169,6 +173,7 @@ def from_search(
|
|
|
169
173
|
bounds: Optional[Union[tuple, Polygon]] = None,
|
|
170
174
|
bitmask: Optional[bool] = True,
|
|
171
175
|
pad: Optional[bool] = False,
|
|
176
|
+
chunks: Optional[Union[int, tuple, dict]] = None,
|
|
172
177
|
):
|
|
173
178
|
"""Given a row from the GeoDataFrame output of ``pdemtools.search()``, loads the 2
|
|
174
179
|
m DEM strip of the desired ArcticDEM/REMA DEM strip as an xarray DataArray.
|
|
@@ -190,6 +195,9 @@ def from_search(
|
|
|
190
195
|
:param pad: If the DEM strip is not the full extent of the given bounds,
|
|
191
196
|
pad with NaNs to match the full bounds. Defaults to False.
|
|
192
197
|
:type pad: bool
|
|
198
|
+
:param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
|
|
199
|
+
parallelisation and lazy evaluation/loading. Defaults to `None`.
|
|
200
|
+
:type chunks: int | tuple | dict
|
|
193
201
|
|
|
194
202
|
:returns: xarray DataArray of DEM strip
|
|
195
203
|
:rtype: DataArray
|
|
@@ -223,6 +231,7 @@ def from_search(
|
|
|
223
231
|
bounds,
|
|
224
232
|
bitmask_url,
|
|
225
233
|
pad,
|
|
234
|
+
chunks,
|
|
226
235
|
)
|
|
227
236
|
|
|
228
237
|
|
|
@@ -236,6 +245,7 @@ def from_id(
|
|
|
236
245
|
version: Optional[str] = "s2s041",
|
|
237
246
|
preview: Optional[bool] = False,
|
|
238
247
|
pad: Optional[bool] = False,
|
|
248
|
+
chunks: Optional[Union[int, tuple, dict]] = None,
|
|
239
249
|
) -> DataArray:
|
|
240
250
|
"""An alternative method of loading the selected ArcticDEM/REMA strip, which
|
|
241
251
|
requires only the geocell and the dem_id (e.g. ``geocell = 'n70w051'``, ``dem_id =
|
|
@@ -270,6 +280,9 @@ def from_id(
|
|
|
270
280
|
:param pad: If the DEM strip is not the full extent of the given bounds,
|
|
271
281
|
pad with NaNs to match the full bounds. Defaults to False.
|
|
272
282
|
:type pad: bool
|
|
283
|
+
:param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
|
|
284
|
+
parallelisation and lazy evaluation/loading. Defaults to `None`.
|
|
285
|
+
:type chunks: int | tuple | dict
|
|
273
286
|
|
|
274
287
|
:return: xarray DataArray of DEM strip
|
|
275
288
|
:rtype: DataArray
|
|
@@ -309,6 +322,7 @@ def from_id(
|
|
|
309
322
|
bounds,
|
|
310
323
|
bitmask_fpath,
|
|
311
324
|
pad,
|
|
325
|
+
chunks,
|
|
312
326
|
)
|
|
313
327
|
|
|
314
328
|
|
|
@@ -317,6 +331,7 @@ def mosaic(
|
|
|
317
331
|
resolution: Literal["2m", "10m", "32m"],
|
|
318
332
|
bounds: Union[tuple, Polygon] = None,
|
|
319
333
|
version: Optional[Literal["v2.0", "v3.0", "v4.1"]] = None,
|
|
334
|
+
chunks: Optional[Union[int, tuple, dict]] = None,
|
|
320
335
|
):
|
|
321
336
|
"""Given a dataset, resolution, and bounding box, downloads the ArcticDEM or REMA
|
|
322
337
|
mosiac from AWS.
|
|
@@ -333,6 +348,12 @@ def mosaic(
|
|
|
333
348
|
:param bounds: Clip to bounds [xmin, ymin, xmax, ymax], in EPSG:3413 (ArcticDEM) or
|
|
334
349
|
EPSG:3031 (REMA). Will accept a shapely geometry to extract bounds from.
|
|
335
350
|
:type bounds: tuple | Polygon, optional
|
|
351
|
+
:param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
|
|
352
|
+
parallelisation and lazy evaluation/loading. Defaults to `None`.
|
|
353
|
+
:type chunks: int | tuple | dict
|
|
354
|
+
|
|
355
|
+
:return: xarray DataArray of DEM mosaic
|
|
356
|
+
:rtype: DataArray
|
|
336
357
|
"""
|
|
337
358
|
|
|
338
359
|
# sanity check that datset and versioning is correct versioning is valid for selected dataset
|
|
@@ -382,7 +403,7 @@ def mosaic(
|
|
|
382
403
|
|
|
383
404
|
if len(tiles) < 1:
|
|
384
405
|
raise ValueError(
|
|
385
|
-
"No {dataset} mosaic tiles found to intersect with bounds {aoi}"
|
|
406
|
+
f"No {dataset} mosaic tiles found to intersect with bounds {aoi}"
|
|
386
407
|
)
|
|
387
408
|
|
|
388
409
|
# get aws filepaths from the tiles dataframe
|
|
@@ -401,13 +422,14 @@ def mosaic(
|
|
|
401
422
|
# load dem(s)
|
|
402
423
|
dems = []
|
|
403
424
|
for fpath in fpaths:
|
|
404
|
-
dem = rxr.open_rasterio(fpath).rio.clip_box(*bounds)
|
|
425
|
+
dem = rxr.open_rasterio(fpath, chunks=chunks).rio.clip_box(*bounds)
|
|
405
426
|
dems.append(dem)
|
|
406
427
|
|
|
407
428
|
if len(fpaths) == 1:
|
|
408
|
-
dem = rxr.open_rasterio(fpaths[0]).rio.clip_box(*bounds)
|
|
429
|
+
dem = rxr.open_rasterio(fpaths[0], chunks=chunks).rio.clip_box(*bounds)
|
|
409
430
|
|
|
410
|
-
# If multiple dems, merge them
|
|
431
|
+
# If multiple dems, merge them - NB I don't know whether this breaks lazy
|
|
432
|
+
# evaluation for chunked data
|
|
411
433
|
if len(dems) > 1:
|
|
412
434
|
dem = merge_arrays(dems)
|
|
413
435
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pdemtools
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Conveniently search, download, and preprocess ArcticDEM and REMA products.
|
|
5
5
|
Author-email: Tom Chudley <thomas.r.chudley@durham.ac.uk>
|
|
6
6
|
License: MIT
|
|
@@ -31,6 +31,7 @@ Requires-Dist: scipy
|
|
|
31
31
|
Requires-Dist: numba
|
|
32
32
|
Requires-Dist: pyarrow
|
|
33
33
|
Requires-Dist: fiona
|
|
34
|
+
Dynamic: license-file
|
|
34
35
|
|
|
35
36
|
# pDEMtools
|
|
36
37
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/mosaic_index/ArcticDEM_Mosaic_Index_v3_gpkg.gpkg
RENAMED
|
File without changes
|
{pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/mosaic_index/ArcticDEM_Mosaic_Index_v4_1_gpkg.gpkg
RENAMED
|
File without changes
|
{pdemtools-1.0.0 → pdemtools-1.1.0}/src/pdemtools/mosaic_index/REMA_Mosaic_Index_v2_gpkg.gpkg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|