-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportARGOS.py
More file actions
56 lines (44 loc) · 1.8 KB
/
Copy pathImportARGOS.py
File metadata and controls
56 lines (44 loc) · 1.8 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
##---------------------------------------------------------------------
## ImportARGOS.py
##
## Description: Read in ARGOS formatted tracking data and create a line
## feature class from the [filtered] tracking points
##
## Usage: ImportArgos <ARGOS folder> <Output feature class>
##
## Created: Fall 2022
## Author: shenyi.liu@duke.edu (for ENV859)
##---------------------------------------------------------------------
# Import modules
import sys, os, arcpy
# Set input variables (Hard-wired)
inputFile = 'V:/ARGOSTracking/data/ARGOSdata/1997dg.txt'
outputFC = "V:/ARGOSTracking/Scratch/ARGOStrack.shp"
outPath,outName = os.path.split(outputFC)
arcpy.management.CreateFeatureClass(outPath, outName)
#%% Construct a while loop to iterate through all lines in the datafile
# Open the ARGOS data file for reading
inputFileObj = open(inputFile,'r')
# Get the first line of data, so we can use a while loop
lineString = inputFileObj.readline()
# Start the while loop
while lineString:
# Set code to run only if the line contains the string "Date: "
if ("Date :" in lineString):
# Parse the line into a list
lineData = lineString.split()
# Extract attributes from the datum header line
tagID = lineData[0]
# Extract location info from the next line
line2String = inputFileObj.readline()
# Parse the line into a list
line2Data = line2String.split()
# Extract the date we need to variables
obsLat = line2Data[2]
obsLon= line2Data[5]
# Print results to see how we're doing
print (tagID,"Lat:"+obsLat,"Long:"+obsLon)
# Move to the next line so the while loop progresses
lineString = inputFileObj.readline()
#Close the file object
inputFileObj.close()