forked from cont-limno/LAGOS_GIS_Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_lagosGIS.py
58 lines (48 loc) · 2.84 KB
/
test_lagosGIS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import sys
import arcpy
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import lagosGIS
os.chdir(os.path.dirname(os.path.abspath(__file__)))
TEST_DATA_GDB = os.path.abspath(os.path.join(os.curdir, 'TestData_0411.gdb'))
arcpy.env.overwriteOutput = True
__all__ = ["lake_connectivity_classification",
"zonal_attribution_of_raster_data",
"polygons_in_zones",
"lakes_in_zones",
"interlake_watersheds_old",
"interlake_watersheds_new"]
def lake_connectivity_classification(out_feature_class, debug_mode = True):
lagosGIS.lake_connectivity_classification(TEST_DATA_GDB, out_feature_class, debug_mode)
def zonal_attribution_of_raster_data(out_table, is_thematic = False, debug_mode = True):
zone_fc = os.path.join(TEST_DATA_GDB, 'HU12_raster')
if is_thematic:
in_value_raster = os.path.join(TEST_DATA_GDB, 'NLCD_LandCover_2006')
else:
in_value_raster = os.path.join(TEST_DATA_GDB, 'Total_Nitrogen_Deposition_2006')
zone_field = arcpy.ListFields(zone_fc, '*zoneid')[0].name
lagosGIS.zonal_attribution_of_raster_data(zone_fc, zone_field, in_value_raster,
out_table, is_thematic = is_thematic, debug_mode = debug_mode)
# hand-verified to be correct
# update 2018-05-29, these numbers rely on the old method of using the source raster data grid instead of the
# common_grid.tif
hu12_7509_totalN_2006 = {"CELL_COUNT": 7, "MIN": 6.749966, "MAX": 7.41714, "MEAN": 7.026327, "STD": 0.226898}
hu12_7454_totalN_2006 = {"CELL_COUNT": None, "MIN": None, "MAX": None, "MEAN": None, "STD": None}
def polygons_in_zones(out_table, selection_expression = ''):
zone_fc = os.path.join(TEST_DATA_GDB, 'HU12')
polygons_fc = os.path.join(TEST_DATA_GDB, 'Lakes_1ha')
lagosGIS.polygons_in_zones(zone_fc, 'ZoneID', polygons_fc, out_table, selection_expression)
def lakes_in_zones(out_table):
zone_fc = os.path.join(TEST_DATA_GDB, 'HU12')
polygons_fc = os.path.join(TEST_DATA_GDB, 'Lakes_1ha')
lagosGIS.lakes_in_zones(zone_fc, 'ZoneID', polygons_fc, out_table)
def interlake_watersheds_NE(out_fc):
watersheds = os.path.join(TEST_DATA_GDB, 'Local_Catchments_Original_Methods')
nhd_gdb = TEST_DATA_GDB
eligible_lakes = os.path.join(TEST_DATA_GDB, 'eligible_lakes')
lagosGIS.aggregate_watersheds_NE(watersheds, nhd_gdb, eligible_lakes, out_fc, mode = 'interlake')
def interlake_watersheds_US(out_fc):
# watersheds = r'C:\Users\smithn78\Dropbox\CL_HUB_GEO\QAQC\New_Watershed_Methods\Test.gdb\lake_and_flowline_catchments_feb27'
nhdplus_gdb = r'D:\Not_ContLimno\NHDPlus HR\NHDPlus_H_0205_GDB.gdb'
eligible_lakes = r'C:\Users\smithn78\Dropbox\CL_HUB_GEO\LAGOS_US_GIS_Data_v0.5.gdb\Lakes\LAGOS_US_All_Lakes_1ha'
lagosGIS.aggregate_watersheds_US(nhdplus_gdb, eligible_lakes, out_fc, mode = 'interlake')