Skip to content

Commit b0a78c0

Browse files
authored
Merge pull request #27 from crim-ca/refactor-typings-extra-configs
Refactor typings + extra configs forwarding
2 parents a85e155 + 6ab1433 commit b0a78c0

File tree

4 files changed

+885
-550
lines changed

4 files changed

+885
-550
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ GNU AFFERO GENERAL PUBLIC LICENSE
1111
- [DGGRID Version 8.3 on GitHub](https://github.com/sahrk/DGGRID)
1212
- [DGGRID User Manual](https://github.com/sahrk/DGGRID/blob/d08e10d761f7bedd72a253ab1057458f339de51e/dggridManualV81b.pdf)
1313

14-
You need the ddgrid tool compiled available on the system.
14+
You need the `dggrid` tool compiled available on the system.
1515

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
1717

1818
- grid_cell_polygons_for_extent(): fill extent/subset with cells at resolution (clip or world)
1919
- grid_cell_polygons_from_cellids(): geometry_from_cellid for dggs at resolution (from id list)
2020
- grid_cellids_for_extent(): get_all_indexes/cell_ids for dggs at resolution (clip or world)
2121
- 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
2323

2424

2525
```python
@@ -29,7 +29,7 @@ import shapely
2929
from dggrid4py import DGGRIDv7
3030

3131

32-
# create an inital instance that knows where the dggrid tool lives, configure temp workspace and log/stdout output
32+
# create an initial instance that knows where the dggrid tool lives, configure temp workspace and log/stdout output
3333
# if you have
3434
dggrid_instance = DGGRIDv7(executable='<path_to>/dggrid', working_dir='.', capture_logs=False, silent=False, tmp_geo_out_legacy=False, debug=False)
3535

@@ -42,10 +42,10 @@ gdf1.to_file('isea4t_5.shp')
4242
gdf_centroids = dggrid_instance.grid_cell_centroids_for_extent(dggs_type='ISEA7H', resolution=4, mixed_aperture_level=None, clip_geom=None)
4343

4444
# clip extent
45-
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)
4646

4747
# ISEA7H grid at resolution 9, for extent of provided WGS84 rectangle into GeoDataFrame to Shapefile
48-
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)
4949
print(gdf3.head())
5050
gdf3.to_file('grids/est_shape_isea7h_9.shp')
5151

@@ -55,6 +55,8 @@ print(df1.head(8))
5555
df1.to_csv('isea7h_8_stats.csv', index=False)
5656

5757
# 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')
5860
gdf4 = dggrid_instance.cells_for_geo_points(geodf_points_wgs84, False, 'ISEA7H', 5)
5961
print(gdf4.head())
6062
gdf4.to_file('polycells_from_points_isea7h_5.shp')
@@ -65,15 +67,15 @@ print(gdf5.head())
6567
gdf5.to_file('geopoint_cellids_from_points_isea4h_8.shp')
6668

6769
# generate DGGS grid cell polygons based on 'cell_id_list' (a list or np.array of provided cell_ids)
68-
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)
6971
print(gdf6.head())
7072
gdf6.to_file('from_seqnums_isea7h_5.shp')
7173

7274
# v0.2.6 API update split at dateline for cartesian GIS tools
7375
gdf7 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 3, split_dateline=True)
7476
gdf7.to_file('global_isea7h_3_interrupted.shp')
7577

76-
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')
7779
print(gdf_z1.head(3))
7880

7981
df_z1 = dggrid_instance.guess_zstr_resolution(gdf_z1['name'].values, 'IGEO7', input_address_type='Z7_STRING')
@@ -94,7 +96,7 @@ if you don't have a special local distribution of the dggrid-tool or if you didn
9496

9597
```python
9698

97-
from dggrid4py import tool
99+
from dggrid4py import DGGRIDv7, tool
98100

99101
dggrid_exec = tool.get_portable_executable(".")
100102
dggrid_instance_portable = DGGRIDv7(executable=dggrid_exec, working_dir='.', capture_logs=False, silent=True, has_gdal=False, tmp_geo_out_legacy=True, debug=False)
@@ -125,4 +127,3 @@ working on an updated conda package. Currently DGGRID v8.3 is available on conda
125127
## greater context DGGS in Earth Sciences and GIS
126128

127129
Some reading to be excited about: [discourse.pangeo.io](https://discourse.pangeo.io/t/discrete-global-grid-systems-dggs-use-with-pangeo/2274)
128-

0 commit comments

Comments
 (0)