NASADEM 2.1.0__tar.gz → 2.2.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.
- {nasadem-2.1.0 → nasadem-2.2.0}/.github/workflows/ci.yml +1 -1
- nasadem-2.2.0/.github/workflows/python-publish.yml +30 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/.gitignore +2 -1
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM/NASADEM.py +78 -86
- {nasadem-2.1.0 → nasadem-2.2.0/NASADEM.egg-info}/PKG-INFO +40 -17
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM.egg-info/SOURCES.txt +5 -2
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM.egg-info/requires.txt +3 -4
- {nasadem-2.1.0/NASADEM.egg-info → nasadem-2.2.0}/PKG-INFO +40 -17
- {nasadem-2.1.0 → nasadem-2.2.0}/README.md +36 -12
- nasadem-2.2.0/docs/Changelog.md +81 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/docs/Migration-Guide.md +9 -119
- nasadem-2.2.0/docs/Release-Summary.md +38 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/makefile +7 -20
- nasadem-2.2.0/notes/2026-11-20 NASADEM development plan.md +47 -0
- nasadem-2.2.0/notes/2026-11-20 NASADEM known issues.md +57 -0
- nasadem-2.2.0/notes/2026-11-20 NASADEM repository history.md +69 -0
- nasadem-2.2.0/notes/2026-11-20 known issues.md +52 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/pyproject.toml +5 -6
- nasadem-2.2.0/tests/test_nasadem_elevation.py +40 -0
- nasadem-2.2.0/tests/test_nasadem_v2.py +297 -0
- nasadem-2.1.0/.github/workflows/python-publish.yml +0 -39
- nasadem-2.1.0/debug.py +0 -8
- nasadem-2.1.0/docs/Changelog.md +0 -99
- nasadem-2.1.0/docs/Release-Summary.md +0 -244
- nasadem-2.1.0/test_nasadem_elevation.py +0 -129
- nasadem-2.1.0/tests/test_nasadem_v2.py +0 -224
- {nasadem-2.1.0 → nasadem-2.2.0}/.github/.DS_Store +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/LICENSE +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM/__init__.py +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM/version.py +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM.egg-info/dependency_links.txt +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/NASADEM.egg-info/top_level.txt +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/debug/debug_point_extraction.py +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/notebooks/Extract Point.ipynb +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/notebooks/Generate a tile of elevation.ipynb +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/setup.cfg +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/tests/test_import_NASADEM.py +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/tests/test_import_dependencies.py +0 -0
- {nasadem-2.1.0 → nasadem-2.2.0}/tox.ini +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
deploy:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.13"
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip
|
|
23
|
+
pip install build
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: python -m build
|
|
26
|
+
- name: Publish package
|
|
27
|
+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
|
|
28
|
+
with:
|
|
29
|
+
user: __token__
|
|
30
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -21,6 +21,7 @@ DEFAULT_DOWNLOAD_DIRECTORY = DEFAULT_WORKING_DIRECTORY
|
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
class NASADEMGranule:
|
|
25
26
|
def __init__(self, filename: str):
|
|
26
27
|
if not exists(filename):
|
|
@@ -37,7 +38,6 @@ class NASADEMGranule:
|
|
|
37
38
|
def hgt_URI(self) -> str:
|
|
38
39
|
return f"zip://{self.filename}!/{self.tile.lower()}.hgt"
|
|
39
40
|
|
|
40
|
-
|
|
41
41
|
def get_elevation_m(self, geometry: Union[RasterGeometry, Point, MultiPoint] = None) -> Raster:
|
|
42
42
|
URI = self.hgt_URI
|
|
43
43
|
logger.info(f"loading elevation: {cl.URL(URI)}")
|
|
@@ -52,10 +52,6 @@ class NASADEMGranule:
|
|
|
52
52
|
|
|
53
53
|
elevation_m = property(get_elevation_m)
|
|
54
54
|
|
|
55
|
-
# @property
|
|
56
|
-
# def ocean(self) -> Raster:
|
|
57
|
-
# return self.elevation_m == 0
|
|
58
|
-
|
|
59
55
|
@property
|
|
60
56
|
def geometry(self) -> RasterGrid:
|
|
61
57
|
if self._geometry is None:
|
|
@@ -69,7 +65,7 @@ class NASADEMGranule:
|
|
|
69
65
|
|
|
70
66
|
def get_swb(self, geometry: Union[RasterGeometry, Point, MultiPoint] = None) -> Raster:
|
|
71
67
|
URI = self.swb_URI
|
|
72
|
-
|
|
68
|
+
|
|
73
69
|
if geometry is None:
|
|
74
70
|
geometry = self.geometry
|
|
75
71
|
|
|
@@ -84,7 +80,7 @@ class NASADEMGranule:
|
|
|
84
80
|
data = data != 0
|
|
85
81
|
|
|
86
82
|
return data
|
|
87
|
-
|
|
83
|
+
|
|
88
84
|
swb = property(get_swb)
|
|
89
85
|
|
|
90
86
|
|
|
@@ -95,7 +91,7 @@ class TileNotAvailable(ValueError):
|
|
|
95
91
|
class NASADEMConnection:
|
|
96
92
|
"""
|
|
97
93
|
Connection to NASADEM data using NASA's earthaccess package.
|
|
98
|
-
|
|
94
|
+
|
|
99
95
|
This class provides methods to search, download, and extract elevation data
|
|
100
96
|
from the NASADEM dataset via NASA's Earthdata Cloud infrastructure.
|
|
101
97
|
"""
|
|
@@ -110,7 +106,7 @@ class NASADEMConnection:
|
|
|
110
106
|
skip_auth: bool = False):
|
|
111
107
|
"""
|
|
112
108
|
Initialize NASADEM connection.
|
|
113
|
-
|
|
109
|
+
|
|
114
110
|
Args:
|
|
115
111
|
username: NASA Earthdata username (optional, can use .netrc or env vars)
|
|
116
112
|
password: NASA Earthdata password (optional, can use .netrc or env vars)
|
|
@@ -119,22 +115,17 @@ class NASADEMConnection:
|
|
|
119
115
|
persist_credentials: Whether to persist credentials to .netrc file
|
|
120
116
|
skip_auth: Skip authentication (useful for testing or when auth is handled separately)
|
|
121
117
|
"""
|
|
122
|
-
# Authenticate with earthaccess (unless explicitly skipped)
|
|
123
118
|
if not skip_auth:
|
|
124
|
-
# Check if we're in a non-interactive environment (like CI)
|
|
125
|
-
# by checking for common CI environment variables
|
|
126
119
|
is_ci = any([
|
|
127
120
|
os.environ.get('CI'),
|
|
128
121
|
os.environ.get('GITHUB_ACTIONS'),
|
|
129
122
|
os.environ.get('TRAVIS'),
|
|
130
123
|
os.environ.get('CIRCLECI'),
|
|
131
124
|
])
|
|
132
|
-
|
|
133
|
-
# Only attempt login if we have credentials or are not in CI
|
|
125
|
+
|
|
134
126
|
if username and password:
|
|
135
127
|
earthaccess.login(username=username, password=password, persist=persist_credentials)
|
|
136
128
|
elif not is_ci:
|
|
137
|
-
# Will use .netrc, environment variables, or prompt interactively
|
|
138
129
|
earthaccess.login(persist=persist_credentials)
|
|
139
130
|
|
|
140
131
|
if working_directory is None:
|
|
@@ -152,7 +143,7 @@ class NASADEMConnection:
|
|
|
152
143
|
"working_directory": self.working_directory
|
|
153
144
|
}
|
|
154
145
|
return json.dumps(display_dict, indent=2)
|
|
155
|
-
|
|
146
|
+
|
|
156
147
|
def tile_filename(self, tile: str) -> str:
|
|
157
148
|
"""Get the local filename for a tile."""
|
|
158
149
|
return join(
|
|
@@ -163,25 +154,24 @@ class NASADEMConnection:
|
|
|
163
154
|
def search_tile(self, tile: str):
|
|
164
155
|
"""
|
|
165
156
|
Search for a NASADEM tile using earthaccess.
|
|
166
|
-
|
|
157
|
+
|
|
167
158
|
Args:
|
|
168
159
|
tile: Tile identifier (e.g., 'n34w118', 's10e142')
|
|
169
|
-
|
|
160
|
+
|
|
170
161
|
Returns:
|
|
171
162
|
earthaccess granule result or None if not found
|
|
172
163
|
"""
|
|
173
164
|
try:
|
|
174
|
-
# Search for the granule by tile name
|
|
175
165
|
results = earthaccess.search_data(
|
|
176
166
|
short_name='NASADEM_HGT',
|
|
177
167
|
version='001',
|
|
178
168
|
granule_name=f'*{tile.upper()}*'
|
|
179
169
|
)
|
|
180
|
-
|
|
170
|
+
|
|
181
171
|
if results:
|
|
182
172
|
return results[0]
|
|
183
173
|
return None
|
|
184
|
-
|
|
174
|
+
|
|
185
175
|
except Exception as e:
|
|
186
176
|
logger.warning(f"Error searching for tile {tile}: {e}")
|
|
187
177
|
return None
|
|
@@ -189,8 +179,20 @@ class NASADEMConnection:
|
|
|
189
179
|
def tiles_intersecting_bbox(self, lon_min, lat_min, lon_max, lat_max):
|
|
190
180
|
tiles = []
|
|
191
181
|
|
|
192
|
-
|
|
193
|
-
|
|
182
|
+
lat_start = int(np.floor(lat_min))
|
|
183
|
+
if lat_max > lat_min and float(lat_max).is_integer():
|
|
184
|
+
lat_end = int(lat_max) - 1
|
|
185
|
+
else:
|
|
186
|
+
lat_end = int(np.floor(lat_max))
|
|
187
|
+
|
|
188
|
+
lon_start = int(np.floor(lon_min))
|
|
189
|
+
if lon_max > lon_min and float(lon_max).is_integer():
|
|
190
|
+
lon_end = int(lon_max) - 1
|
|
191
|
+
else:
|
|
192
|
+
lon_end = int(np.floor(lon_max))
|
|
193
|
+
|
|
194
|
+
for lat in range(lat_start, lat_end + 1):
|
|
195
|
+
for lon in range(lon_start, lon_end + 1):
|
|
194
196
|
tiles.append(f"{'s' if lat < 0 else 'n'}{abs(lat):02d}{'w' if lon < 0 else 'e'}{abs(lon):03d}")
|
|
195
197
|
|
|
196
198
|
tiles = sorted(tiles)
|
|
@@ -225,13 +227,13 @@ class NASADEMConnection:
|
|
|
225
227
|
def download_tile(self, tile: str) -> NASADEMGranule:
|
|
226
228
|
"""
|
|
227
229
|
Download a NASADEM tile using earthaccess.
|
|
228
|
-
|
|
230
|
+
|
|
229
231
|
Args:
|
|
230
232
|
tile: Tile identifier (e.g., 'n34w118', 's10e142')
|
|
231
|
-
|
|
233
|
+
|
|
232
234
|
Returns:
|
|
233
235
|
NASADEMGranule object for the downloaded tile
|
|
234
|
-
|
|
236
|
+
|
|
235
237
|
Raises:
|
|
236
238
|
TileNotAvailable: If the tile doesn't exist or can't be downloaded
|
|
237
239
|
"""
|
|
@@ -239,33 +241,30 @@ class NASADEMConnection:
|
|
|
239
241
|
|
|
240
242
|
if not exists(filename):
|
|
241
243
|
logger.info(f"acquiring NASADEM tile: {cl.val(tile)}")
|
|
242
|
-
|
|
243
|
-
# Search for the granule
|
|
244
|
+
|
|
244
245
|
granule = self.search_tile(tile)
|
|
245
|
-
|
|
246
|
+
|
|
246
247
|
if not granule:
|
|
247
248
|
raise TileNotAvailable(f"NASADEM does not cover tile {tile}")
|
|
248
|
-
|
|
249
|
+
|
|
249
250
|
try:
|
|
250
|
-
# Download the file using earthaccess
|
|
251
251
|
files = earthaccess.download(
|
|
252
252
|
granule,
|
|
253
253
|
local_path=self.download_directory
|
|
254
254
|
)
|
|
255
|
-
|
|
255
|
+
|
|
256
256
|
if files:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if downloaded_file != filename:
|
|
257
|
+
downloaded_path = abspath(str(files[0]))
|
|
258
|
+
target_path = abspath(filename)
|
|
259
|
+
|
|
260
|
+
if downloaded_path != target_path:
|
|
262
261
|
import shutil
|
|
263
|
-
shutil.move(
|
|
264
|
-
|
|
262
|
+
shutil.move(downloaded_path, target_path)
|
|
263
|
+
|
|
265
264
|
logger.info(f"downloaded NASADEM tile: {cl.file(filename)}")
|
|
266
265
|
else:
|
|
267
266
|
raise TileNotAvailable(f"Failed to download tile {tile}")
|
|
268
|
-
|
|
267
|
+
|
|
269
268
|
except Exception as e:
|
|
270
269
|
logger.error(f"Error downloading tile {tile}: {e}")
|
|
271
270
|
raise TileNotAvailable(f"Failed to download tile {tile}: {e}")
|
|
@@ -275,16 +274,16 @@ class NASADEMConnection:
|
|
|
275
274
|
def swb(self, geometry: Union[RasterGeometry, Point, MultiPoint]):
|
|
276
275
|
"""
|
|
277
276
|
Surface water body from NASADEM.
|
|
278
|
-
|
|
277
|
+
|
|
279
278
|
Args:
|
|
280
279
|
geometry: Target geometry (RasterGeometry, Point, or MultiPoint)
|
|
281
|
-
|
|
280
|
+
|
|
282
281
|
Returns:
|
|
283
282
|
Boolean raster for RasterGeometry, boolean value(s) for Point/MultiPoint
|
|
284
283
|
"""
|
|
285
284
|
if isinstance(geometry, (Point, MultiPoint)):
|
|
286
285
|
return self._extract_point_values(geometry, 'swb')
|
|
287
|
-
|
|
286
|
+
|
|
288
287
|
result = Raster(np.full(geometry.shape, np.nan, dtype=np.float32), geometry=geometry)
|
|
289
288
|
tiles = self.tiles(geometry)
|
|
290
289
|
|
|
@@ -294,7 +293,7 @@ class NASADEMConnection:
|
|
|
294
293
|
except TileNotAvailable as e:
|
|
295
294
|
logger.warning(e)
|
|
296
295
|
continue
|
|
297
|
-
|
|
296
|
+
|
|
298
297
|
image = granule.swb.astype(np.float32)
|
|
299
298
|
image_projected = image.to_geometry(geometry)
|
|
300
299
|
result = rasters.where(np.isnan(result), image_projected, result)
|
|
@@ -307,16 +306,16 @@ class NASADEMConnection:
|
|
|
307
306
|
def elevation_m(self, geometry: Union[RasterGeometry, Point, MultiPoint]):
|
|
308
307
|
"""
|
|
309
308
|
Digital elevation model in meters from NASADEM.
|
|
310
|
-
|
|
309
|
+
|
|
311
310
|
Args:
|
|
312
311
|
geometry: Target geometry (RasterGeometry, Point, or MultiPoint)
|
|
313
|
-
|
|
312
|
+
|
|
314
313
|
Returns:
|
|
315
314
|
Elevation raster for RasterGeometry, elevation value(s) for Point/MultiPoint
|
|
316
315
|
"""
|
|
317
316
|
if isinstance(geometry, (Point, MultiPoint)):
|
|
318
317
|
return self._extract_point_values(geometry, 'elevation_m')
|
|
319
|
-
|
|
318
|
+
|
|
320
319
|
result = None
|
|
321
320
|
tiles = self.tiles(geometry)
|
|
322
321
|
|
|
@@ -339,10 +338,10 @@ class NASADEMConnection:
|
|
|
339
338
|
def elevation_km(self, geometry: Union[RasterGeometry, Point, MultiPoint]):
|
|
340
339
|
"""
|
|
341
340
|
Digital elevation model in kilometers from NASADEM.
|
|
342
|
-
|
|
341
|
+
|
|
343
342
|
Args:
|
|
344
343
|
geometry: Target geometry (RasterGeometry, Point, or MultiPoint)
|
|
345
|
-
|
|
344
|
+
|
|
346
345
|
Returns:
|
|
347
346
|
Elevation raster in km for RasterGeometry, elevation value(s) in km for Point/MultiPoint
|
|
348
347
|
"""
|
|
@@ -351,41 +350,40 @@ class NASADEMConnection:
|
|
|
351
350
|
def _extract_point_values(self, geometry: Union[Point, MultiPoint], data_type: str):
|
|
352
351
|
"""
|
|
353
352
|
Extract values at point locations from NASADEM data.
|
|
354
|
-
|
|
353
|
+
|
|
355
354
|
Args:
|
|
356
355
|
geometry: Point or MultiPoint geometry
|
|
357
356
|
data_type: 'elevation_m' or 'swb'
|
|
358
|
-
|
|
357
|
+
|
|
359
358
|
Returns:
|
|
360
359
|
Single value for Point, array of values for MultiPoint
|
|
361
360
|
"""
|
|
362
361
|
if isinstance(geometry, Point):
|
|
363
362
|
points = [geometry]
|
|
363
|
+
elif hasattr(geometry, 'x') and hasattr(geometry, 'y'):
|
|
364
|
+
xs = np.atleast_1d(geometry.x)
|
|
365
|
+
ys = np.atleast_1d(geometry.y)
|
|
366
|
+
points = [Point(float(x), float(y)) for x, y in zip(xs, ys)]
|
|
364
367
|
else:
|
|
365
368
|
points = [Point(geom.x, geom.y) for geom in geometry.geoms]
|
|
366
|
-
|
|
367
|
-
# Group points by tile to minimize data loading
|
|
369
|
+
|
|
368
370
|
from collections import defaultdict
|
|
369
371
|
points_by_tile = defaultdict(list)
|
|
370
|
-
|
|
372
|
+
|
|
371
373
|
for i, point in enumerate(points):
|
|
372
|
-
# Calculate which tile this point belongs to
|
|
373
374
|
lat, lon = point.y, point.x
|
|
374
375
|
tile = f"{'s' if lat < 0 else 'n'}{abs(int(np.floor(lat))):02d}{'w' if lon < 0 else 'e'}{abs(int(np.floor(lon))):03d}"
|
|
375
376
|
points_by_tile[tile].append((i, point))
|
|
376
|
-
|
|
377
|
-
# Initialize results array
|
|
377
|
+
|
|
378
378
|
values = [np.nan] * len(points)
|
|
379
|
-
|
|
380
|
-
# Process each tile only once
|
|
379
|
+
|
|
381
380
|
for tile, point_list in points_by_tile.items():
|
|
382
381
|
try:
|
|
383
382
|
granule = self.download_tile(tile)
|
|
384
383
|
except TileNotAvailable as e:
|
|
385
384
|
logger.warning(e)
|
|
386
385
|
continue
|
|
387
|
-
|
|
388
|
-
# Load the full tile data
|
|
386
|
+
|
|
389
387
|
try:
|
|
390
388
|
if data_type == 'elevation_m':
|
|
391
389
|
data_layer = granule.get_elevation_m(geometry=None)
|
|
@@ -393,62 +391,55 @@ class NASADEMConnection:
|
|
|
393
391
|
data_layer = granule.get_swb(geometry=None)
|
|
394
392
|
else:
|
|
395
393
|
raise ValueError(f"Unknown data type: {data_type}")
|
|
396
|
-
|
|
394
|
+
|
|
397
395
|
if not isinstance(data_layer, Raster):
|
|
398
396
|
logger.warning(f"Expected Raster, got {type(data_layer)}")
|
|
399
397
|
continue
|
|
400
|
-
|
|
401
|
-
# Extract values for all points in this tile
|
|
398
|
+
|
|
402
399
|
for idx, point in point_list:
|
|
403
400
|
try:
|
|
404
|
-
# Check if point is within tile bounds
|
|
405
401
|
tile_geometry = data_layer.geometry
|
|
406
|
-
if not (tile_geometry.x_min <= point.x <= tile_geometry.x_max and
|
|
402
|
+
if not (tile_geometry.x_min <= point.x <= tile_geometry.x_max and
|
|
407
403
|
tile_geometry.y_min <= point.y <= tile_geometry.y_max):
|
|
408
404
|
continue
|
|
409
|
-
|
|
410
|
-
# Convert geographic coordinates to pixel indices
|
|
405
|
+
|
|
411
406
|
row = int((tile_geometry.y_max - point.y) / abs(tile_geometry.cell_height))
|
|
412
407
|
col = int((point.x - tile_geometry.x_min) / abs(tile_geometry.cell_width))
|
|
413
|
-
|
|
414
|
-
# Clip to array bounds
|
|
408
|
+
|
|
415
409
|
row = max(0, min(row, data_layer.shape[0] - 1))
|
|
416
410
|
col = max(0, min(col, data_layer.shape[1] - 1))
|
|
417
|
-
|
|
418
|
-
# Extract the value
|
|
411
|
+
|
|
419
412
|
value = float(data_layer.array[row, col])
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
413
|
+
|
|
414
|
+
nodata = data_layer.nodata
|
|
415
|
+
is_nodata = nodata is not None and not np.isnan(nodata) and value == nodata
|
|
416
|
+
if not np.isnan(value) and not is_nodata:
|
|
423
417
|
values[idx] = value
|
|
424
|
-
|
|
418
|
+
|
|
425
419
|
except Exception as e:
|
|
426
420
|
logger.warning(f"Failed to sample point ({point.x}, {point.y}) from tile {tile}: {e}")
|
|
427
421
|
continue
|
|
428
|
-
|
|
422
|
+
|
|
429
423
|
except Exception as e:
|
|
430
424
|
logger.warning(f"Failed to load data from tile {tile}: {e}")
|
|
431
425
|
continue
|
|
432
|
-
|
|
433
|
-
# Apply post-processing for swb
|
|
426
|
+
|
|
434
427
|
if data_type == 'swb':
|
|
435
428
|
values = [bool(v != 0) if not np.isnan(v) else False for v in values]
|
|
436
|
-
|
|
437
|
-
# Return single value for Point, array for MultiPoint
|
|
429
|
+
|
|
438
430
|
if isinstance(geometry, Point):
|
|
439
431
|
return values[0]
|
|
440
432
|
else:
|
|
441
433
|
return np.array(values)
|
|
442
434
|
|
|
443
435
|
|
|
444
|
-
# Lazy-loaded global instance for convenience
|
|
445
436
|
_NASADEM_INSTANCE = None
|
|
446
437
|
|
|
438
|
+
|
|
447
439
|
def _get_default_instance():
|
|
448
440
|
"""Get or create the default NASADEM instance."""
|
|
449
441
|
global _NASADEM_INSTANCE
|
|
450
442
|
if _NASADEM_INSTANCE is None:
|
|
451
|
-
# In CI or testing environments, skip authentication by default
|
|
452
443
|
is_ci = any([
|
|
453
444
|
os.environ.get('CI'),
|
|
454
445
|
os.environ.get('GITHUB_ACTIONS'),
|
|
@@ -458,14 +449,15 @@ def _get_default_instance():
|
|
|
458
449
|
_NASADEM_INSTANCE = NASADEMConnection(skip_auth=is_ci)
|
|
459
450
|
return _NASADEM_INSTANCE
|
|
460
451
|
|
|
461
|
-
|
|
452
|
+
|
|
462
453
|
class _NASADEMProxy:
|
|
463
454
|
"""Proxy to lazily initialize the default NASADEM connection."""
|
|
464
|
-
|
|
455
|
+
|
|
465
456
|
def __getattr__(self, name):
|
|
466
457
|
return getattr(_get_default_instance(), name)
|
|
467
|
-
|
|
458
|
+
|
|
468
459
|
def __call__(self, *args, **kwargs):
|
|
469
460
|
return _get_default_instance()(*args, **kwargs)
|
|
470
461
|
|
|
462
|
+
|
|
471
463
|
NASADEM = _NASADEMProxy()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: NASADEM
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Shuttle Radar Topography Mission (SRTM) Digital Elevation Model (DEM) search and download utility
|
|
5
5
|
Author-email: "Gregory H. Halverson" <gregory.h.halverson@jpl.nasa.gov>
|
|
6
6
|
Project-URL: Homepage, https://github.com/JPL-Evapotranspiration-Algorithms/NASADEM
|
|
@@ -11,17 +11,16 @@ Description-Content-Type: text/markdown
|
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: colored-logging
|
|
13
13
|
Requires-Dist: earthaccess>=0.8.0
|
|
14
|
-
Requires-Dist: ECOv002_calval_tables
|
|
15
14
|
Requires-Dist: numpy
|
|
16
15
|
Requires-Dist: rasters>=1.17.1
|
|
17
|
-
Requires-Dist: sentinel-tiles
|
|
18
16
|
Requires-Dist: shapely
|
|
19
17
|
Provides-Extra: dev
|
|
20
18
|
Requires-Dist: build; extra == "dev"
|
|
19
|
+
Requires-Dist: ECOv002_calval_tables; extra == "dev"
|
|
20
|
+
Requires-Dist: jupyter; extra == "dev"
|
|
21
21
|
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
22
22
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: pytest; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
25
24
|
Requires-Dist: tox; extra == "dev"
|
|
26
25
|
Requires-Dist: twine; extra == "dev"
|
|
27
26
|
Dynamic: license-file
|
|
@@ -30,19 +29,21 @@ Dynamic: license-file
|
|
|
30
29
|
|
|
31
30
|
This Python package provides utilities for accessing and downloading Digital Elevation Model (DEM) data from the NASADEM dataset, which is a reprocessed version of the Shuttle Radar Topography Mission (SRTM) data.
|
|
32
31
|
|
|
33
|
-
**Version 2.
|
|
32
|
+
**Version 2.x** modernizes the package to use NASA's official [`earthaccess`](https://earthaccess.readthedocs.io/) library for reliable and efficient data access from NASA's Earthdata Cloud.
|
|
34
33
|
|
|
35
34
|
[Gregory H. Halverson](https://github.com/gregory-halverson-jpl) (they/them)<br>
|
|
36
35
|
[gregory.h.halverson@jpl.nasa.gov](mailto:gregory.h.halverson@jpl.nasa.gov)<br>
|
|
37
36
|
NASA Jet Propulsion Laboratory 329G
|
|
38
37
|
|
|
39
|
-
## What's New in v2.
|
|
38
|
+
## What's New in v2.x
|
|
40
39
|
|
|
41
|
-
- 🚀 **Modern Data Access**: Uses NASA's official `earthaccess` package
|
|
42
|
-
-
|
|
40
|
+
- 🚀 **Modern Data Access**: Uses NASA's official `earthaccess` package (`v2.0.0+`)
|
|
41
|
+
- ⚡ **Optimized Point Queries**: Tile-grouped point and multipoint extraction with direct pixel indexing (`v2.0.1+`)
|
|
42
|
+
- 📐 **Updated Raster Interface**: Bumped `rasters>=1.17.1` for improved bounding box handling (`v2.1.0`)
|
|
43
|
+
- 🛠️ **Hardened Geometry & Downloads**: Normalized `MultiPoint` extraction, exact integer bounding-box tile bounds, and streamlined dependencies (`v2.2.0`)
|
|
44
|
+
- ✅ **Reliable Downloads**: Built-in retry logic and error handling via `earthaccess`
|
|
43
45
|
- ☁️ **Cloud-Optimized**: Direct access to NASA Earthdata Cloud
|
|
44
46
|
- 🔐 **Simplified Authentication**: Multiple authentication options (`.netrc`, environment variables, interactive)
|
|
45
|
-
- 🗑️ **Removed Legacy Code**: Deprecated old LP DAAC connection methods
|
|
46
47
|
|
|
47
48
|
## Installation
|
|
48
49
|
|
|
@@ -53,7 +54,7 @@ pip install NASADEM
|
|
|
53
54
|
Or install from source:
|
|
54
55
|
|
|
55
56
|
```bash
|
|
56
|
-
git clone https://github.com/
|
|
57
|
+
git clone https://github.com/JPL-Evapotranspiration-Algorithms/NASADEM.git
|
|
57
58
|
cd NASADEM
|
|
58
59
|
pip install -e .
|
|
59
60
|
```
|
|
@@ -156,9 +157,9 @@ print(f"Elevation at point: {elevation:.1f} m")
|
|
|
156
157
|
|
|
157
158
|
# Multiple points
|
|
158
159
|
points = MultiPoint([
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
(-118.0, 34.0),
|
|
161
|
+
(-117.5, 33.8),
|
|
162
|
+
(-118.2, 34.2)
|
|
162
163
|
])
|
|
163
164
|
elevations = NASADEM.elevation_m(points)
|
|
164
165
|
print(f"Elevations: {elevations}")
|
|
@@ -226,6 +227,25 @@ Examples:
|
|
|
226
227
|
- `n34w118`: 34°N to 35°N, 118°W to 117°W (Los Angeles area)
|
|
227
228
|
- `s10e142`: 10°S to 9°S, 142°E to 143°E (Northern Australia)
|
|
228
229
|
|
|
230
|
+
## Release History
|
|
231
|
+
|
|
232
|
+
| Version | Release Date | Summary |
|
|
233
|
+
| :--- | :--- | :--- |
|
|
234
|
+
| **v2.2.0** | 2026-11-20 | Normalized `MultiPoint` extraction, fixed `Path` comparison and integer bbox tile boundaries, cleaned up dependencies |
|
|
235
|
+
| **v2.1.0** | 2026-01-13 | Fixed bounding box handling by updating `rasters>=1.17.1` |
|
|
236
|
+
| **v2.0.1** | 2025-12-19 | Fixed single-point `elevation_m()` routing and optimized multi-point extraction via tile grouping |
|
|
237
|
+
| **v2.0.0** | 2025-12-19 | Major rewrite replacing LP DAAC HTTP scraping with NASA's `earthaccess` package |
|
|
238
|
+
| **v1.5.0** | 2025-11-18 | Switched to dynamic package versioning (`importlib.metadata`) and cleaned up logging |
|
|
239
|
+
| **v1.4.0** | 2025-10-24 | Added `Point` and `MultiPoint` extraction and optional checksum enforcement |
|
|
240
|
+
| **v1.3.1** | 2025-09-28 | Fixed home directory (`~`) expansion in `NASADEMConnection` |
|
|
241
|
+
| **v1.3.0** | 2025-07-08 | Replaced `pycksum` with pure-Python POSIX `cksum` for Python 3.10–3.13 compatibility |
|
|
242
|
+
| **v1.2.1** | 2025-06-03 | Quieted directory initialization logging |
|
|
243
|
+
| **v1.2.0** | 2025-04-07 | Enabled `offline_ok=True` by default and local file existence checks |
|
|
244
|
+
| **v1.1.1** | 2025-03-25 | Added `NASADEM` singleton instance and warned instead of raising on missing credentials |
|
|
245
|
+
| **v1.0.1** | 2025-03-19 | Initial release |
|
|
246
|
+
|
|
247
|
+
See [notes/2026-11-20 NASADEM repository history.md](notes/2026-11-20%20NASADEM%20repository%20history.md) for the full commit-level development timeline.
|
|
248
|
+
|
|
229
249
|
## Migration from v1.x
|
|
230
250
|
|
|
231
251
|
If you're upgrading from v1.x:
|
|
@@ -246,7 +266,7 @@ nasadem = NASADEMConnection(
|
|
|
246
266
|
)
|
|
247
267
|
```
|
|
248
268
|
|
|
249
|
-
New code (v2.0):
|
|
269
|
+
New code (v2.0+):
|
|
250
270
|
```python
|
|
251
271
|
from NASADEM import NASADEMConnection
|
|
252
272
|
|
|
@@ -291,10 +311,13 @@ See [LICENSE](LICENSE) file.
|
|
|
291
311
|
|
|
292
312
|
## Documentation
|
|
293
313
|
|
|
294
|
-
- [Migration Guide](docs/Migration-Guide.md) - How to upgrade from v1.x to v2.
|
|
314
|
+
- [Migration Guide](docs/Migration-Guide.md) - How to upgrade from v1.x to v2.x
|
|
295
315
|
- [Changelog](docs/Changelog.md) - Version history and changes
|
|
296
316
|
- [Release Summary](docs/Release-Summary.md) - Detailed v2.0.0 release notes
|
|
317
|
+
- [Repository History](notes/2026-11-20%20NASADEM%20repository%20history.md) - Full development and release timeline
|
|
318
|
+
- [Development Plan](notes/2026-11-20%20NASADEM%20development%20plan.md) - Engineering roadmap through v2.2.0
|
|
319
|
+
- [Known Issues](notes/2026-11-20%20known%20issues.md) - Audit log of bugs, packaging items, and technical debt
|
|
297
320
|
|
|
298
321
|
## Contributing
|
|
299
322
|
|
|
300
|
-
Issues and pull requests are welcome at https://github.com/
|
|
323
|
+
Issues and pull requests are welcome at https://github.com/JPL-Evapotranspiration-Algorithms/NASADEM
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
.gitignore
|
|
2
2
|
LICENSE
|
|
3
3
|
README.md
|
|
4
|
-
debug.py
|
|
5
4
|
makefile
|
|
6
5
|
pyproject.toml
|
|
7
|
-
test_nasadem_elevation.py
|
|
8
6
|
tox.ini
|
|
9
7
|
.github/.DS_Store
|
|
10
8
|
.github/workflows/ci.yml
|
|
@@ -23,6 +21,11 @@ docs/Migration-Guide.md
|
|
|
23
21
|
docs/Release-Summary.md
|
|
24
22
|
notebooks/Extract Point.ipynb
|
|
25
23
|
notebooks/Generate a tile of elevation.ipynb
|
|
24
|
+
notes/2026-11-20 NASADEM development plan.md
|
|
25
|
+
notes/2026-11-20 NASADEM known issues.md
|
|
26
|
+
notes/2026-11-20 NASADEM repository history.md
|
|
27
|
+
notes/2026-11-20 known issues.md
|
|
26
28
|
tests/test_import_NASADEM.py
|
|
27
29
|
tests/test_import_dependencies.py
|
|
30
|
+
tests/test_nasadem_elevation.py
|
|
28
31
|
tests/test_nasadem_v2.py
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
colored-logging
|
|
2
2
|
earthaccess>=0.8.0
|
|
3
|
-
ECOv002_calval_tables
|
|
4
3
|
numpy
|
|
5
4
|
rasters>=1.17.1
|
|
6
|
-
sentinel-tiles
|
|
7
5
|
shapely
|
|
8
6
|
|
|
9
7
|
[dev]
|
|
10
8
|
build
|
|
9
|
+
ECOv002_calval_tables
|
|
10
|
+
jupyter
|
|
11
11
|
pytest>=6.0
|
|
12
12
|
pytest-cov
|
|
13
|
-
|
|
14
|
-
pytest
|
|
13
|
+
ruff
|
|
15
14
|
tox
|
|
16
15
|
twine
|