dggrid4py 0.5.1.dev0__tar.gz → 0.5.2__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.
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/PKG-INFO +1 -1
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/dggrid_runner.py +198 -60
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/pyproject.toml +1 -1
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/LICENSE +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/README.md +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/__init__.py +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/auxlat.py +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/igeo7.py +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/igeo7_ext.py +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/interrupt.py +0 -0
- {dggrid4py-0.5.1.dev0 → dggrid4py-0.5.2}/dggrid4py/tool.py +0 -0
|
@@ -189,7 +189,7 @@ DggsOutputCellLabelTypeT = DggsOutputCellLabelTypeV7T | DggsOutputCellLabelTypeV
|
|
|
189
189
|
DggsCellOutputControlT = Literal["OUTPUT_ALL", "OUTPUT_OCCUPIED"]
|
|
190
190
|
cell_output_controls = get_args(DggsCellOutputControlT)
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
DggsInputAddressTypeV7T = Literal[
|
|
193
193
|
'GEO', # geodetic coordinates -123.36 43.22 20300 Roseburg
|
|
194
194
|
'Q2DI', # quad number and (i, j) coordinates on that quad
|
|
195
195
|
'SEQNUM', # DGGS index - linear address (1 to size-of-DGG), not supported for parameter input_address_type if dggs_aperture_type is SEQUENCE
|
|
@@ -204,7 +204,36 @@ DggsInputAddressTypeT = Literal[
|
|
|
204
204
|
'ZORDER', # index system ZORDER especially useful for ISEA3H, ISEA4H and mixed aperture
|
|
205
205
|
'ZORDER_STRING' # numerical digits representation of ZORDER (as characters, not an integer)
|
|
206
206
|
]
|
|
207
|
-
|
|
207
|
+
input_address_types_v7 = get_args(DggsInputAddressTypeV7T)
|
|
208
|
+
|
|
209
|
+
DggsInputAddressTypeV8T = Literal[
|
|
210
|
+
'GEO', # geodetic coordinates -123.36 43.22 20300 Roseburg
|
|
211
|
+
'Q2DI', # quad number and (i, j) coordinates on that quad
|
|
212
|
+
'SEQNUM', # DGGS index - linear address (1 to size-of-DGG), not supported for parameter input_address_type if dggs_aperture_type is SEQUENCE
|
|
213
|
+
'INTERLEAVE', # digit-interleaved form of Q2DI, only supported for parameter output_address_type; only available for hexagonal aperture 3 and 4 grids
|
|
214
|
+
'PLANE', # (x, y) coordinates on unfolded ISEA plane, only supported for parameter output_address_type;
|
|
215
|
+
'Q2DD', # quad number and (x, y) coordinates on that quad
|
|
216
|
+
'PROJTRI', # PROJTRI - triangle number and (x, y) coordinates within that triangle on the ISEA plane
|
|
217
|
+
'VERTEX2DD', # vertex number, triangle number, and (x, y) coordinates on ISEA plane
|
|
218
|
+
'AIGEN', # Arc/Info Generate file format
|
|
219
|
+
'HIERNDX',
|
|
220
|
+
]
|
|
221
|
+
input_address_types_v8 = get_args(DggsInputAddressTypeV8T)
|
|
222
|
+
|
|
223
|
+
DggsInputAddressTypeT = DggsInputAddressTypeV7T | DggsInputAddressTypeV8T
|
|
224
|
+
|
|
225
|
+
input_extra_fields_v7 = {}
|
|
226
|
+
|
|
227
|
+
DggsInputHierNdxSystemT = Literal['Z3', 'Z7', 'ZORDER']
|
|
228
|
+
input_hier_ndx_systems = get_args(DggsInputHierNdxSystemT)
|
|
229
|
+
|
|
230
|
+
DggsInputHierNdxFormT = Literal['INT64', 'DIGIT_STRING']
|
|
231
|
+
input_hier_ndx_forms = get_args(DggsInputHierNdxFormT)
|
|
232
|
+
|
|
233
|
+
input_extra_fields_v8 = {
|
|
234
|
+
'input_hier_ndx_system': input_hier_ndx_systems,
|
|
235
|
+
'input_hier_ndx_form': input_hier_ndx_forms,
|
|
236
|
+
}
|
|
208
237
|
|
|
209
238
|
### CUSTOM args
|
|
210
239
|
DggsProjectionT = Literal["ISEA", "FULLER"]
|
|
@@ -270,8 +299,11 @@ DggridMetaConfigT = TypedDict(
|
|
|
270
299
|
"clip_cell_res": int,
|
|
271
300
|
"clip_cell_addresses": str,
|
|
272
301
|
"clip_region_files": str,
|
|
302
|
+
"clip_cell_densification": int,
|
|
273
303
|
"clipper_scale_factor": float,
|
|
274
304
|
"input_address_type": DggsInputAddressTypeT,
|
|
305
|
+
"input_hier_ndx_form": DggsInputHierNdxFormT,
|
|
306
|
+
"input_hier_ndx_system": DggsInputHierNdxSystemT,
|
|
275
307
|
"input_delimiter": str,
|
|
276
308
|
"input_file_name": str,
|
|
277
309
|
"input_files": str,
|
|
@@ -332,6 +364,13 @@ def __getattr__(name): # for backward compatibility helper/warning
|
|
|
332
364
|
DeprecationWarning
|
|
333
365
|
)
|
|
334
366
|
return output_address_types_v7
|
|
367
|
+
if name == 'input_address_types':
|
|
368
|
+
warnings.warn(
|
|
369
|
+
"Definitions 'input_address_types' has been deprecated. "
|
|
370
|
+
"Use the 'DGGRID.input_address_types' of desired version!",
|
|
371
|
+
DeprecationWarning
|
|
372
|
+
)
|
|
373
|
+
return output_address_types_v7
|
|
335
374
|
raise AttributeError(f"module {__name__} has no attribute {name}")
|
|
336
375
|
|
|
337
376
|
|
|
@@ -513,11 +552,18 @@ class Dggs:
|
|
|
513
552
|
'dggs_vert0_lat': 'pole_lat_deg',
|
|
514
553
|
'dggs_vert0_lon': 'pole_lon_deg',
|
|
515
554
|
'dggs_num_aperture_4_res': 'mixed_aperture_level',
|
|
555
|
+
'res': 'resolution',
|
|
516
556
|
# Add more aliases as needed
|
|
517
557
|
}, init=False, repr=False)
|
|
518
558
|
|
|
519
|
-
def _resolve_key(self, key: str) -> str:
|
|
559
|
+
def _resolve_key(self, key: str, strict: bool = False) -> str | None:
|
|
520
560
|
# If key is an alias, return canonical; else if it's a canonical, return as is
|
|
561
|
+
if strict:
|
|
562
|
+
if key in self._aliases:
|
|
563
|
+
return self._aliases[key]
|
|
564
|
+
elif key in self.__dataclass_fields__:
|
|
565
|
+
return key
|
|
566
|
+
return None
|
|
521
567
|
return self._aliases.get(key, key)
|
|
522
568
|
|
|
523
569
|
def set_par(self, par_key: str, par_value: DggridMetaConfigParameterT):
|
|
@@ -550,6 +596,19 @@ class Dggs:
|
|
|
550
596
|
def metafile(self) -> DggridMetafileT:
|
|
551
597
|
return copy.copy(dg_grid_meta(self))
|
|
552
598
|
|
|
599
|
+
def update(self, strict=False, **kwargs):
|
|
600
|
+
"""
|
|
601
|
+
Back propagate keyword parameters if they can be mapped to an attribute handled by this class.
|
|
602
|
+
|
|
603
|
+
:param strict:
|
|
604
|
+
If True, only keys that match existing attributes will be set.
|
|
605
|
+
If False, unknown keys will be set with provided name.
|
|
606
|
+
"""
|
|
607
|
+
for key, value in kwargs.items():
|
|
608
|
+
found = self._resolve_key(key, strict=strict)
|
|
609
|
+
if found:
|
|
610
|
+
self.set_par(found, value)
|
|
611
|
+
|
|
553
612
|
def dg_closest_res_to_area (self, area, resround,metric,show_info=True):
|
|
554
613
|
raise ValueError('not yet implemented')
|
|
555
614
|
|
|
@@ -603,6 +662,16 @@ class DGGRID(abc.ABC):
|
|
|
603
662
|
def output_extra_fields(self) -> dict[str, Iterable[DggridMetaConfigParameterT]]:
|
|
604
663
|
raise NotImplementedError
|
|
605
664
|
|
|
665
|
+
@property
|
|
666
|
+
@abc.abstractmethod
|
|
667
|
+
def input_address_types(self) -> Iterable[DggsInputAddressTypeT]:
|
|
668
|
+
raise NotImplementedError
|
|
669
|
+
|
|
670
|
+
@property
|
|
671
|
+
@abc.abstractmethod
|
|
672
|
+
def input_extra_fields(self) -> dict[str, Iterable[DggridMetaConfigParameterT]]:
|
|
673
|
+
raise NotImplementedError
|
|
674
|
+
|
|
606
675
|
def check_output_extra_fields(
|
|
607
676
|
self,
|
|
608
677
|
output_conf: DggridMetaConfigT | dict[str, DggridMetaConfigParameterT],
|
|
@@ -616,6 +685,19 @@ class DGGRID(abc.ABC):
|
|
|
616
685
|
output_conf_extra[conf] = out
|
|
617
686
|
return output_conf_extra
|
|
618
687
|
|
|
688
|
+
def check_input_extra_fields(
|
|
689
|
+
self,
|
|
690
|
+
input_conf: DggridMetaConfigT | dict[str, DggridMetaConfigParameterT],
|
|
691
|
+
) -> DggridMetaConfigT:
|
|
692
|
+
input_conf_extra: DggridMetaConfigT = {}
|
|
693
|
+
for conf, allowed in self.input_extra_fields.items():
|
|
694
|
+
if conf in input_conf:
|
|
695
|
+
_in = input_conf[conf]
|
|
696
|
+
if _in not in allowed:
|
|
697
|
+
raise ValueError(f"input_conf '{conf}' has invalid value '{_in}'. Allowed are {allowed}")
|
|
698
|
+
input_conf_extra[conf] = _in
|
|
699
|
+
return input_conf_extra
|
|
700
|
+
|
|
619
701
|
def check_gdal_support(self):
|
|
620
702
|
if self.has_gdal:
|
|
621
703
|
print(f"GDAL types should be possible: has GDAL={self.has_gdal}")
|
|
@@ -728,6 +810,7 @@ class DGGRID(abc.ABC):
|
|
|
728
810
|
metafile = []
|
|
729
811
|
metafile.append("dggrid_operation " + dggrid_operation)
|
|
730
812
|
|
|
813
|
+
dggs.update(**subset_conf, **output_conf)
|
|
731
814
|
dggs_config_meta = dggs.metafile
|
|
732
815
|
|
|
733
816
|
for cmd in dggs_config_meta:
|
|
@@ -771,7 +854,7 @@ class DGGRID(abc.ABC):
|
|
|
771
854
|
else:
|
|
772
855
|
raise ValueError('something is not correct in subset_conf')
|
|
773
856
|
|
|
774
|
-
if 'input_address_type' in subset_conf.keys() and subset_conf.get('input_address_type', 'NOPE') in input_address_types:
|
|
857
|
+
if 'input_address_type' in subset_conf.keys() and subset_conf.get('input_address_type', 'NOPE') in self.input_address_types:
|
|
775
858
|
metafile.append("input_address_type " + subset_conf['input_address_type'])
|
|
776
859
|
|
|
777
860
|
# join grid gen params add to metafile
|
|
@@ -867,7 +950,7 @@ class DGGRID(abc.ABC):
|
|
|
867
950
|
self,
|
|
868
951
|
dggs: Dggs,
|
|
869
952
|
subset_conf: DggridMetaConfigT,
|
|
870
|
-
**
|
|
953
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
871
954
|
) -> DggridApiOutputT:
|
|
872
955
|
"""
|
|
873
956
|
Address Conversion. Transform a file of locations from one address form (such as longitude/latitude) to another (such as DGG cell indexes).
|
|
@@ -885,7 +968,7 @@ class DGGRID(abc.ABC):
|
|
|
885
968
|
if (
|
|
886
969
|
'input_file_name' in subset_conf.keys() and
|
|
887
970
|
'input_address_type' in subset_conf.keys() and
|
|
888
|
-
subset_conf['input_address_type'] in input_address_types
|
|
971
|
+
subset_conf['input_address_type'] in self.input_address_types
|
|
889
972
|
):
|
|
890
973
|
for elem in filter(lambda x: x.startswith('input_') , subset_conf.keys()):
|
|
891
974
|
metafile.append(f"{elem} " + str(subset_conf[elem]))
|
|
@@ -893,9 +976,12 @@ class DGGRID(abc.ABC):
|
|
|
893
976
|
raise ValueError('no input filename or type given')
|
|
894
977
|
|
|
895
978
|
# join grid gen params add to metafile
|
|
896
|
-
subset_conf.update(specify_resolution(**
|
|
897
|
-
subset_conf.update(specify_orient_type_args(**
|
|
898
|
-
subset_conf.update(specify_topo_aperture(**
|
|
979
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
980
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
981
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
982
|
+
|
|
983
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
984
|
+
subset_conf.update(input_extras)
|
|
899
985
|
|
|
900
986
|
# transform output_types
|
|
901
987
|
if (
|
|
@@ -908,7 +994,7 @@ class DGGRID(abc.ABC):
|
|
|
908
994
|
else:
|
|
909
995
|
raise ValueError('no output filename or type given')
|
|
910
996
|
|
|
911
|
-
output_extras = self.check_output_extra_fields(
|
|
997
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
912
998
|
if output_extras:
|
|
913
999
|
for elem, value in output_extras.items():
|
|
914
1000
|
metafile.append(f"{elem} " + str(value))
|
|
@@ -930,7 +1016,7 @@ class DGGRID(abc.ABC):
|
|
|
930
1016
|
self,
|
|
931
1017
|
dggs: Dggs,
|
|
932
1018
|
subset_conf: DggridMetaConfigT,
|
|
933
|
-
**
|
|
1019
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
934
1020
|
) -> DggridApiOutputT:
|
|
935
1021
|
"""
|
|
936
1022
|
Point Value Binning. Bin a set of floating-point values associated with point locations into the cells of a DGG,
|
|
@@ -972,7 +1058,7 @@ class DGGRID(abc.ABC):
|
|
|
972
1058
|
if (
|
|
973
1059
|
'input_file_name' in subset_conf.keys() and
|
|
974
1060
|
'input_address_type' in subset_conf.keys() and
|
|
975
|
-
subset_conf['input_address_type'] in input_address_types
|
|
1061
|
+
subset_conf['input_address_type'] in self.input_address_types
|
|
976
1062
|
):
|
|
977
1063
|
for elem in filter(lambda x: x.startswith('input_') , subset_conf.keys()):
|
|
978
1064
|
metafile.append(f"{elem} " + subset_conf[elem])
|
|
@@ -980,9 +1066,12 @@ class DGGRID(abc.ABC):
|
|
|
980
1066
|
raise ValueError('no input filename or type given')
|
|
981
1067
|
|
|
982
1068
|
# join grid gen params add to metafile
|
|
983
|
-
subset_conf.update(specify_resolution(**
|
|
984
|
-
subset_conf.update(specify_orient_type_args(**
|
|
985
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1069
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1070
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1071
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1072
|
+
|
|
1073
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1074
|
+
subset_conf.update(input_extras)
|
|
986
1075
|
|
|
987
1076
|
# transform output_types
|
|
988
1077
|
if (
|
|
@@ -995,7 +1084,7 @@ class DGGRID(abc.ABC):
|
|
|
995
1084
|
else:
|
|
996
1085
|
raise ValueError('no output filename or type given')
|
|
997
1086
|
|
|
998
|
-
output_extras = self.check_output_extra_fields(
|
|
1087
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
999
1088
|
if output_extras:
|
|
1000
1089
|
for elem, value in output_extras.items():
|
|
1001
1090
|
metafile.append(f"{elem} " + str(value))
|
|
@@ -1017,7 +1106,7 @@ class DGGRID(abc.ABC):
|
|
|
1017
1106
|
self,
|
|
1018
1107
|
dggs: Dggs,
|
|
1019
1108
|
subset_conf: DggridMetaConfigT,
|
|
1020
|
-
**
|
|
1109
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1021
1110
|
) -> DggridApiOutputT:
|
|
1022
1111
|
"""
|
|
1023
1112
|
Presence/Absence Binning. Given a set of input files, each containing point locations associated with a particular class, DGGRID outputs,
|
|
@@ -1036,7 +1125,7 @@ class DGGRID(abc.ABC):
|
|
|
1036
1125
|
if (
|
|
1037
1126
|
'input_file_name' in subset_conf.keys() and
|
|
1038
1127
|
'input_address_type' in subset_conf.keys() and
|
|
1039
|
-
subset_conf['input_address_type'] in input_address_types
|
|
1128
|
+
subset_conf['input_address_type'] in self.input_address_types
|
|
1040
1129
|
):
|
|
1041
1130
|
for elem in filter(lambda x: x.startswith('input_') , subset_conf.keys()):
|
|
1042
1131
|
metafile.append(f"{elem} " + subset_conf[elem])
|
|
@@ -1044,9 +1133,12 @@ class DGGRID(abc.ABC):
|
|
|
1044
1133
|
raise ValueError('no input filename or type given')
|
|
1045
1134
|
|
|
1046
1135
|
# join grid gen params add to metafile
|
|
1047
|
-
subset_conf.update(specify_resolution(**
|
|
1048
|
-
subset_conf.update(specify_orient_type_args(**
|
|
1049
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1136
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1137
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1138
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1139
|
+
|
|
1140
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1141
|
+
subset_conf.update(input_extras)
|
|
1050
1142
|
|
|
1051
1143
|
# transform output_types
|
|
1052
1144
|
if (
|
|
@@ -1059,7 +1151,7 @@ class DGGRID(abc.ABC):
|
|
|
1059
1151
|
else:
|
|
1060
1152
|
raise ValueError('no output filename or type given')
|
|
1061
1153
|
|
|
1062
|
-
output_extras = self.check_output_extra_fields(
|
|
1154
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1063
1155
|
if output_extras:
|
|
1064
1156
|
for elem, value in output_extras.items():
|
|
1065
1157
|
metafile.append(f"{elem} " + str(value))
|
|
@@ -1184,7 +1276,7 @@ class DGGRID(abc.ABC):
|
|
|
1184
1276
|
clip_geom: "AnyGeometry" = None,
|
|
1185
1277
|
split_dateline: bool = False,
|
|
1186
1278
|
output_address_type: DggsOutputAddressTypeT | None = None,
|
|
1187
|
-
**
|
|
1279
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1188
1280
|
) -> gpd.GeoDataFrame:
|
|
1189
1281
|
"""
|
|
1190
1282
|
generates a DGGS grid and returns all the cells as GeoDataFrame with geometry type Polygon
|
|
@@ -1194,6 +1286,7 @@ class DGGRID(abc.ABC):
|
|
|
1194
1286
|
tmp_id = uuid.uuid4()
|
|
1195
1287
|
tmp_dir = self.working_dir
|
|
1196
1288
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1289
|
+
dggs.update(**conf_extra, strict=True)
|
|
1197
1290
|
|
|
1198
1291
|
subset_conf: DggridMetaConfigT = { 'update_frequency': 100000, 'clip_subset_type': 'WHOLE_EARTH' }
|
|
1199
1292
|
|
|
@@ -1213,11 +1306,14 @@ class DGGRID(abc.ABC):
|
|
|
1213
1306
|
'clip_subset_type': cast(DggsClipSubsetTypeT, self.tmp_geo_out['legacy_driver'].upper())
|
|
1214
1307
|
})
|
|
1215
1308
|
|
|
1216
|
-
subset_conf.update(specify_resolution(**
|
|
1217
|
-
subset_conf.update(specify_orient_type_args(**
|
|
1218
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1309
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1310
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1311
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1219
1312
|
|
|
1220
|
-
|
|
1313
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1314
|
+
subset_conf.update(input_extras)
|
|
1315
|
+
|
|
1316
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1221
1317
|
output_conf: DggridMetaConfigT = {
|
|
1222
1318
|
'cell_output_type': 'GDAL',
|
|
1223
1319
|
'point_output_type': 'NONE',
|
|
@@ -1278,7 +1374,7 @@ class DGGRID(abc.ABC):
|
|
|
1278
1374
|
mixed_aperture_level: int = None,
|
|
1279
1375
|
clip_geom: "AnyGeometry" = None,
|
|
1280
1376
|
output_address_type: DggsOutputAddressTypeT | None = None,
|
|
1281
|
-
**
|
|
1377
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1282
1378
|
) -> gpd.GeoDataFrame:
|
|
1283
1379
|
"""
|
|
1284
1380
|
generates a DGGS grid and returns all the cell's centroid as GeoDataFrame with geometry type Point
|
|
@@ -1288,6 +1384,7 @@ class DGGRID(abc.ABC):
|
|
|
1288
1384
|
tmp_id = uuid.uuid4()
|
|
1289
1385
|
tmp_dir = self.working_dir
|
|
1290
1386
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1387
|
+
dggs.update(**conf_extra, strict=True)
|
|
1291
1388
|
|
|
1292
1389
|
subset_conf: DggridMetaConfigT = { 'update_frequency': 100000, 'clip_subset_type': 'WHOLE_EARTH' }
|
|
1293
1390
|
|
|
@@ -1307,11 +1404,14 @@ class DGGRID(abc.ABC):
|
|
|
1307
1404
|
'clip_subset_type': cast(DggsClipSubsetTypeT, self.tmp_geo_out['legacy_driver'].upper())
|
|
1308
1405
|
})
|
|
1309
1406
|
|
|
1310
|
-
subset_conf.update(specify_resolution(**
|
|
1311
|
-
subset_conf.update(specify_orient_type_args(**
|
|
1312
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1407
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1408
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1409
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1410
|
+
|
|
1411
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1412
|
+
subset_conf.update(input_extras)
|
|
1313
1413
|
|
|
1314
|
-
output_extras = self.check_output_extra_fields(
|
|
1414
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1315
1415
|
output_conf: DggridMetaConfigT = {
|
|
1316
1416
|
'point_output_type': 'GDAL',
|
|
1317
1417
|
'cell_output_type': 'NONE',
|
|
@@ -1373,7 +1473,7 @@ class DGGRID(abc.ABC):
|
|
|
1373
1473
|
clip_cell_res: int = 1,
|
|
1374
1474
|
input_address_type: DggsInputAddressTypeT = 'SEQNUM',
|
|
1375
1475
|
output_address_type: DggsOutputAddressTypeT = 'SEQNUM',
|
|
1376
|
-
**
|
|
1476
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1377
1477
|
) -> gpd.GeoDataFrame:
|
|
1378
1478
|
"""
|
|
1379
1479
|
generates a DGGS grid and returns all the cells as GeoDataFrame with geometry type Polygon
|
|
@@ -1383,6 +1483,7 @@ class DGGRID(abc.ABC):
|
|
|
1383
1483
|
tmp_id = uuid.uuid4()
|
|
1384
1484
|
tmp_dir = self.working_dir
|
|
1385
1485
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1486
|
+
dggs.update(**conf_extra, strict=True)
|
|
1386
1487
|
|
|
1387
1488
|
subset_conf: DggridMetaConfigT = { 'update_frequency': 100000, 'clip_subset_type': clip_subset_type }
|
|
1388
1489
|
seq_df = None
|
|
@@ -1400,8 +1501,8 @@ class DGGRID(abc.ABC):
|
|
|
1400
1501
|
# TODO, for Z3, Z7, ZORDER can potentially also be COARSE_CELLS / aka parent cells?
|
|
1401
1502
|
# clip_subset_type should INPUT_ADDRESS_TYPE for the equivalent of SEQNUM (tp use input_address_type Z3 ...), or COARSE_CELLS as an actual parent cell type clip (also for Z3 ..)
|
|
1402
1503
|
if (
|
|
1403
|
-
input_address_type in
|
|
1404
|
-
and output_address_type in
|
|
1504
|
+
input_address_type in self.input_address_types
|
|
1505
|
+
and output_address_type in self.output_address_types
|
|
1405
1506
|
):
|
|
1406
1507
|
subset_conf.update(
|
|
1407
1508
|
{
|
|
@@ -1419,12 +1520,21 @@ class DGGRID(abc.ABC):
|
|
|
1419
1520
|
'clip_cell_addresses' : " ".join([str(address) for address in cell_id_list])
|
|
1420
1521
|
}
|
|
1421
1522
|
)
|
|
1523
|
+
if "clip_cell_densification" in conf_extra:
|
|
1524
|
+
subset_conf.update(
|
|
1525
|
+
{
|
|
1526
|
+
'clip_cell_densification' : conf_extra['clip_cell_densification']
|
|
1527
|
+
}
|
|
1528
|
+
)
|
|
1529
|
+
|
|
1530
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1531
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1532
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1422
1533
|
|
|
1423
|
-
|
|
1424
|
-
subset_conf.update(
|
|
1425
|
-
subset_conf.update(specify_topo_aperture(**output_conf_extra))
|
|
1534
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1535
|
+
subset_conf.update(input_extras)
|
|
1426
1536
|
|
|
1427
|
-
output_extras = self.check_output_extra_fields(
|
|
1537
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1428
1538
|
output_conf: DggridMetaConfigT = {
|
|
1429
1539
|
'cell_output_type': 'GDAL',
|
|
1430
1540
|
'point_output_type': 'NONE',
|
|
@@ -1510,7 +1620,7 @@ class DGGRID(abc.ABC):
|
|
|
1510
1620
|
clip_cell_res: int = 1,
|
|
1511
1621
|
input_address_type: DggsInputAddressTypeT = 'SEQNUM',
|
|
1512
1622
|
output_address_type: DggsOutputAddressTypeT = 'SEQNUM',
|
|
1513
|
-
**
|
|
1623
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1514
1624
|
):
|
|
1515
1625
|
"""
|
|
1516
1626
|
generates a DGGS grid and returns all the cell's centroid as GeoDataFrame with geometry type Point
|
|
@@ -1520,6 +1630,7 @@ class DGGRID(abc.ABC):
|
|
|
1520
1630
|
tmp_id = uuid.uuid4()
|
|
1521
1631
|
tmp_dir = self.working_dir
|
|
1522
1632
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1633
|
+
dggs.update(**conf_extra, strict=True)
|
|
1523
1634
|
|
|
1524
1635
|
subset_conf: DggridMetaConfigT = { 'update_frequency': 100000, 'clip_subset_type': clip_subset_type }
|
|
1525
1636
|
seq_df = None
|
|
@@ -1538,8 +1649,8 @@ class DGGRID(abc.ABC):
|
|
|
1538
1649
|
# TODO, for Z3, Z7, ZORDER can potentially also be COARSE_CELLS / aka parent cells?
|
|
1539
1650
|
# clip_subset_type should INPUT_ADDRESS_TYPE for the equivalent of SEQNUM (tp use input_address_type Z3 ...), or COARSE_CELLS as an actual parent cell type clip (also for Z3 ..)
|
|
1540
1651
|
if (
|
|
1541
|
-
input_address_type in
|
|
1542
|
-
and output_address_type in
|
|
1652
|
+
input_address_type in self.input_address_types
|
|
1653
|
+
and output_address_type in self.output_address_types
|
|
1543
1654
|
):
|
|
1544
1655
|
subset_conf.update(
|
|
1545
1656
|
{
|
|
@@ -1558,11 +1669,14 @@ class DGGRID(abc.ABC):
|
|
|
1558
1669
|
}
|
|
1559
1670
|
)
|
|
1560
1671
|
|
|
1561
|
-
subset_conf.update(specify_resolution(**
|
|
1562
|
-
subset_conf.update(specify_orient_type_args(**
|
|
1563
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1672
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1673
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1674
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1564
1675
|
|
|
1565
|
-
|
|
1676
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1677
|
+
subset_conf.update(input_extras)
|
|
1678
|
+
|
|
1679
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1566
1680
|
output_conf: DggridMetaConfigT = {
|
|
1567
1681
|
'point_output_type': 'GDAL',
|
|
1568
1682
|
'cell_output_type': 'NONE',
|
|
@@ -1633,7 +1747,7 @@ class DGGRID(abc.ABC):
|
|
|
1633
1747
|
mixed_aperture_level: int = None,
|
|
1634
1748
|
clip_geom: "AnyGeometry" = None,
|
|
1635
1749
|
output_address_type: DggsOutputAddressTypeT | None = None,
|
|
1636
|
-
**
|
|
1750
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1637
1751
|
) -> pd.DataFrame:
|
|
1638
1752
|
"""
|
|
1639
1753
|
generates a DGGS grid and returns all the cellids as a pandas dataframe
|
|
@@ -1644,6 +1758,7 @@ class DGGRID(abc.ABC):
|
|
|
1644
1758
|
tmp_id = uuid.uuid4()
|
|
1645
1759
|
tmp_dir = self.working_dir
|
|
1646
1760
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1761
|
+
dggs.update(**conf_extra, strict=True)
|
|
1647
1762
|
|
|
1648
1763
|
subset_conf = { 'update_frequency': 100000, 'clip_subset_type': 'WHOLE_EARTH' }
|
|
1649
1764
|
|
|
@@ -1663,11 +1778,14 @@ class DGGRID(abc.ABC):
|
|
|
1663
1778
|
'clip_subset_type': cast(DggsClipSubsetTypeT, self.tmp_geo_out['legacy_driver'].upper())
|
|
1664
1779
|
})
|
|
1665
1780
|
|
|
1666
|
-
subset_conf.update(specify_resolution(**
|
|
1667
|
-
subset_conf.update(specify_orient_type_args(**
|
|
1668
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1781
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1782
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1783
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1784
|
+
|
|
1785
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1786
|
+
subset_conf.update(input_extras)
|
|
1669
1787
|
|
|
1670
|
-
output_extras = self.check_output_extra_fields(
|
|
1788
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1671
1789
|
output_conf: DggridMetaConfigT = {
|
|
1672
1790
|
'point_output_type': 'TEXT',
|
|
1673
1791
|
'cell_output_type': 'NONE',
|
|
@@ -1715,7 +1833,7 @@ class DGGRID(abc.ABC):
|
|
|
1715
1833
|
mixed_aperture_level: int = None,
|
|
1716
1834
|
split_dateline: bool = False,
|
|
1717
1835
|
output_address_type: DggsOutputAddressTypeT | None = None,
|
|
1718
|
-
**
|
|
1836
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1719
1837
|
) -> gpd.GeoDataFrame:
|
|
1720
1838
|
"""
|
|
1721
1839
|
takes a GeoDataFrame with point geometry and optional additional value columns and returns:
|
|
@@ -1725,6 +1843,7 @@ class DGGRID(abc.ABC):
|
|
|
1725
1843
|
tmp_id = uuid.uuid4()
|
|
1726
1844
|
tmp_dir = self.working_dir
|
|
1727
1845
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1846
|
+
dggs.update(**conf_extra, strict=True)
|
|
1728
1847
|
|
|
1729
1848
|
cols = set(geodf_points_wgs84.columns.tolist())
|
|
1730
1849
|
cols = cols - set('geometry')
|
|
@@ -1741,11 +1860,14 @@ class DGGRID(abc.ABC):
|
|
|
1741
1860
|
'input_address_type': 'GEO',
|
|
1742
1861
|
'input_delimiter': "\" \""
|
|
1743
1862
|
}
|
|
1744
|
-
subset_conf.update(specify_resolution(**
|
|
1745
|
-
subset_conf.update(specify_orient_type_args(**
|
|
1746
|
-
subset_conf.update(specify_topo_aperture(**
|
|
1863
|
+
subset_conf.update(specify_resolution(**conf_extra))
|
|
1864
|
+
subset_conf.update(specify_orient_type_args(**conf_extra))
|
|
1865
|
+
subset_conf.update(specify_topo_aperture(**conf_extra))
|
|
1866
|
+
|
|
1867
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1868
|
+
subset_conf.update(input_extras)
|
|
1747
1869
|
|
|
1748
|
-
output_extras = self.check_output_extra_fields(
|
|
1870
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1749
1871
|
output_conf = {
|
|
1750
1872
|
'output_file_name': str( (Path(tmp_dir) / f"{output_address_type}_{tmp_id}.txt").resolve()),
|
|
1751
1873
|
'output_address_type': 'SEQNUM',
|
|
@@ -1809,7 +1931,7 @@ class DGGRID(abc.ABC):
|
|
|
1809
1931
|
mixed_aperture_level: int = None,
|
|
1810
1932
|
input_address_type: DggsInputAddressTypeT = 'SEQNUM',
|
|
1811
1933
|
output_address_type: DggsOutputAddressTypeT = 'SEQNUM',
|
|
1812
|
-
**
|
|
1934
|
+
**conf_extra: DggridMetaConfigParameterT,
|
|
1813
1935
|
) -> pd.DataFrame:
|
|
1814
1936
|
"""
|
|
1815
1937
|
generates the DGGS for the input cell_ids and returns all the transformed cell_ids
|
|
@@ -1818,11 +1940,12 @@ class DGGRID(abc.ABC):
|
|
|
1818
1940
|
tmp_id = uuid.uuid4()
|
|
1819
1941
|
tmp_dir = self.working_dir
|
|
1820
1942
|
dggs = dgselect(dggs_type = dggs_type, res= resolution, mixed_aperture_level=mixed_aperture_level)
|
|
1943
|
+
dggs.update(**conf_extra, strict=True)
|
|
1821
1944
|
|
|
1822
1945
|
if cell_id_list is None or len(cell_id_list) <= 0:
|
|
1823
1946
|
raise ValueError("Expecting cell_id_list to transform.")
|
|
1824
1947
|
|
|
1825
|
-
if not input_address_type in input_address_types:
|
|
1948
|
+
if not input_address_type in self.input_address_types:
|
|
1826
1949
|
raise ValueError(f"unknown input_address_type: {input_address_type}")
|
|
1827
1950
|
|
|
1828
1951
|
if not output_address_type in self.output_address_types:
|
|
@@ -1837,7 +1960,10 @@ class DGGRID(abc.ABC):
|
|
|
1837
1960
|
'input_delimiter': "\" \""
|
|
1838
1961
|
}
|
|
1839
1962
|
|
|
1840
|
-
|
|
1963
|
+
input_extras = self.check_input_extra_fields(conf_extra)
|
|
1964
|
+
subset_conf.update(input_extras)
|
|
1965
|
+
|
|
1966
|
+
output_extras = self.check_output_extra_fields(conf_extra)
|
|
1841
1967
|
output_conf: DggridMetaConfigT = {
|
|
1842
1968
|
'output_file_name': str( (Path(tmp_dir) / f"temp_out_{output_address_type}_{tmp_id}.txt").resolve()),
|
|
1843
1969
|
'output_address_type': output_address_type,
|
|
@@ -1867,12 +1993,24 @@ class DGGRIDv7(DGGRID):
|
|
|
1867
1993
|
version = 7
|
|
1868
1994
|
output_address_types: DggsOutputAddressTypeV7T = output_address_types_v7
|
|
1869
1995
|
output_extra_fields = output_extra_fields_v7
|
|
1996
|
+
input_address_types: DggsInputAddressTypeV7T = input_address_types_v7
|
|
1997
|
+
input_extra_fields = input_extra_fields_v7
|
|
1870
1998
|
|
|
1871
1999
|
|
|
1872
2000
|
class DGGRIDv8(DGGRID):
|
|
1873
2001
|
version = 8
|
|
1874
2002
|
output_address_types: DggsOutputAddressTypeV8T = output_address_types_v8
|
|
1875
2003
|
output_extra_fields = output_extra_fields_v8
|
|
2004
|
+
input_address_types: DggsInputAddressTypeV8T = input_address_types_v8
|
|
2005
|
+
input_extra_fields = input_extra_fields_v8
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
class AnyDGGRID(DGGRID):
|
|
2009
|
+
version = 0
|
|
2010
|
+
output_address_types: DggsOutputAddressTypeT = list(set(output_address_types_v7) | set(output_address_types_v8))
|
|
2011
|
+
output_extra_fields = list(set(output_extra_fields_v7) | set(output_extra_fields_v8))
|
|
2012
|
+
input_address_types: DggsInputAddressTypeT = list(set(input_address_types_v7) | set(input_address_types_v8))
|
|
2013
|
+
input_extra_fields = list(set(input_extra_fields_v7) | set(input_extra_fields_v8))
|
|
1876
2014
|
|
|
1877
2015
|
|
|
1878
2016
|
#############################################################
|
|
@@ -2029,7 +2167,7 @@ def specify_resolution(
|
|
|
2029
2167
|
if dggs_proj is None or dggs_res_specify_type is None:
|
|
2030
2168
|
return {}
|
|
2031
2169
|
|
|
2032
|
-
if not
|
|
2170
|
+
if not dggs_proj in list(dggs_projections) or not dggs_res_specify_type in dggs_res_specify_types:
|
|
2033
2171
|
raise ValueError("base projection (ISEA or FULLER) or resolution spec unknown")
|
|
2034
2172
|
|
|
2035
2173
|
if dggs_res_specify_type == "SPECIFIED":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|