Last active
December 31, 2015 21:28
-
-
Save BGranberg/8046668 to your computer and use it in GitHub Desktop.
Convert Isotrope Broadband Drive Test files (2013) to fileGDB feature classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import os | |
from os import listdir | |
import csv | |
def find_csv_filenames( path_to_dir, suffix=".csv" ): | |
filenames = listdir(path_to_dir) | |
return [ filename for filename in filenames if filename.endswith( suffix ) ] | |
arcpy.env.overwriteOutput = False | |
# Local variables: | |
inPath = r"I:/PROJECTS/Broadband/Isotrope/Isotrope2013/" | |
filenames = find_csv_filenames(inPath) | |
for csvFile in filenames: | |
headerList = [] | |
if "Alert.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Subband","DataProtocol","AlertType"] | |
elif "- DATA GPRS-EDGE.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Subband","DataProtocol","ConnectState","Terminationtype","DatasessionID","TransferID","Direction","Bytestransferred","Bytesremaining","Averagethroughput","Currentthroughput","ThroughputInterval","RLCDownlinkThroughput","RLCUplink Throughput","Mode","DownlinkCoding","UplinkCoding","NoTimeslotsdown","NoTimeslotsup","CI"] | |
elif "- DATA HSPA.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Subband","DataProtocol","ConnectState","Terminationtype","DatasessionID","TransferID","Direction","Bytestransferred","Bytesremaining","Averagethroughput","Currentthroughput","ThroughputInterval","RLCDownlinkThroughput","RLCUplinkThroughput","RLCBLERDown","DownlinkSpreadFactor","UplinkSpreadFactor","CQI","Noofcodesinuse","Modulation","MACLayerThroughput1sec","MACLayerThroughput5sec"] | |
elif "- DATA Link Status.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Subband","DataProtocol","ConnectState","LinkBringupTime","DatasessionID","LinkDialupTime","LinkLayerEstablish"] | |
elif "- DATA UMTS.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Subband","DataProtocol","ConnectState","Terminationtype","DatasessionID","TransferID","Direction","Bytestransferred","Bytesremaining","Averagethroughput","Currentthroughput","ThroughputInterval","RLCDownlinkThroughput","RLCUplinkThroughput","RLCBLERDown","DownlinkSpreadFactor","UplinkSpreadFactor","TransportBLERDown"] | |
elif "- GSM.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","PhoneState","Hyperband","ARFCN","RSSI","RxQualSub","TXPower","BSIC","CID","TimeSlot","MCC","MNC","LAC","Timingadvance","HandoverRecord"] | |
elif "- UMTS.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","PhoneState","Hyperband","DownlinkUARFCN","RSSI","BLER","TXPower","CompressedMode","CID","URAID","MCC","MNC","LAC","ActiveSet","Active1Cellname","Active1RSSI","Active1EcNo","Active1RSCP","Active2Cellname","Active2RSSI","Active2EcNo","Active2RSCP","Active3Cellname","Active3RSSI","Active3EcNo","Active3RSCP","Active4Cellname","Active4RSSI","Active4EcNo","Active4RSCP","Active5Cellname","Active5RSSI","Active5EcNo","Active5RSCP","Active6Cellname","Active6RSSI","Active6EcNo","Active6RSCP","HandoverRecord"] | |
elif "- CDMA.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","PhoneState","Hyperband","RFChannel","RSSI","FER","TXPower","BaseID","SysID","NetID","ActiveSet","Active1Cellname","Active1EcIo","Active2Cellname","Active2EcIo","Active3Cellname","Active3EcIo","Active4Cellname","Active4EcIo","Active5Cellname","Active5EcIo","Active6Cellname","Active6EcIo","HandoverRecord"] | |
elif "- DATA CDMA-EVDO" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Sub-band","DataProtocol","ConnectState","Terminationtype","DatasessionID","TransferID","Direction","Bytestransferred","Bytesremaining","Averagethroughput","Currentthroughput","ThroughputInterval","RLCDownlinkThroughput","RLCUplinkThroughput","EVDOAccessTerminalState","EVDOForwardBER","EVDOCurrentthroughputforward","EVDODataRateControl","EVDORLPlayerforwardthroughput","EVDORLPlayerreversethroughput","EVDOTotalRLPbytecounterdownlink","EVDOTotalRLPbytecounteruplink","EVDOThroughputInterval"] | |
elif "- EVDO.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","PhoneState","Hyperband","RFChannel","RSSI","SINR","TXPower","SectorID","EVDO1xHybridMode","ServingDRC","ActiveSet","Active1Cellname","Active1SINR","Active1EcIo","Active1DRCCover","Active2Cellname","Active2SINR","Active2EcIo","Active2DRCCover","Active3Cellname","Active3SINR","Active3EcIo","Active3DRCCover","Active4Cellname","Active4SINR","Active4EcIo","Active4DRCCover","Active5Cellname","Active5SINR","Active5EcIo","Active5DRCCover","Active6Cellname","Active6SINR","Active6EcIo","Active6DRCCover","HandoverRecord"] | |
elif "- DATA LTE.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","Hyperband","Sub-band","DataProtocol","ConnectState","Terminationtype","DatasessionID","TransferID","Direction","Bytestransferred","Bytesremaining","Averagethroughput","Currentthroughput","ThroughputInterval","RLCDownlinkThroughput","RLCUplinkThroughput",""] | |
elif "- LTE.csv" in csvFile: | |
headerList = ["Date","Time","UTCOffset","Latitude","Longitude","Satellites","HDOP","Heading","PhoneState","Hyperband","EARFCN","AverageRSSI","AverageRSRP","TXPower","AverageRSRQ","CellID","CellsiteName","SINRAntenna1","SINRAntenna2","CQI","Rank","Numberofneighbors","Neighbor1CellsiteName","Neighbor1CellID","Neighbor1RSSI","Neighbor1RSRP","Neighbor1RSRQ","Neihgbor2CellsiteName","Neighbor2CellID","Neighbor2RSSI","Neighbor2RSRP","Neighbor2RSRQ","Neihgbor3CellsiteName","Neighbor3CellID","Neighbor3RSSI","Neighbor3RSRP","Neighbor3RSRQ"] | |
if len(headerList) > 0: | |
tmpFile = csvFile.replace(".","HEAD.") | |
tmpFullPath = os.path.join(inPath, tmpFile) | |
tmp = open(tmpFullPath, 'w') | |
origFullPath = os.path.join(inPath, csvFile) | |
orig = open(origFullPath, 'r') | |
tmp.write(','.join(headerList) + '\n') | |
for line in orig.readlines(): | |
tmp.write(line) | |
orig.close() | |
tmp.close() | |
os.remove(origFullPath) | |
os.rename(tmpFullPath, origFullPath) | |
tempLayerName = csvFile.replace(" ","").replace(".csv","").replace("-","") | |
outDBPath = r"C:/Isotrope13/drivetest.gdb/" | |
outFullPath = os.path.join(outDBPath, tempLayerName) | |
# Process: Make XY Event Layer | |
arcpy.MakeXYEventLayer_management(os.path.join(inPath, csvFile), "longitude", "latitude", tempLayerName, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433],METADATA['World',-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1262]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision", "") | |
# Process: Project to UTM NAD83 Zone North and Store in file GDB | |
arcpy.Project_management(tempLayerName, outFullPath , "PROJCS['NAD_1983_UTM_Zone_12N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-111.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "WGS_1984_(ITRF00)_To_NAD_1983", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433],METADATA['World',-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1262]]") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment