-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdahoLines.R
47 lines (30 loc) · 852 Bytes
/
IdahoLines.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
library(spatialEco)
library(rgeos)
library(rgdal)
library(sp)
wd <- setwd("c:/personal/R")
#' using a subset of idaho lines because I cannot open all
#' of them in R because of laptop limitation
#'
idaho <- readOGR(".", "idaholines")
plot(idaho)
slotNames(idaho) # just to check the slots available
lins <- idaho@lines
# if you want to report with line names
for (i in 1:length(lins)) {
print(paste0("Line #", i))
print(slot(slot(lins[[i]], "Lines")[[1]], "coords"))
}
# just node coordinates
allcoordinates = function(x) {
ret = NULL
#lins = x@idaho@lines
for(i in 1:length(lins)) {
ll = lins[[i]]@Lines
for (j in 1:length(ll))
ret = rbind(ret, coordinates(ll[[j]]))
}
ret
}
q <- allcoordinates(idaho)
write.csv(q, file="idahopnts.csv")