-
Notifications
You must be signed in to change notification settings - Fork 2
/
SimplifiedWorkflow.R
89 lines (67 loc) · 4.05 KB
/
SimplifiedWorkflow.R
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
87
88
89
#################
# Workflow in R for processing .las files for Oklahoma Writen by
# Mike Treglia, [email protected] Tested on R version 3.1.3 x64 on Windows
# 8 Lines w/ 2 hashtags are comments; lines w/ 1 hashtag were run and should
# not/need not be run again
###############
# Import function to run extract metadata from all .las files in directory
source("L:/OK_LiDAR_Processing/Metadata_Read_Edit/LAS_MetadataExtract.R")
source("L:/OK_LiDAR_Processing/FileManipulation/LAS_Reprojection.R")
setwd("M:/OK_LiDAR/OK_LAS_data")
## Get Metadata prior on original directory, after all files are uncompressed
#system.time(las.metadataExtract(path=getwd(), cores=8, out="LAS_Metadata_ORIG.csv"))
## Assign EPSG code for files w/out it in the metadata, based on inspections of those datasets
## This is not a function - just a script, as it is fairly specific to these data.
#system.time(source("L:/OK_LiDAR_Processing/Metadata_Read_Edit/LAS_AddProjectionInfo.R"))
## Reproject Files
#system.time(ReprojLog <- las.batch.reproj(path=getwd(), epsg=26914, cores=8, out="reprojectionLog.csv"))
##The above Reproject Files step failed mid-way through due to OSU HPCC problem, and some EPSG codes not recognized in LASTools
## Summary of what was done should be able to be extracted from '20151110ReprjSummary.csv' and '20151110ReprjSummary_Flagged.csv' (created using 'L:/OK_Lidar_Processing/Misc_BashCode/CountLas_COuntReproj.sh' on linux VM)
##Updated the metadata extract code on Unix to pull out creation date for files and vertical CRS info, as well as non-EPSG code based CRS string info.
##Ran this function in Linux VM:
# setwd("~")
#
# setwd("../../../data/groups/OK_LiDAR/OK_LAS_data/")
# system.time(LAS_Metadata_PostFailedReprj <- las.metadataExtract(path=getwd(), cores=4, out="LAS_Metadata_PostFailedReprj_20151130.csv"))
###############
# Next to be developed/run
# * Check metadata and if not projection not EPSG 26914, reproject to that; if no projection data, leave it
# * Code written - see LAS_Reprojection.R
# * Re-run metadata extraction - perhaps only for files w/ EPSG 26914(?)
# * For each file create minimum concave polygon... put everything into a single shapefile or geojson or similar
# * Have all .las files somehow indexed to respective polygons for spatial query
###############
## 20160202 - Removed all Reprj26914 files because they may not have been correctly reprojected depending on source EPSG
##Run to fix EPSG 29018 and convert to EPSG 26914 #Started 20160202
#
# setwd("~/../../../data/groups/OK_LiDAR/OK_LAS_data/")
#
# path <- getwd()
# epsgBad=29018
# epsgDes=26914
# cores=8
# system.time(CRSfixLog20160202 <- las.batch.EPSGfix(path=getwd(), epsgDes=26914, epsgBad=29018, cores=8, out="CRSfixLog20160202.csv"))
### Redo Metadata
# system.time(PostEPSGgFixMeta <- las.metadataExtract(path=getwd(), cores=8, out="PostEPSGFixMeta.csv"))
### Remove Files w/ No EPSG Code and with EPSG 29018
#
# setwd("~")
# setwd("../../../data/groups/OK_LiDAR/OK_LAS_data/")
#
# meta <- read.csv("PostEPSGFixMeta.csv", stringsAsFactors = FALSE)
#
# meta.bad.files <- meta[which(is.na(meta$epsgHoriz)|meta$epsgHoriz=="29018"),1]
#
# ## Doing this twice over-write files with duplicate names in different folders - this should be okay since these files were bad anyway
# system.time(for(i in 1:length(meta.bad.files)){
# file.rename(from=meta.bad.files[i], to=paste("../BadFiles/", (unlist(strsplit(meta.bad.files[i], split="/"))[length(unlist(strsplit(meta.bad.files[i], split="/")))]), sep=""))
# })
#
# system.time(for(i in 1:length(meta.bad.files)){
# file.rename(from=meta.bad.files[i], to=paste("../BadFiles/", (unlist(strsplit(meta.bad.files[i], split="/"))[length(unlist(strsplit(meta.bad.files[i], split="/")))]), sep=""))
# })
#### Reproject all data to EPSG 26914 (the majority projection)
setwd("~")
source("../../../data/users/mtreglia/OK_LiDAR_Processing/FileManipulation/LAS_Reprojection_unix.R")
setwd("../../../data/groups/OK_LiDAR/OK_LAS_data/")
system.time(ReprojLog_20160224 <- las.batch.reproj(path = getwd(), epsg=26914, cores=8, out="ReprojLog20160224.csv"))