geometamaker 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
@@ -39,6 +39,12 @@ PROTOCOLS = [
39
39
  DT_FMT = '%Y-%m-%d %H:%M:%S %Z'
40
40
 
41
41
 
42
+ def _gdal_progress_callback(complete, message, data):
43
+ percentage = complete * 100
44
+ if (percentage > 0) & (percentage % 5 == 0):
45
+ LOGGER.info(f'{message} {percentage}%')
46
+
47
+
42
48
  # TODO: In the future we can remove these exception managers in favor of the
43
49
  # builtin gdal.ExceptionMgr. It was released in 3.7.0 and debugged in 3.9.1.
44
50
  # https://github.com/OSGeo/gdal/blob/v3.9.3/NEWS.md#gdalogr-391-release-notes
@@ -203,7 +209,10 @@ def detect_file_type(filepath, scheme):
203
209
  # We'll likely want a different data model for multi-dimensional arrays.
204
210
  # Frictionless supports a wide range of formats. The quickest way to
205
211
  # determine if a file is recognized as a table or archive is to call list.
206
- info = frictionless.list(filepath)[0]
212
+ try:
213
+ info = frictionless.list(filepath)[0]
214
+ except frictionless.FrictionlessException:
215
+ raise RuntimeError(f'Cannot detect file type of "{filepath}"')
207
216
  if info.type == 'table':
208
217
  return 'table'
209
218
  # Frictionless doesn't recognize .tgz compression (but does recognize .tar.gz)
@@ -259,7 +268,7 @@ def describe_file(source_dataset_path, scheme):
259
268
  hash_func = hashlib.new('sha256')
260
269
  hash_func.update(
261
270
  f'{description["bytes"]}{description["last_modified"]}\
262
- {description["path"]}'.encode('ascii'))
271
+ {description["path"]}'.encode('utf-8'))
263
272
  description['uid'] = f'sizetimestamp:{hash_func.hexdigest()}'
264
273
 
265
274
  # We don't have a use for including these attributes in our metadata:
@@ -388,18 +397,24 @@ def describe_raster(source_dataset_path, scheme, **kwargs):
388
397
  for i in range(info['n_bands']):
389
398
  b = i + 1
390
399
  band = raster.GetRasterBand(b)
400
+ band_gdal_metadata = band.GetMetadata()
391
401
  if compute_stats:
392
402
  try:
393
- # 0=do not approximate stats, 1=calculate if they don't exist
394
- # If exact stats exist they will be retrieved without
395
- # computing them, otherwise, this forces computation.
396
- # https://github.com/OSGeo/gdal/blob/master/gcore/gdalrasterband.cpp
397
- _ = band.GetStatistics(0, 1)
403
+ if not 'STATISTICS_VALID_PERCENT' in band_gdal_metadata:
404
+ # Sometimes some stats exist, but not all. If this one doesn't,
405
+ # it's important enough that we want to force computation.
406
+ _ = band.ComputeStatistics(0, callback=_gdal_progress_callback)
407
+ else:
408
+ # 0=do not approximate stats, 1=calculate if they don't exist
409
+ # If exact stats exist they will be retrieved without
410
+ # computing them, otherwise, this forces computation.
411
+ # https://github.com/OSGeo/gdal/blob/master/gcore/gdalrasterband.cpp
412
+ _ = band.GetStatistics(0, 1)
413
+ band_gdal_metadata = band.GetMetadata()
398
414
  except RuntimeError as e:
399
415
  LOGGER.warning(
400
416
  f'Could not compute statistics for band {b} of '
401
417
  f'{source_dataset_path}: {e}')
402
- band_gdal_metadata = band.GetMetadata()
403
418
 
404
419
  bands.append(models.BandSchema(
405
420
  index=b,
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geometamaker
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: metadata creation for geospatial data
5
- Maintainer: Natural Capital Project Software Team
5
+ Maintainer: Natural Capital Alliance Software Team
6
6
  License:
7
7
  Apache License
8
8
  Version 2.0, January 2004
@@ -215,11 +215,11 @@ Classifier: Operating System :: MacOS :: MacOS X
215
215
  Classifier: Operating System :: Microsoft
216
216
  Classifier: Operating System :: POSIX
217
217
  Classifier: Programming Language :: Python :: 3
218
- Classifier: Programming Language :: Python :: 3.9
219
218
  Classifier: Programming Language :: Python :: 3.10
220
219
  Classifier: Programming Language :: Python :: 3.11
221
220
  Classifier: Programming Language :: Python :: 3.12
222
221
  Classifier: Programming Language :: Python :: 3.13
222
+ Classifier: Programming Language :: Python :: 3.14
223
223
  Classifier: License :: OSI Approved :: Apache Software License
224
224
  Classifier: Topic :: Scientific/Engineering :: GIS
225
225
  Requires-Python: >=3.9
@@ -1,12 +1,12 @@
1
1
  geometamaker/__init__.py,sha256=fs8_0Wj-NfHHyK-wd5UHzMnCK2HxI0uWR_KtSbb8xXs,405
2
2
  geometamaker/cli.py,sha256=FGwrwBxJV269G509w2qvNNVbdMpxKHZv671M5ojeryE,10339
3
3
  geometamaker/config.py,sha256=KrDOFm_Wa15iZAmDxpy_yizBW3oIf0irqAVirFGWGLY,1964
4
- geometamaker/geometamaker.py,sha256=EuI1Nwgh6L1cNwNeyJhUm59JXWiqbc9XHKw7zpEWYLs,28344
4
+ geometamaker/geometamaker.py,sha256=OrBAjjqyXQZvUjUI8lkWEbGNxjZ4Cxpj0S8JIRn69yk,29093
5
5
  geometamaker/models.py,sha256=TF47XNKBhnSUScNXC3jk1Op_Icu7otLahApF3Kv0Hz0,27232
6
6
  geometamaker/utils.py,sha256=RLFtobLdUAeJEKBnzsQmC2h-eJTYn22tjNPAq261EhE,932
7
- geometamaker-0.2.0.dist-info/licenses/LICENSE.txt,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
8
- geometamaker-0.2.0.dist-info/METADATA,sha256=-tSGY0ik9gLL_Lc0RpEf_RiPNRQoL41CP9MKZ53SrzE,19090
9
- geometamaker-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- geometamaker-0.2.0.dist-info/entry_points.txt,sha256=fY8nmpxmOO5kA47EBpKBKzaq3uZ1tWPA1sBgRJKvVU4,54
11
- geometamaker-0.2.0.dist-info/top_level.txt,sha256=cm34aKGvrHyEgqNXi3Cx9LTU1Sm79r1RkpQZpy9MoxA,13
12
- geometamaker-0.2.0.dist-info/RECORD,,
7
+ geometamaker-0.2.1.dist-info/licenses/LICENSE.txt,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
8
+ geometamaker-0.2.1.dist-info/METADATA,sha256=QOcEsvUNd4Zh-IRzkKBHwlSD5PrbLrCyKrL7F71Pd8s,19092
9
+ geometamaker-0.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ geometamaker-0.2.1.dist-info/entry_points.txt,sha256=fY8nmpxmOO5kA47EBpKBKzaq3uZ1tWPA1sBgRJKvVU4,54
11
+ geometamaker-0.2.1.dist-info/top_level.txt,sha256=cm34aKGvrHyEgqNXi3Cx9LTU1Sm79r1RkpQZpy9MoxA,13
12
+ geometamaker-0.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5