Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/inside.reg.lump.R
Finds regulation area from a position given in dataframe
1 |
data |
Data frame with columns |
to be added later
Original data with column area added, with index to list of
regulation areas in reg.lump
.
Could be repeated for other area divisions.
STJ
Borrows from inside.reg.bc
.
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (data)
{
if (nrow(data) > 1)
tmpdata <- data[, c("lat", "lon")]
else tmpdata <- as.data.frame(data[, c("lat", "lon")])
tmpdata$area <- rep(0, nrow(tmpdata))
i <- 1
ind <- geoinside(tmpdata, reg = reg.lump[[i]], option = 0,
robust = FALSE)
if (length(ind) > 0)
tmpdata[ind, "area"] <- i
i <- 2
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
i <- 3
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
i <- 4
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
i <- 5
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
i <- 6
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
i <- 7
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
i <- 8
j <- tmpdata$area == 0
j1 <- c(1:length(j))
j1 <- j1[j == T]
if (length(j1) > 0) {
ind <- geoinside(tmpdata[j1, ], reg = reg.lump[[i]],
option = 0, robust = FALSE)
if (length(ind) > 0)
tmpdata[j1[ind], "area"] <- i
}
data$area <- tmpdata$area
return(data)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.