diff --git a/pyflowline/algorithms/merge/merge_flowline.py b/pyflowline/algorithms/merge/merge_flowline.py index 25cdfe4..4099596 100644 --- a/pyflowline/algorithms/merge/merge_flowline.py +++ b/pyflowline/algorithms/merge/merge_flowline.py @@ -8,7 +8,9 @@ from pyflowline.algorithms.cython.kernel import find_vertex_in_list else: from pyflowline.algorithms.auxiliary.find_vertex_in_list import find_vertex_in_list + lID = 0 + def merge_flowline(aFlowline_in, aVertex_in, \ pVertex_outlet_in, \ aIndex_headwater_in,\ diff --git a/pyflowline/classes/_visual.py b/pyflowline/classes/_visual.py index fbf5ec9..2d85cd7 100644 --- a/pyflowline/classes/_visual.py +++ b/pyflowline/classes/_visual.py @@ -1,7 +1,5 @@ import os -import json #dependency packages -import numpy as np from pyflowline.external.pyearth.visual.map.map_vector_polygon_data import map_vector_polygon_data from pyflowline.external.pyearth.visual.map.map_vector_polyline_data import map_vector_polyline_data from pyflowline.external.pyearth.visual.map.map_multiple_vector_data import map_multiple_vector_data diff --git a/pyflowline/classes/basin.py b/pyflowline/classes/basin.py index f638cf3..2f1e9c0 100644 --- a/pyflowline/classes/basin.py +++ b/pyflowline/classes/basin.py @@ -19,8 +19,6 @@ from pyflowline.formats.export_vertex import export_vertex_to_geojson from pyflowline.external.pyearth.toolbox.reader.text_reader_string import text_reader_string - - from pyflowline.algorithms.split.find_flowline_vertex import find_flowline_vertex from pyflowline.algorithms.split.find_flowline_confluence import find_flowline_confluence from pyflowline.algorithms.split.split_flowline import split_flowline @@ -125,14 +123,18 @@ class pybasin(object): aConfluence_basin_simplified= None aConfluence_basin_conceptual= None + #json + sFilename_hexwatershed_json='' + sFilename_stream_edge_json ='' - #for hexwatershed compatibility + #geojson for hexwatershed compatibility sFilename_elevation='' sFilename_slope='' sFilename_drainage_area='' sFilename_flow_direction ='' sFilename_distance_to_outlet = '' - + sFilename_stream_segment='' + sFilename_stream_edge='' iFlag_visual = importlib.util.find_spec("cartopy") @@ -239,7 +241,18 @@ def __init__(self, aParameter): exit pass + #json + self.sFilename_hexwatershed_json = os.path.join(str(self.sWorkspace_output_basin ), "watershed.json" ) + self.sFilename_stream_edge_json = os.path.join(str(self.sWorkspace_output_basin ), 'stream_edge.json') + self.sFilename_basin_info = os.path.join(str(self.sWorkspace_output_basin ), 'basin_info.json') + self.sFilename_flowline_conceptual_info = os.path.join(str(self.sWorkspace_output_basin ), 'flowline_conceptual_info.json') + self.sFilename_flowline_simplified_info = os.path.join(str(self.sWorkspace_output_basin ), 'flowline_simplified_info.json') + self.sFilename_confluence_conceptual_info = os.path.join(str(self.sWorkspace_output_basin ),'confluence_conceptual_info.json') + self.sFilename_confluence_simplified_info = os.path.join(str(self.sWorkspace_output_basin ),'confluence_simplified_info.json') + #geojson, full path of the file + #full paths are required for the following files + #for hexwatershed compatibility, the geojson files will be generated by the pyhexwatershed front end self.sFilename_flowline_segment_index_before_intersect = os.path.join(str(self.sWorkspace_output_basin ),'flowline_segment_index_before_intersect.geojson') self.sFilename_flowline_simplified = os.path.join(str(self.sWorkspace_output_basin ),'flowline_simplified.geojson') self.sFilename_flowline_split = os.path.join(str(self.sWorkspace_output_basin ),'flowline_split.geojson') @@ -247,21 +260,14 @@ def __init__(self, aParameter): self.sFilename_flowline_conceptual = os.path.join(str(self.sWorkspace_output_basin ),'flowline_conceptual.geojson') self.sFilename_flowline_edge = os.path.join(str(self.sWorkspace_output_basin ),'flowline_edge.geojson') self.sFilename_area_of_difference = os.path.join(str(self.sWorkspace_output_basin ),'area_of_difference.geojson') - - self.sFilename_basin_info = os.path.join(str(self.sWorkspace_output_basin ), 'basin_info.json') - self.sFilename_flowline_conceptual_info = os.path.join(str(self.sWorkspace_output_basin ), 'flowline_conceptual_info.json') - self.sFilename_flowline_simplified_info = os.path.join(str(self.sWorkspace_output_basin ), 'flowline_simplified_info.json') - self.sFilename_confluence_conceptual_info = os.path.join(str(self.sWorkspace_output_basin ),'confluence_conceptual_info.json') - self.sFilename_confluence_simplified_info = os.path.join(str(self.sWorkspace_output_basin ),'confluence_simplified_info.json') - - - #full paths are required for the following files - #for hexwatershed compatibility + self.sFilename_elevation = os.path.join(str(self.sWorkspace_output_basin ), "elevation.geojson" ) self.sFilename_slope = os.path.join(str(self.sWorkspace_output_basin ), "slope.geojson" ) self.sFilename_drainage_area = os.path.join(str(self.sWorkspace_output_basin ), "drainage_area.geojson" ) self.sFilename_flow_direction = os.path.join(str(self.sWorkspace_output_basin ), "flow_direction.geojson" ) self.sFilename_distance_to_outlet = os.path.join(str(self.sWorkspace_output_basin ), "distance_to_outlet.geojson" ) + self.sFilename_stream_edge = os.path.join(str(self.sWorkspace_output_basin ), "stream_edge.geojson" ) + self.sFilename_stream_segment = os.path.join(str(self.sWorkspace_output_basin ), "stream_segment.geojson" ) return @@ -631,8 +637,11 @@ def reconstruct_topological_relationship(self, iMesh_type, sFilename_mesh): export_flowline_to_geojson( aFlowline_basin_edge, sFilename_out) sFilename_out = self.sFilename_flowline_conceptual - export_flowline_to_geojson( aFlowline_basin_conceptual, sFilename_out, \ - aAttribute_data=[aStream_segment, aStream_order], aAttribute_field=['iseg','iord'], aAttribute_dtype=['int','int']) + export_flowline_to_geojson( aFlowline_basin_conceptual, + sFilename_out, + aAttribute_data=[aStream_segment, aStream_order], + aAttribute_field=['iseg','iord'], + aAttribute_dtype=['int','int']) self.aFlowline_basin_conceptual = aFlowline_basin_conceptual diff --git a/pyflowline/formats/export_flowline.py b/pyflowline/formats/export_flowline.py index 286d0cf..0f53416 100644 --- a/pyflowline/formats/export_flowline.py +++ b/pyflowline/formats/export_flowline.py @@ -5,13 +5,15 @@ from pyflowline.classes.edge import pyedge from pyflowline.classes.link import pycelllink -def export_flowline_to_geojson( aFlowline_in, \ - sFilename_json_in, \ - iFlag_projected_in= None, \ - pSpatial_reference_in=None, \ - aAttribute_field=None,\ - aAttribute_data=None,\ +def export_flowline_to_geojson( aFlowline_in, + sFilename_json_in, + iFlag_projected_in= None, + pSpatial_reference_in=None, + aAttribute_field=None, + aAttribute_data=None, aAttribute_dtype=None): + + """ convert a shpefile to json format. This function should be used for stream flowline only.