dggrid4py 0.4.1__tar.gz → 0.5.0.dev0__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.
@@ -1,12 +1,13 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: dggrid4py
3
- Version: 0.4.1
3
+ Version: 0.5.0.dev0
4
4
  Summary: a Python library to run highlevel functions of DGGRIDv7 and v8
5
5
  License: AGPL-3.0-or-later
6
+ License-File: LICENSE
6
7
  Keywords: python,GIS,DGGS,DGGRID,hexagons,grids,spatial statistics
7
8
  Author: Alexander Kmoch
8
9
  Author-email: alexander.kmoch@ut.ee
9
- Requires-Python: >=3.8,<4.0.0
10
+ Requires-Python: >=3.9,<4.0.0
10
11
  Classifier: Development Status :: 5 - Production/Stable
11
12
  Classifier: Environment :: Console
12
13
  Classifier: Intended Audience :: Education
@@ -17,18 +18,18 @@ Classifier: Operating System :: POSIX
17
18
  Classifier: Operating System :: POSIX :: Linux
18
19
  Classifier: Operating System :: Unix
19
20
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.8
21
21
  Classifier: Programming Language :: Python :: 3.9
22
22
  Classifier: Programming Language :: Python :: 3.10
23
23
  Classifier: Programming Language :: Python :: 3.11
24
24
  Classifier: Programming Language :: Python :: 3.12
25
25
  Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
26
27
  Classifier: Topic :: Scientific/Engineering :: GIS
27
28
  Requires-Dist: fiona (>=1.8.0,<2.0.0)
28
- Requires-Dist: geopandas (>=0.9.0,<1.1.0)
29
- Requires-Dist: numpy (>=1.22.0,<2.3.0)
29
+ Requires-Dist: geopandas (>=0.9.0,<=1.1.0)
30
+ Requires-Dist: numpy (>=1.22.0,<=2.3.0)
30
31
  Requires-Dist: pandas (>=1.4.0,<2.4.0)
31
- Requires-Dist: shapely (>=1.8.0,<2.1.0)
32
+ Requires-Dist: shapely (>=1.8.0,<=2.1.0)
32
33
  Project-URL: Homepage, https://github.com/allixender/dggrid4py
33
34
  Project-URL: Repository, https://github.com/allixender/dggrid4py
34
35
  Description-Content-Type: text/markdown
