From 82cc5b494065741250403fdc2b9cb162eefaee97 Mon Sep 17 00:00:00 2001 From: Alexander Kmoch Date: Fri, 23 Feb 2024 18:51:52 +0200 Subject: [PATCH] ISEA7H Seqnums to geom --- dggrid4py/dggrid_runner.py | 5 ++-- dggrid4py/interrupt.py | 55 -------------------------------------- setup.py | 4 +-- 3 files changed, 5 insertions(+), 59 deletions(-) diff --git a/dggrid4py/dggrid_runner.py b/dggrid4py/dggrid_runner.py index 5fc4df5..cd0cb4e 100644 --- a/dggrid4py/dggrid_runner.py +++ b/dggrid4py/dggrid_runner.py @@ -459,13 +459,14 @@ def dg_closest_res_to_cls (self, cls_val, resround,metric,show_info=True): """ class DGGRIDv7(object): - def __init__(self, executable = 'dggrid', working_dir = None, capture_logs=True, silent=False, tmp_geo_out_legacy= True): + def __init__(self, executable = 'dggrid', working_dir = None, capture_logs=True, silent=False, tmp_geo_out_legacy=True, has_gdal=True): self.executable = Path(executable).resolve() self.capture_logs=capture_logs self.silent=silent self.last_run_succesful = False self.last_run_logs = '' self.tmp_geo_out = get_geo_out(legacy=tmp_geo_out_legacy) + self.has_gdal = has_gdal if working_dir is None: self.working_dir = tempfile.mkdtemp(prefix='dggrid_') @@ -576,7 +577,7 @@ def dgapi_grid_gen(self, dggs, subset_conf, output_conf): metafile.append("clip_subset_type " + subset_conf['clip_subset_type']) metafile.append("clip_region_files " + subset_conf['clip_region_files']) elif subset_conf['clip_subset_type'] in [ 'SEQNUMS'] and not subset_conf['clip_region_files'] is None: - if not dggs.dggs_type in ['ISEA7H', 'FULLER7H', 'PLANETRISK']: + if not dggs.dggs_type in ['PLANETRISK']: metafile.append("clip_subset_type " + subset_conf['clip_subset_type']) metafile.append("clip_region_files " + subset_conf['clip_region_files']) else: diff --git a/dggrid4py/interrupt.py b/dggrid4py/interrupt.py index c74bdfd..8242082 100644 --- a/dggrid4py/interrupt.py +++ b/dggrid4py/interrupt.py @@ -17,7 +17,6 @@ # Date: 07-10-2022 # -import sys import geopandas as gpd from shapely.geometry import Polygon from shapely.ops import split @@ -28,29 +27,6 @@ intersectEast = Polygon([(0,-90),(0,90),(179.995,90),(179.995,-90),(0,-90)]) -def wrongUsage(): - - print("This programme requires two arguments:\n" + - " - path to an input DGG in Shapefile format \n" + - " - path to the output interrupted Shapefile \n" + - "Usage example: \n" - " python3 interrupt.py /path/to/input.shp /path/to/output.shp") - sys.exit() - - -def processArguments(args): - - inputFile = "" - outputFile = "" - - if len(args) < 3: - wrongUsage() - else: - inputFile = str(args[1]) - outputFile = str(args[2]) - - return (inputFile, outputFile) - def get_geom_coords(geometry): wkt = geometry.wkt @@ -91,34 +67,3 @@ def interrupt_cell(coords): return result - -# -------- Main ------- -def main(): - - inputFile, outputFile = processArguments(sys.argv) - - cells = gpd.read_file(inputFile) - # Create resulting layer - cellsNew = cells.iloc[:0].copy() - - #Clean output line - print("\n") - - for index, row in cells.iterrows(): - - print("\033[AProcessing cell %s of %s" % (index, len(cells))) - - poly = row.geometry - coords = get_geom_coords(poly) - if crosses_interruption(coords): - geoms = interrupt_cell(coords) - for geom in geoms: - cellsNew.loc[len(cellsNew)] = [row["name"], geom] - else: - cellsNew.loc[len(cellsNew)] = row - - cellsNew.to_file(outputFile) - print("All done!") - -if __name__ == "__main__": - main() diff --git a/setup.py b/setup.py index 9121cd4..c75bfc0 100644 --- a/setup.py +++ b/setup.py @@ -9,10 +9,10 @@ # from setuptools import setup, find_packages -__version__ = "0.2.6" +__version__ = "0.2.7" VERSION = __version__ -DESCRIPTION = "a Python library to run highlevel functions of DGGRIDv7" +DESCRIPTION = "a Python library to run highlevel functions of DGGRIDv7 and v8" LONG_DESCRIPTION = "a set of python modules for creating and manipulating Discrete Global Grids with DGGRID version 7.x software which was created and maintained by Kevin Sahr. - more info to come!"