Skip to content

Commit

Permalink
ISEA7H Seqnums to geom
Browse files Browse the repository at this point in the history
  • Loading branch information
allixender committed Feb 23, 2024
1 parent 7c5eebb commit 82cc5b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 59 deletions.
5 changes: 3 additions & 2 deletions dggrid4py/dggrid_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_')
Expand Down Expand Up @@ -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:
Expand Down
55 changes: 0 additions & 55 deletions dggrid4py/interrupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# Date: 07-10-2022
#

import sys
import geopandas as gpd
from shapely.geometry import Polygon
from shapely.ops import split
Expand All @@ -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
Expand Down Expand Up @@ -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()
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"


Expand Down

0 comments on commit 82cc5b4

Please sign in to comment.