-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFromGDB.py
More file actions
86 lines (70 loc) · 3.2 KB
/
FromGDB.py
File metadata and controls
86 lines (70 loc) · 3.2 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import arceditor
import arcpy
import os
arcpy.env.overwriteOutput = True
NON_SENSITIVE = common.CONFIG.get('FireGUARD', 'gis_share') + common.CONFIG.get('FireGUARD', 'gis_non_sensitive')
PROVINCIAL = common.CONFIG.get('FireGUARD', 'gis_prov')
# Script arguments
#~ HOME_DIR = os.path.dirname(os.path.realpath(__import__("__main__").__file__))
HOME_DIR = r'C:\FireGUARD\GIS'
File_GDB_Path = os.path.realpath(os.path.join(HOME_DIR, r'..\data\GIS\generated'))
File_GDB_Name = r'simplified.gdb'
To_GDB = os.path.join(File_GDB_Path, File_GDB_Name)
print "Preparing {}".format(To_GDB)
if not arcpy.Exists(To_GDB):
print "Creating {}".format(To_GDB)
arcpy.CreateFileGDB_management(File_GDB_Path, File_GDB_Name, "CURRENT")
print "Copying..."
SIMPLIFY_FEATURES = map(lambda _: os.path.join(NON_SENSITIVE, _),
[
"WETLAND",
"OHN_100K_WATERBODY",
"INDIAN_RESERVE",
"PROV_PARK_REGULATED",
"CONSERVATION_RESERVE",
])
NON_SENSITIVE_FEATURES = map(lambda _: os.path.join(NON_SENSITIVE, _),
[
"OHN_100K_WATERCOURSE",
"MNRF_ROAD_SEGMENT",
"ORN_SEGMENT_WITH_ADDRESS",
"UTILITY_LINE",
"ORWN_TRACK",
"TOURISM_ESTABLISHMENT_AREA",
"COTTAGE_RESIDENTIAL_SITE",
"UTILITY_SITE",
"FIRE_COMMUNICATIONS_TOWER",
"RECREATION_POINT",
"BOAT_CACHE_LOCATION",
"FISHING_ACCESS_POINT",
"TRAPPER_CABIN",
"BUILDING_AS_SYMBOL",
"CL_NON_FREEHOLD_DISPOSITION",
"AIRPORT_OFFICIAL",
"FIRE_RESPONSE_SECTOR",
"MNR_DISTRICT",
])
PROVINCIAL_FEATURES = map(lambda _: os.path.join(PROVINCIAL, _),
[
"COMMUNITIES",
"CITIESMAJOR",
"PROVINCIAL_FIRE_BLOCKS",
"PROVINCIAL_FIRE_INDEX",
])
def doSimplify(input):
output = os.path.join(To_GDB, os.path.basename(input))
print "{} => {}".format(input, output)
if not arcpy.Exists(output):
arcpy.SimplifyPolygon_cartography(input, output, "POINT_REMOVE", "10 Meters", "0 SquareMeters", "NO_CHECK", "NO_KEEP")
def doCopy(input):
output = os.path.join(To_GDB, os.path.basename(input))
print "{} => {}".format(input, output)
if not arcpy.Exists(output):
arcpy.FeatureClassToFeatureClass_conversion(input, To_GDB, os.path.basename(input), "", "", "")
for f in SIMPLIFY_FEATURES:
doSimplify(f)
for f in NON_SENSITIVE_FEATURES:
doCopy(f)
for f in PROVINCIAL_FEATURES:
doCopy(f)
arcpy.CompressFileGeodatabaseData_management(To_GDB)