-
Notifications
You must be signed in to change notification settings - Fork 9
/
featureCC.py
52 lines (40 loc) · 2.23 KB
/
featureCC.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
### *- Program: FeatureCC
### *- Objective: To determine the total number of point, line, and polygon shapefiles
### in a directory
### *- Input: Provided by the user (workspace)
### *- Output: Display total files for point, line, and polygon shapefiles to the user
# - START PROGRAM -
# Import OS module to load appropriate paths depending on which system is being used
import os
# Import ArcPy module to use built-in functions to achieve the program objective
import arcpy
# From ArcPy, import the environment/workspace
from arcpy import env
# Ask the user to input a file path to set as a workspace
env.workspace = raw_input("\nPlease enter your file path: ")
# Assign the workspace to a new variable
filePath = env.workspace
x = 0
while x < 1: # Set up a file validation system
if os.path.exists(filePath): # If file path, exists: continue. Otherwise..
x = 1 # ..go to Line 45
point = arcpy.ListFeatureClasses("*", "Point") # List point feature classes
line = arcpy.ListFeatureClasses("*", "Line") # List line feature classes
poly = arcpy.ListFeatureClasses("*", "Polygon") # List polygon feature classes
pointCount = len(point) # Count the number of point feature classes
lineCount = len(line) # Count the number of line feature classes
polyCount = len(poly) # Count the number of polygon feature classes
print("\nPOINTS:"), pointCount, ("files") # Print total for point feature classes
print("LINES:"), lineCount, ("files") # Print total for line feature classes
print("POLYGONS:"), polyCount, ("files\n") # Print total for polygon feature classes
else:
raw_input("\n!ERROR! - File path does not exist." # If file path does not exist..
"\nPress Enter to continue. ") # ..display an error message..
env.workspace = raw_input("\nPlease enter your file path: ") # ..and ask user to..
filePath = env.workspace # ..enter it again
# Import time module and exit the program in 10 seconds
import time
time.sleep(10)
# - END PROGRAM -
# I'm gonna make him an offer he can't refuse
# - Don Vito Corleone (The Godfather)