13
13
from pyflowline .formats .read_nhdplus_flowline_shapefile import extract_nhdplus_flowline_shapefile_by_attribute
14
14
from pyflowline .formats .read_nhdplus_flowline_shapefile import track_nhdplus_flowline
15
15
from pyflowline .formats .convert_flowline_to_geojson import convert_flowline_to_geojson
16
- from pyflowline .formats .export_flowline import export_flowline_to_json
17
- from pyflowline .formats .export_vertex import export_vertex_to_json
16
+ from pyflowline .formats .export_flowline import export_flowline_to_geojson
17
+ from pyflowline .formats .export_vertex import export_vertex_to_geojson
18
18
from pyflowline .algorithms .auxiliary .text_reader_string import text_reader_string
19
19
from pyflowline .algorithms .split .find_flowline_vertex import find_flowline_vertex
20
20
from pyflowline .algorithms .split .find_flowline_confluence import find_flowline_confluence
@@ -238,15 +238,15 @@ def flowline_simplification(self):
238
238
#not used anymore
239
239
#aThreshold = np.full(2, 300.0, dtype=float)
240
240
#aFlowline_basin_filtered = connect_disconnect_flowline(aFlowline_basin_filtered, aVertex, aThreshold)
241
- #sFilename_out = 'flowline_connect.json '
241
+ #sFilename_out = 'flowline_connect.geojson '
242
242
#sFilename_out = os.path.join(sWorkspace_output_basin, sFilename_out)
243
- #export_flowline_to_json (iFlag_projected, aFlowline_basin_filtered,pSpatial_reference_gcs, sFilename_out)
243
+ #export_flowline_to_geojson (iFlag_projected, aFlowline_basin_filtered,pSpatial_reference_gcs, sFilename_out)
244
244
pass
245
245
else :
246
246
pass
247
247
248
248
if self .iFlag_debug == 1 :
249
- sFilename_out = 'flowline_before_intersect.json '
249
+ sFilename_out = 'flowline_before_intersect.geojson '
250
250
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
251
251
self .export_flowline (aFlowline_basin_filtered , sFilename_out )
252
252
#calculate length
@@ -256,14 +256,14 @@ def flowline_simplification(self):
256
256
#simplification started
257
257
aVertex = find_flowline_vertex (aFlowline_basin_filtered )
258
258
if self .iFlag_debug == 1 :
259
- sFilename_out = 'flowline_vertex_without_confluence_before_intersect.json '
259
+ sFilename_out = 'flowline_vertex_without_confluence_before_intersect.geojson '
260
260
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
261
- export_vertex_to_json ( aVertex , sFilename_out )
261
+ export_vertex_to_geojson ( aVertex , sFilename_out )
262
262
aFlowline_basin_simplified = split_flowline (aFlowline_basin_filtered , aVertex )
263
263
if self .iFlag_debug == 1 :
264
- sFilename_out = 'flowline_split_by_point_before_intersect.json '
264
+ sFilename_out = 'flowline_split_by_point_before_intersect.geojson '
265
265
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
266
- export_flowline_to_json (aFlowline_basin_simplified , sFilename_out )
266
+ export_flowline_to_geojson (aFlowline_basin_simplified , sFilename_out )
267
267
#ues location to find outlet
268
268
point = dict ()
269
269
point ['dLongitude_degree' ] = self .dLongitude_outlet_degree
@@ -273,41 +273,41 @@ def flowline_simplification(self):
273
273
pVertex_outlet = aFlowline_basin_simplified [0 ].pVertex_end
274
274
self .pVertex_outlet = pVertex_outlet
275
275
if self .iFlag_debug == 1 :
276
- sFilename_out = 'flowline_direction_before_intersect.json '
276
+ sFilename_out = 'flowline_direction_before_intersect.geojson '
277
277
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
278
- export_flowline_to_json ( aFlowline_basin_simplified , sFilename_out )
278
+ export_flowline_to_geojson ( aFlowline_basin_simplified , sFilename_out )
279
279
#step 4: remove loops
280
280
aFlowline_basin_simplified = remove_flowline_loop (aFlowline_basin_simplified )
281
281
if self .iFlag_debug == 1 :
282
- sFilename_out = 'flowline_loop_before_intersect.json '
282
+ sFilename_out = 'flowline_loop_before_intersect.geojson '
283
283
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
284
- export_flowline_to_json ( aFlowline_basin_simplified , sFilename_out )
284
+ export_flowline_to_geojson ( aFlowline_basin_simplified , sFilename_out )
285
285
#using loop to remove small river, here we use 5 steps
286
286
for i in range (3 ):
287
287
sStep = "{:02d}" .format (i + 1 )
288
288
aFlowline_basin_simplified = remove_small_river (aFlowline_basin_simplified , self .dThreshold_small_river )
289
289
if self .iFlag_debug == 1 :
290
- sFilename_out = 'flowline_large_' + sStep + '_before_intersect.json '
290
+ sFilename_out = 'flowline_large_' + sStep + '_before_intersect.geojson '
291
291
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
292
- export_flowline_to_json ( aFlowline_basin_simplified , sFilename_out )
292
+ export_flowline_to_geojson ( aFlowline_basin_simplified , sFilename_out )
293
293
aVertex , lIndex_outlet , aIndex_headwater ,aIndex_middle , aIndex_confluence , aConnectivity = find_flowline_confluence (aFlowline_basin_simplified , pVertex_outlet )
294
294
if self .iFlag_debug == 1 :
295
- sFilename_out = 'flowline_vertex_with_confluence_' + sStep + '_before_intersect.json '
295
+ sFilename_out = 'flowline_vertex_with_confluence_' + sStep + '_before_intersect.geojson '
296
296
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
297
- export_vertex_to_json ( aVertex , sFilename_out , aAttribute_data = aConnectivity )
297
+ export_vertex_to_geojson ( aVertex , sFilename_out , aAttribute_data = aConnectivity )
298
298
aFlowline_basin_simplified = merge_flowline ( aFlowline_basin_simplified ,aVertex , pVertex_outlet , aIndex_headwater ,aIndex_middle , aIndex_confluence )
299
299
if self .iFlag_debug == 1 :
300
- sFilename_out = 'flowline_merge_' + sStep + '_before_intersect.json '
300
+ sFilename_out = 'flowline_merge_' + sStep + '_before_intersect.geojson '
301
301
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
302
- export_flowline_to_json ( aFlowline_basin_simplified , sFilename_out )
302
+ export_flowline_to_geojson ( aFlowline_basin_simplified , sFilename_out )
303
303
if len (aFlowline_basin_simplified ) == 1 :
304
304
break
305
305
306
306
#the final vertex info
307
307
aVertex , lIndex_outlet , aIndex_headwater ,aIndex_middle , aIndex_confluence , aConnectivity = find_flowline_confluence (aFlowline_basin_simplified , pVertex_outlet )
308
- sFilename_out = 'vertex_simplified.json '
308
+ sFilename_out = 'vertex_simplified.geojson '
309
309
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
310
- export_vertex_to_json ( aVertex , sFilename_out , aAttribute_data = aConnectivity )
310
+ export_vertex_to_geojson ( aVertex , sFilename_out , aAttribute_data = aConnectivity )
311
311
312
312
#self.dLength_flowline_simplified = self.calculate_flowline_length(aFlowline_basin_simplified)
313
313
aVertex = np .array (aVertex )
@@ -322,13 +322,13 @@ def flowline_simplification(self):
322
322
if self .iFlag_debug == 1 :
323
323
sFilename_out = self .sFilename_flowline_segment_index_before_intersect
324
324
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
325
- export_flowline_to_json ( aFlowline_basin_simplified , sFilename_out , \
325
+ export_flowline_to_geojson ( aFlowline_basin_simplified , sFilename_out , \
326
326
aAttribute_data = [aStream_segment ], aAttribute_field = ['iseg' ], aAttribute_dtype = ['int' ])
327
327
#build stream order
328
328
aFlowline_basin_simplified , aStream_order = define_stream_order (aFlowline_basin_simplified )
329
329
sFilename_out = self .sFilename_flowline_simplified
330
330
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
331
- export_flowline_to_json ( aFlowline_basin_simplified , sFilename_out , \
331
+ export_flowline_to_geojson ( aFlowline_basin_simplified , sFilename_out , \
332
332
aAttribute_data = [aStream_segment , aStream_order ], aAttribute_field = ['iseg' ,'iord' ], aAttribute_dtype = ['int' ,'int' ])
333
333
334
334
@@ -347,6 +347,10 @@ def reconstruct_topological_relationship(self, iMesh_type, sFilename_mesh):
347
347
aCell , aCell_intersect_basin , aFlowline_intersect_all = intersect_flowline_with_mesh (iMesh_type , sFilename_mesh , \
348
348
sFilename_flowline_in , sFilename_flowline_intersect_out )
349
349
sFilename_flowline_filter_geojson = self .sFilename_flowline_filter
350
+ if self .iFlag_debug == 1 :
351
+ sFilename_out = 'flowline_intersect_flowline_with_mesh.geojson'
352
+ sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
353
+ export_flowline_to_geojson (aFlowline_intersect_all , sFilename_out )
350
354
351
355
point = dict ()
352
356
point ['dLongitude_degree' ] = self .dLongitude_outlet_degree
@@ -357,22 +361,38 @@ def reconstruct_topological_relationship(self, iMesh_type, sFilename_mesh):
357
361
#segment based
358
362
aFlowline_basin_conceptual , lCellID_outlet , pVertex_outlet = remove_returning_flowline (iMesh_type , aCell_intersect_basin , pVertex_outlet_initial )
359
363
if self .iFlag_debug == 1 :
360
- sFilename_out = 'flowline_simplified_after_intersect.json '
364
+ sFilename_out = 'flowline_simplified_after_intersect.geojson '
361
365
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
362
- export_flowline_to_json (aFlowline_basin_conceptual , sFilename_out )
366
+ export_flowline_to_geojson (aFlowline_basin_conceptual , sFilename_out )
363
367
364
368
#edge based
365
369
aFlowline_basin_conceptual , aEdge = split_flowline_to_edge (aFlowline_basin_conceptual )
370
+ if self .iFlag_debug == 1 :
371
+ sFilename_out = 'flowline_edge_split_flowline_to_edge.geojson'
372
+ sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
373
+ export_flowline_to_geojson ( aFlowline_basin_conceptual , sFilename_out )
366
374
aFlowline_basin_conceptual = remove_duplicate_flowline (aFlowline_basin_conceptual )
375
+ if self .iFlag_debug == 1 :
376
+ sFilename_out = 'flowline_edge_remove_duplicate_flowline.geojson'
377
+ sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
378
+ export_flowline_to_geojson ( aFlowline_basin_conceptual , sFilename_out )
367
379
aFlowline_basin_conceptual = correct_flowline_direction (aFlowline_basin_conceptual , pVertex_outlet )
380
+ if self .iFlag_debug == 1 :
381
+ sFilename_out = 'flowline_edge_correct_flowline_direction.geojson'
382
+ sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
383
+ export_flowline_to_geojson ( aFlowline_basin_conceptual , sFilename_out )
368
384
aFlowline_basin_conceptual = remove_flowline_loop ( aFlowline_basin_conceptual )
385
+ if self .iFlag_debug == 1 :
386
+ sFilename_out = 'flowline_edge_remove_flowline_loop.geojson'
387
+ sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
388
+ export_flowline_to_geojson ( aFlowline_basin_conceptual , sFilename_out )
369
389
370
390
aVertex , lIndex_outlet , aIndex_headwater ,aIndex_middle , aIndex_confluence , aConnectivity \
371
391
= find_flowline_confluence (aFlowline_basin_conceptual , pVertex_outlet )
372
392
if self .iFlag_debug == 1 :
373
- sFilename_out = 'flowline_vertex_with_confluence_after_intersect.json '
393
+ sFilename_out = 'flowline_vertex_with_confluence_after_intersect.geojson '
374
394
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
375
- export_vertex_to_json ( aVertex , sFilename_out , aAttribute_data = aConnectivity )
395
+ export_vertex_to_geojson ( aVertex , sFilename_out , aAttribute_data = aConnectivity )
376
396
377
397
#segment based
378
398
aFlowline_basin_conceptual = merge_flowline ( aFlowline_basin_conceptual ,aVertex , pVertex_outlet , aIndex_headwater ,aIndex_middle , aIndex_confluence )
@@ -393,11 +413,11 @@ def reconstruct_topological_relationship(self, iMesh_type, sFilename_mesh):
393
413
aFlowline_basin_edge , aEdge = split_flowline_to_edge (aFlowline_basin_conceptual )
394
414
sFilename_out = self .sFilename_flowline_edge
395
415
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
396
- export_flowline_to_json ( aFlowline_basin_edge , sFilename_out )
416
+ export_flowline_to_geojson ( aFlowline_basin_edge , sFilename_out )
397
417
398
418
sFilename_out = self .sFilename_flowline_conceptual
399
419
sFilename_out = os .path .join (sWorkspace_output_basin , sFilename_out )
400
- export_flowline_to_json ( aFlowline_basin_conceptual , sFilename_out , \
420
+ export_flowline_to_geojson ( aFlowline_basin_conceptual , sFilename_out , \
401
421
aAttribute_data = [aStream_segment , aStream_order ], aAttribute_field = ['iseg' ,'iord' ], aAttribute_dtype = ['int' ,'int' ])
402
422
403
423
self .aFlowline_basin_conceptual = aFlowline_basin_conceptual
@@ -480,7 +500,7 @@ def export(self):
480
500
return
481
501
482
502
def export_flowline (self , aFlowline_in , sFilename_json_in ,iFlag_projected_in = None , pSpatial_reference_in = None ):
483
- export_flowline_to_json (aFlowline_in , sFilename_json_in ,\
503
+ export_flowline_to_geojson (aFlowline_in , sFilename_json_in ,\
484
504
iFlag_projected_in = iFlag_projected_in , \
485
505
pSpatial_reference_in = pSpatial_reference_in )
486
506
@@ -580,7 +600,7 @@ def export_config_to_json(self, sFilename_output_in = None):
580
600
cls = BasinClassEncoder )
581
601
return
582
602
583
- def convert_flowline_to_json (self ):
603
+ def convert_flowline_to_geojson (self ):
584
604
sFilename_raw = self .sFilename_flowline_filter
585
605
sFilename_out = self .sFilename_flowline_filter_geojson
586
606
print ('This is the filtered flowline:' , sFilename_raw )
0 commit comments