-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListRasterFiles.py
63 lines (44 loc) · 1.64 KB
/
ListRasterFiles.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
59
60
61
62
63
# Script Name: ListRasterFiles.py
# Description:
#
# Inputs: 1) A folder containing tif files
#
# Outputs: 1) A text file that lists the layout name and projected coordinate system name.
#
# Script expects C:\Temp directory
#
# Version 0.2
# Created by: Juel Paul
# Date: 12th January 2020
# Import modules
import arcpy
from arcpy import env
import os
import csv
import datetime
inFLD = arcpy.GetParameterAsText(0) #folder with features
# Set workspace and environment variables
arcpy.env.workspace = inFLD
arcpy.env.overwriteOutput = True
arcpy.AddMessage("Searching the folder now...")
rsts = arcpy.ListRasters()
rstcount = len(rsts)
arcpy.AddMessage("{0} layouts in this folder.".format(rstcount))
arcpy.AddMessage("Creating text file...")
outTXT = datetime.datetime.now().strftime("C:\Temp\LayoutPlans_Report_%d%m%Y.txt")
# Create txt file appended with date then write header
# outputTXT = open("C:\Temp\LayoutParcels_Report.txt", 'w')
with open(outTXT, 'w') as txtfile:
txtfile.write("geolayout_name" + ", " + "coordsys" + "\n")
for rst in rsts:
#Get names of all rasters
desc = arcpy.Describe(rst)
rst_name = desc.baseName
#Get spatial reference of each
spatial_ref = desc.spatialReference
coords_psc = spatial_ref.PCSName
#coords_gsc = spatial_ref.GCSName
#arcpy.AddMessage(rst_name + "," + coords_psc + " " + coords_gsc)
#outputCSV.write(rst_name + " , " + coords_psc + " " + coords_gsc)
txtfile.write(rst_name + ", " + coords_psc + "\n")
#outputTXT.write("{0} layouts in this folder.".format(rstcount))