diff --git a/README.md b/README.md index d675a6f..f2dbe15 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ GNU AFFERO GENERAL PUBLIC LICENSE -[DGGRID](https://www.discreteglobalgrids.org/software/) is a free software program for creating and manipulating Discrete Global Grids created and maintained by Kevin Sahr. DGGRID version 8.1b was released 12. January 2024 +[DGGRID](https://www.discreteglobalgrids.org/software/) is a free software program for creating and manipulating Discrete Global Grids created and maintained by Kevin Sahr. DGGRID version 8.34 was released 13. November 2024 -- [DGGRID Version 8.1b on GitHub](https://github.com/sahrk/DGGRID) +- [DGGRID Version 8.3 on GitHub](https://github.com/sahrk/DGGRID) - [DGGRID User Manual](https://github.com/sahrk/DGGRID/blob/d08e10d761f7bedd72a253ab1057458f339de51e/dggridManualV81b.pdf) You need the ddgrid tool compiled available on the system. @@ -19,6 +19,7 @@ Besides some lowlevel access influence the dggrid operations' metafile creation, - grid_cell_polygons_from_cellids(): geometry_from_cellid for dggs at resolution (from id list) - grid_cellids_for_extent(): get_all_indexes/cell_ids for dggs at resolution (clip or world) - cells_for_geo_points(): poly_outline for point/centre at resolution +- address_transform(): conversion betwenn cell_id address types, like SEQNUM, Z7, or Q2DI ```python @@ -99,7 +100,7 @@ After some unsuccessful trials with ctypes, cython, CFFI, pybind11 or cppyy (rat ## Bundling for different operating systems Having to compile DGGRID for Windows can be a bit challenging. We are -working on an updated conda package. Currently DGGRID v7.8 is available on conda-forge: +working on an updated conda package. Currently DGGRID v8.3 is available on conda-forge: [![Latest version on conda-forge](https://anaconda.org/conda-forge/dggrid/badges/version.svg)](https://anaconda.org/conda-forge/dggrid) diff --git a/dggrid4py/dggrid_runner.py b/dggrid4py/dggrid_runner.py index e6a6b54..abdf7d2 100644 --- a/dggrid4py/dggrid_runner.py +++ b/dggrid4py/dggrid_runner.py @@ -1170,16 +1170,16 @@ def grid_cell_polygons_from_cellids(self, cell_id_list, dggs_type, resolution, m if self.debug is True: print(f"cannot switch address types on the fly here: {input_address_type} != {output_address_type}") - seq_df['cell_exists'] = True + # seq_df['cell_exists'] = True if output_address_type in ['SEQNUM']: seq_df[input_address_type] = seq_df[input_address_type].astype(np.int64) - seq_df.set_index(input_address_type, inplace=True) + # seq_df.set_index(input_address_type, inplace=True) name_col = 'name' if 'name' in gdf.columns else 'Name' if output_address_type in ['SEQNUM']: gdf[name_col] = gdf[name_col].astype(np.int64) - gdf = gdf.join( seq_df, how='inner', on=name_col) - gdf = gdf.loc[gdf['cell_exists']].drop(columns=['cell_exists']) + # gdf = gdf.join( seq_df, how='inner', left_on=name_col, right_on=input_address_type) + # gdf = gdf.loc[gdf['cell_exists']].drop(columns=['cell_exists']) if self.debug is False: try: @@ -1276,16 +1276,16 @@ def grid_cell_centroids_from_cellids(self, cell_id_list, dggs_type, resolution, if self.debug is True: print(f"cannot switch address types on the fly here: {input_address_type} != {output_address_type}") - seq_df['cell_exists'] = True + # seq_df['cell_exists'] = True if output_address_type in ['SEQNUM']: seq_df[input_address_type] = seq_df[input_address_type].astype(np.int64) - seq_df.set_index(input_address_type, inplace=True) + # seq_df.set_index(input_address_type, inplace=True) name_col = 'name' if 'name' in gdf.columns else 'Name' if output_address_type in ['SEQNUM']: gdf[name_col] = gdf[name_col].astype(np.int64) - gdf = gdf.join( seq_df, how='inner', on=name_col) - gdf = gdf.loc[gdf['cell_exists']].drop(columns=['cell_exists']) + # gdf = gdf.join( seq_df, how='inner', on=name_col) + # gdf = gdf.loc[gdf['cell_exists']].drop(columns=['cell_exists']) if self.debug is False: try: diff --git a/docs/requirements.txt b/docs/requirements.txt index d1a6358..ac02e76 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,5 +6,5 @@ pandas fiona shapely geopandas -dggrid4py==0.3.0 +dggrid4py==0.3.1 diff --git a/docs/source/conf.py b/docs/source/conf.py index e987f59..68d9f27 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,8 +11,8 @@ copyright = '2024, Alexander Kmoch' author = "Alexander Kmoch" -release = '0.3.0' -version = '0.3.0' +release = '0.3.1' +version = '0.3.1' # -- General configuration diff --git a/docs/source/index.rst b/docs/source/index.rst index bddd4e2..a29103f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -9,9 +9,9 @@ GNU AFFERO GENERAL PUBLIC LICENSE `DGGRID `__ is a free software program for creating and manipulating Discrete Global Grids -created and maintained by Kevin Sahr. DGGRID version 8.1b was released 12. January 2024 +created and maintained by Kevin Sahr. DGGRID version 8.34 was released 13. November 2024 -- `DGGRID Version 8.1b on GitHub `__ +- `DGGRID Version 8.3 on GitHub `__ - `DGGRID User Manual `__ @@ -50,7 +50,7 @@ Bundling for different operating systems ---------------------------------------- Having to compile DGGRID for Windows can be a bit challenging. We are -working on an updated conda package. Currently DGGRID v7.8 is available on conda-forge: +working on an updated conda package. Currently DGGRID v8.3 is available on conda-forge: .. image:: https://anaconda.org/conda-forge/dggrid/badges/version.svg :target: https://anaconda.org/conda-forge/dggrid diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 0aa214d..54e010d 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -78,17 +78,28 @@ comfortable geopython libraries, like shapely and geopandas gdf7 = dggrid_instance.grid_cell_polygons_for_extent('ISEA7H', 3, split_dateline=True) gdf7.to_file('global_isea7h_3_interrupted.shp') - gdf_z1 = dggrid_instance.grid_cell_polygons_for_extent('IGEO7', 5, clip_geom=est_bound, output_address_type='Z7_STRING') - print(gdf_z1.head(3)) - - df_z1 = dggrid_instance.guess_zstr_resolution(gdf_z1['name'].values, 'IGEO7', input_address_type='Z7_STRING') - print(df_z1.head(3)) - - df_q2di = dggrid_instance.address_transform(gdf_z1['name'].values, 'IGEO7', 5, input_address_type='Z7_STRING', output_address_type='Q2DI') - print(df_q2di.head(3)) - - df_tri = dggrid_instance.address_transform(gdf_z1['name'].values, 'IGEO7', 5, input_address_type='Z7_STRING', output_address_type='PROJTRI') - print(df_tri.head(3)) + gdf_z1 = dggrid_instance.grid_cell_polygons_for_extent('IGEO7', 5, clip_geom=est_bound, output_address_type='Z7_STRING') + print(gdf_z1.head(3)) + + df_z1 = dggrid_instance.guess_zstr_resolution(gdf_z1['name'].values, 'IGEO7', input_address_type='Z7_STRING') + print(df_z1.head(3)) + + df_q2di = dggrid_instance.address_transform(gdf_z1['name'].values, 'IGEO7', 5, input_address_type='Z7_STRING', output_address_type='Q2DI') + print(df_q2di.head(3)) + + df_tri = dggrid_instance.address_transform(gdf_z1['name'].values, 'IGEO7', 5, input_address_type='Z7_STRING', output_address_type='PROJTRI') + print(df_tri.head(3)) + + children = dggrid_instance.grid_cell_polygons_from_cellids( + cell_id_list=['00012502340'], # the input/parent cell id + dggs_type='IGEO7', # dggs type + resolution=11, # target resolution of children + clip_subset_type='COARSE_CELLS', # new parameter + clip_cell_res=9, # resolution of parent cell + input_address_type='Z7_STRING', # address_type + output_address_type='Z7_STRING' # address_type + ) + print(children.head(3)) TODO ---- diff --git a/examples/demo_highlevel_api.py b/examples/demo_highlevel_api.py index 5e67f0c..448f819 100644 --- a/examples/demo_highlevel_api.py +++ b/examples/demo_highlevel_api.py @@ -99,6 +99,18 @@ def highlevel_grid_gen_and_transform(dggrid_instance): df_tri = dggrid_instance.address_transform(gdf_z1['name'].values, 'IGEO7', 5, input_address_type='Z7_STRING', output_address_type='PROJTRI') print(df_tri.head(3)) + children = dggrid_instance.grid_cell_polygons_from_cellids( + cell_id_list=['00012502340'], # the input/parent cell id + dggs_type='IGEO7', # dggs type + resolution=11, # target resolution of children + clip_subset_type='COARSE_CELLS', # new parameter + clip_cell_res=9, # resolution of parent cell + input_address_type='Z7_STRING', # address_type + output_address_type='Z7_STRING' # address_type + ) + print(children.head(3)) + + def highlevel_grid_stats(dggrid_instance): diff --git a/pyproject.toml b/pyproject.toml index 03fb2cd..2983082 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dggrid4py" -version = "0.3.0" +version = "0.3.1" description = "a Python library to run highlevel functions of DGGRIDv7 and v8" authors = ["Alexander Kmoch ", "Wai Tik Chan ",