@@ -46,15 +47,15 @@ GNU AFFERO GENERAL PUBLIC LICENSE
46
47
  - [DGGRID Version 8.3 on GitHub](https://github.com/sahrk/DGGRID)
47
48
  - [DGGRID User Manual](https://github.com/sahrk/DGGRID/blob/d08e10d761f7bedd72a253ab1057458f339de51e/dggridManualV81b.pdf)
48
49
 
49
- You need the ddgrid tool compiled available on the system.
50
+ You need the `dggrid` tool compiled available on the system.
50
51
 
51
- Besides some lowlevel access influence the dggrid operations' metafile creation, a few highlevel functions are integrated to work with the more comfortable geopython libraries, like shapely and geopandas
52
+ Besides some low-level access influence the dggrid operations' metafile creation, a few high-level functions are integrated to work with the more comfortable geopython libraries, like shapely and geopandas
52
53
 
53
54
  - grid_cell_polygons_for_extent(): fill extent/subset with cells at resolution (clip or world)
54
55
  - grid_cell_polygons_from_cellids(): geometry_from_cellid for dggs at resolution (from id list)
55
56
  - grid_cellids_for_extent(): get_all_indexes/cell_ids for dggs at resolution (clip or world)
56
57
  - cells_for_geo_points(): poly_outline for point/centre at resolution
57
- - address_transform(): conversion betwenn cell_id address types, like SEQNUM, Z7, or Q2DI
58
+ - address_transform(): conversion between cell_id address types, like SEQNUM, Z7, or Q2DI
58
59
 
59
60
 
60
61
  ```python
@@ -63,7 +64,9 @@ import shapely
63
64
 
64
65
  from dggrid4py import DGGRIDv7
65
66
 
66
- # create an inital instance that knows where the dggrid tool lives, configure temp workspace and log/stdout output
67
+
68
+ # create an initial instance that knows where the dggrid tool lives, configure temp workspace and log/stdout output
69
+ # if you have
67
70
  dggrid_instance = DGGRIDv7(executable='<path_to>/dggrid', working_dir='.', capture_logs=False, silent=False, tmp_geo_out_legacy=False, debug=False)
68
71
 
69
72
 
@@ -75,10 +78,10 @@ gdf1.to_file('isea4t_5.shp')
75
78
  gdf_centroids = dggrid_instance.grid_cell_centroids_for_extent(dggs_type='ISEA7H', resolution=4, mixed_aperture_level=None, clip_geom=None)
76
79
 
77
80
  # clip extent
78
- clip_bound = shapely.geometry.box(20.2,57.00, 28.4,60.0 )
81
+ clip_bound = shapely.geometry.box(20.2,57.00, 28.4,60.0)
79
82
 
80
83
  # ISEA7H grid at resolution 9, for extent of provided WGS84 rectangle into GeoDataFrame to Shapefile
81
- gdf3 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 9, clip_geom=est_bound)
84
+ gdf3 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 9, clip_geom=clip_bound)
82
85
  print(gdf3.head())
83
86
  gdf3.to_file('grids/est_shape_isea7h_9.shp')
84
87
 
@@ -88,6 +91,8 @@ print(df1.head(8))
88
91
  df1.to_csv('isea7h_8_stats.csv', index=False)
89
92
 
90
93
  # generate the DGGS grid cells that would cover a GeoDataFrame of points, return Polygons with cell IDs as GeoDataFrame
94
+ points = [shapely.Point(20.5, 57.5), shapely.Point(21.0, 58.0)]
95
+ geodf_points_wgs84 = geopandas.GeoDataFrame({'name': ['A', 'B']}, geometry=points, crs='EPSG:4326')
91
96
  gdf4 = dggrid_instance.cells_for_geo_points(geodf_points_wgs84, False, 'ISEA7H', 5)
92
97
  print(gdf4.head())
93
98
  gdf4.to_file('polycells_from_points_isea7h_5.shp')
@@ -98,7 +103,7 @@ print(gdf5.head())
98
103
  gdf5.to_file('geopoint_cellids_from_points_isea4h_8.shp')
99
104
 
100
105
  # generate DGGS grid cell polygons based on 'cell_id_list' (a list or np.array of provided cell_ids)
101
- gdf6 = dggrid_instance.grid_cell_polygons_from_cellids(cell_id_list=[1, 4, 8], 'ISEA7H', 5)
106
+ gdf6 = dggrid_instance.grid_cell_polygons_from_cellids(cell_id_list=[1, 4, 8], dggs_type='ISEA7H', resolution=5)
102
107
  print(gdf6.head())
103
108
  gdf6.to_file('from_seqnums_isea7h_5.shp')
104
109
 
@@ -106,7 +111,7 @@ gdf6.to_file('from_seqnums_isea7h_5.shp')
106
111
  gdf7 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 3, split_dateline=True)
107
112
  gdf7.to_file('global_isea7h_3_interrupted.shp')
108
113
 
109
- gdf_z1 = dggrid_instance.grid_cell_polygons_for_extent('IGEO7', 5, clip_geom=est_bound, output_address_type='Z7_STRING')
114
+ gdf_z1 = dggrid_instance.grid_cell_polygons_for_extent('IGEO7', 5, clip_geom=clip_bound, output_address_type='Z7_STRING')
110
115
  print(gdf_z1.head(3))
111
116
 
112
117
  df_z1 = dggrid_instance.guess_zstr_resolution(gdf_z1['name'].values, 'IGEO7', input_address_type='Z7_STRING')
@@ -120,6 +125,20 @@ print(df_tri.head(3))
120
125
 
121
126
  ```
122
127
 
128
+
129
+ ### Portable DGGRID binary
130
+
131
+ if you don't have a special local distribution of the dggrid-tool or if you didn't install with conda-forge, you can use a provided portable:
132
+
133
+ ```python
134
+
135
+ from dggrid4py import DGGRIDv7, tool
136
+
137
+ dggrid_exec = tool.get_portable_executable(".")
138
+ dggrid_instance_portable = DGGRIDv7(executable=dggrid_exec, working_dir='.', capture_logs=False, silent=True, has_gdal=False, tmp_geo_out_legacy=True, debug=False)
139
+
140
+ ```
141
+
123
142
  ## TODO:
124
143
 
125
144
  - get parent_for_cell_id at coarser resolution
@@ -145,4 +164,3 @@ working on an updated conda package. Currently DGGRID v8.3 is available on conda
145
164
 
146
165
  Some reading to be excited about: [discourse.pangeo.io](https://discourse.pangeo.io/t/discrete-global-grid-systems-dggs-use-with-pangeo/2274)
147
166
 
148
-
@@ -11,15 +11,15 @@ GNU AFFERO GENERAL PUBLIC LICENSE
11
11
  - [DGGRID Version 8.3 on GitHub](https://github.com/sahrk/DGGRID)
12
12
  - [DGGRID User Manual](https://github.com/sahrk/DGGRID/blob/d08e10d761f7bedd72a253ab1057458f339de51e/dggridManualV81b.pdf)
13
13
 
14
- You need the ddgrid tool compiled available on the system.
14
+ You need the `dggrid` tool compiled available on the system.
15
15
 
16
- Besides some lowlevel access influence the dggrid operations' metafile creation, a few highlevel functions are integrated to work with the more comfortable geopython libraries, like shapely and geopandas
16
+ Besides some low-level access influence the dggrid operations' metafile creation, a few high-level functions are integrated to work with the more comfortable geopython libraries, like shapely and geopandas
17
17
 
18
18
  - grid_cell_polygons_for_extent(): fill extent/subset with cells at resolution (clip or world)
19
19
  - grid_cell_polygons_from_cellids(): geometry_from_cellid for dggs at resolution (from id list)
20
20
  - grid_cellids_for_extent(): get_all_indexes/cell_ids for dggs at resolution (clip or world)
21
21
  - cells_for_geo_points(): poly_outline for point/centre at resolution
22
- - address_transform(): conversion betwenn cell_id address types, like SEQNUM, Z7, or Q2DI
22
+ - address_transform(): conversion between cell_id address types, like SEQNUM, Z7, or Q2DI
23
23
 
24
24
 
25
25
  ```python
@@ -28,7 +28,9 @@ import shapely
28
28
 
29
29
  from dggrid4py import DGGRIDv7
30
30
 
31
- # create an inital instance that knows where the dggrid tool lives, configure temp workspace and log/stdout output
31
+
32
+ # create an initial instance that knows where the dggrid tool lives, configure temp workspace and log/stdout output
33
+ # if you have
32
34
  dggrid_instance = DGGRIDv7(executable='<path_to>/dggrid', working_dir='.', capture_logs=False, silent=False, tmp_geo_out_legacy=False, debug=False)
33
35
 
34
36
 
@@ -40,10 +42,10 @@ gdf1.to_file('isea4t_5.shp')
40
42
  gdf_centroids = dggrid_instance.grid_cell_centroids_for_extent(dggs_type='ISEA7H', resolution=4, mixed_aperture_level=None, clip_geom=None)
41
43
 
42
44
  # clip extent
43
- clip_bound = shapely.geometry.box(20.2,57.00, 28.4,60.0 )
45
+ clip_bound = shapely.geometry.box(20.2,57.00, 28.4,60.0)
44
46
 
45
47
  # ISEA7H grid at resolution 9, for extent of provided WGS84 rectangle into GeoDataFrame to Shapefile
46
- gdf3 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 9, clip_geom=est_bound)
48
+ gdf3 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 9, clip_geom=clip_bound)
47
49
  print(gdf3.head())
48
50
  gdf3.to_file('grids/est_shape_isea7h_9.shp')
49
51
 
@@ -53,6 +55,8 @@ print(df1.head(8))
53
55
  df1.to_csv('isea7h_8_stats.csv', index=False)
54
56
 
55
57
  # generate the DGGS grid cells that would cover a GeoDataFrame of points, return Polygons with cell IDs as GeoDataFrame
58
+ points = [shapely.Point(20.5, 57.5), shapely.Point(21.0, 58.0)]
59
+ geodf_points_wgs84 = geopandas.GeoDataFrame({'name': ['A', 'B']}, geometry=points, crs='EPSG:4326')
56
60
  gdf4 = dggrid_instance.cells_for_geo_points(geodf_points_wgs84, False, 'ISEA7H', 5)
57
61
  print(gdf4.head())
58
62
  gdf4.to_file('polycells_from_points_isea7h_5.shp')
@@ -63,7 +67,7 @@ print(gdf5.head())
63
67
  gdf5.to_file('geopoint_cellids_from_points_isea4h_8.shp')
64
68
 
65
69
  # generate DGGS grid cell polygons based on 'cell_id_list' (a list or np.array of provided cell_ids)
66
- gdf6 = dggrid_instance.grid_cell_polygons_from_cellids(cell_id_list=[1, 4, 8], 'ISEA7H', 5)
70
+ gdf6 = dggrid_instance.grid_cell_polygons_from_cellids(cell_id_list=[1, 4, 8], dggs_type='ISEA7H', resolution=5)
67
71
  print(gdf6.head())
68
72
  gdf6.to_file('from_seqnums_isea7h_5.shp')
69
73
 
@@ -71,7 +75,7 @@ gdf6.to_file('from_seqnums_isea7h_5.shp')
71
75
  gdf7 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 3, split_dateline=True)
72
76
  gdf7.to_file('global_isea7h_3_interrupted.shp')
73
77
 
74
- gdf_z1 = dggrid_instance.grid_cell_polygons_for_extent('IGEO7', 5, clip_geom=est_bound, output_address_type='Z7_STRING')
78
+ gdf_z1 = dggrid_instance.grid_cell_polygons_for_extent('IGEO7', 5, clip_geom=clip_bound, output_address_type='Z7_STRING')
75
79
  print(gdf_z1.head(3))
76
80
 
77
81
  df_z1 = dggrid_instance.guess_zstr_resolution(gdf_z1['name'].values, 'IGEO7', input_address_type='Z7_STRING')
@@ -85,6 +89,20 @@ print(df_tri.head(3))
85
89
 
86
90
  ```
87
91
 
92
+
93
+ ### Portable DGGRID binary
94
+
95
+ if you don't have a special local distribution of the dggrid-tool or if you didn't install with conda-forge, you can use a provided portable:
96
+
97
+ ```python
98
+
99
+ from dggrid4py import DGGRIDv7, tool
100
+
101
+ dggrid_exec = tool.get_portable_executable(".")
102
+ dggrid_instance_portable = DGGRIDv7(executable=dggrid_exec, working_dir='.', capture_logs=False, silent=True, has_gdal=False, tmp_geo_out_legacy=True, debug=False)
103
+
104
+ ```
105
+
88
106
  ## TODO:
89
107
 
90
108
  - get parent_for_cell_id at coarser resolution
@@ -109,4 +127,3 @@ working on an updated conda package. Currently DGGRID v8.3 is available on conda
109
127
  ## greater context DGGS in Earth Sciences and GIS
110
128
 
111
129
  Some reading to be excited about: [discourse.pangeo.io](https://discourse.pangeo.io/t/discrete-global-grid-systems-dggs-use-with-pangeo/2274)
112
-
@@ -8,8 +8,8 @@
8
8
  # Date: 07-12-2022
9
9
  #
10
10
 
11
- from .dggrid_runner import DGGRIDv7, Dggs, dgselect, dggs_types
11
+ from .dggrid_runner import DGGRIDv7, DGGRIDv8, Dggs, dgselect, dggs_types
12
12
  import dggrid4py.igeo7 as igeo7
13
13
  import dggrid4py.tool as tool
14
14
 
15
- __version__ = "0.4.1"
15
+ __version__ = "0.5.0-dev"