10.3 Extraindo altura e dap
Funções para extrair altura e diâmetro à altura do peito (DAP) de colunas descritivas.
10.3.1 Altura
<- function(x) {
pegaaltura <- gsub("\\+/-", "", x)
x <- gsub(" ", " ", x)
x <- gsub(" ", " ", x)
x # print(x)
<- "[-+]?[0-9]*[,.]?[0-9] m x"
pt1 <- "[-+]?[0-9]*[,.]?[0-9]m x"
pt2 <- "[-+]?[0-9]*[,.]?[0-9] m\\. x"
pt3 <- "[-+]?[0-9]*[,.]?[0-9] m de altura"
pt4 <- "[-+]?[0-9]*[,.]?[0-9] m\\. de altura"
pt5 <- "[-+]?[0-9]*[,.]?[0-9]m d ealtura"
pt6 <- "[-+]?[0-9]*[,.]?[0-9]m de alto"
pt7 <- "[-+]?[0-9]*[,.]?[0-9] m de alto"
pt8 <- "[-+]?[0-9]*[,.]?[0-9]m alto"
pt9 <- "[-+]?[0-9]*[,.]?[0-9]m de altura"
pt10 <- "[-+]?[0-9]*[,.]?[0-9] m tall"
pt11 <- "[-+]?[0-9]*[,.]?[0-9]m tall"
pt12 <- "[-+]?[0-9]*[,.]?[0-9] m\\. tall"
pt13 <- "[-+]?[0-9]*[,.]?[0-9] m\\. Tall"
pt14 <- "[-+]?[0-9]*[,.]?[0-9]m\\. tall"
pt15 <- "Tree, [-+]?[0-9]*[,.]?[0-9]m"
pt16 <- "Tree, [-+]?[0-9]*[,.]?[0-9] m"
pt17 <- "Tree [-+]?[0-9]*[,.]?[0-9] m"
pt18 <- "Tree [-+]?[0-9]*[,.]?[0-9]m"
pt19 <- "to [-+]?[0-9]*v?[0-9] m"
pt20 <- "Tree [0-9]*-[0-9]*m"
pt21 <- "de [-+]?[0-9]*[,.]?[0-9] m"
pt22 <- "de [-+]?[0-9]*v?[0-9]m"
pt23 <- "de [0-9]*-[0-9]* m"
pt24 <- "Tree [0-9]*-[0-9]* m"
pt25 <- "de [0-9]*-[0-9]*m"
pt26 <- "alt. [-+]?[0-9]*[,.]?[0-9] m"
pt27 <- "[-+]?[0-9]*[,.]?[0-9] feet high"
pt28 <- "[-+]?[0-9]*[,.]?[0-9] ft. high"
pt29
<- "rvore [-+]?[0-9]*[,.]?[0-9]m"
pt30 <- "rvore [-+]?[0-9]*[,.]?[0-9] m"
pt31 <- "rvore, [-+]?[0-9]*[,.]?[0-9] m"
pt32 <- "rvore, [-+]?[0-9]*[,.]?[0-9]m"
pt33
<- "rbusto [-+]?[0-9]*[,.]?[0-9]m"
pt34 <- "rbusto [-+]?[0-9]*[,.]?[0-9] m"
pt35 <- "rbusto, [-+]?[0-9]*[,.]?[0-9] m"
pt36 <- "rbusto, [-+]?[0-9]*[,.].?[0-9]m"
pt37 <- "rvore +/- [-+]?[0-9]*[,.].?[0-9]m"
pt38 <- "rvore ca. [-+]?[0-9]*[,.].?[0-9]m"
pt39 <- "de [-+]?[0-9]*[,.].?[0-9] de altura"
pt40 <- "altura [-+]?[0-9]*[,.].?[0-9]m"
pt41 <- "altura [-+]?[0-9]*[,.].?[0-9] m"
pt42 <- "of [-+]?[0-9]*[,.].?[0-9]m"
pt43 <- "to [-+]?[0-9]*[,.].?[0-9]m"
pt44 <- "Treelet [-+]?[0-9]*[,.].?[0-9]m"
pt45 <- "rvore [-+]?[0-9]*[,.].?[0-9] m"
pt46 <- "rvore, [-+]?[0-9]*[,.].?[0-9] m"
pt47 <- "rvoreta, [-+]?[0-9]*[,.].?[0-9] m"
pt48 <- "Fuste= [-+]?[0-9]*[,.].?[0-9] m"
pt49 <- "Fuste= [-+]?[0-9]*[,.].?[0-9]m"
pt50 <- "com [-+]?[0-9]*[,.].?[0-9] m. alt."
pt51 <- "Height: [-+]?[0-9]*[,.].?[0-9] m"
pt52 <- "Arbol [-+]?[0-9]*[,.].?[0-9]m"
pt53 <- "Treelet, [-+]?[0-9]*[,.].?[0-9]m"
pt54 <- "altura = [-+]?[0-9]*[,.].?[0-9]m"
pt55 <- "Fuste = [-+]?[0-9]*[,.].?[0-9]m"
pt56 <- "Fuste = [-+]?[0-9]*[,.].?[0-9] m"
pt57
<- NA
altura for (p in 1:57) {
<- get(paste("pt", p, sep = ""))
pt <- grep(pt, x, ignore.case = F)
gp if (length(gp) > 0 & is.na(altura)) {
# print(p)
<- strsplit(x, pt)[[1]]
rmm <- rmm[rmm != "" & rmm != "." & !is.na(rmm)]
rmm <- x
xx if (length(rmm) > 0) {
for (r in length(rmm):1) {
<- gsub(rmm[r], "", xx, fixed = T, useBytes = T)
xx
}
}<- trimws(gsub("[A-Z]|\\(|\\)|:|=", "", xx, ignore.case = T), which = "both")
xx <- gsub(",", ".", xx)
xx <- grep("-", xx)
tt if (length(tt) > 0) {
<- strsplit(xx, "-")[[1]]
xxx <- xxx[xxx != ""]
xxx <- gsub(" \\.", "", xxx)
xxx <- mean(as.numeric(trimws(xxx, which = "both")), na.rm = T)
xx else {
} <- strsplit(xx, " ")[[1]]
xx <- trimws(xx, which = "both")
xx <- xx[xx != "."]
xx <- xx[1]
xx
}<- as.numeric(xx)
xx if (!is.na(xx) && xx > 0) {
<- xx
altura else {
} <- NA
altura
}
}
}return(altura)
}
10.3.2 DAP
<- function(x) {
pegadap <- gsub("\\+/-", "", x)
x <- gsub(" ", " ", x)
x <- gsub(" ", " ", x)
x # print(x)
<- "x [-+]?[0-9]*[,.]?[0-9] cm de circ"
pt1 <- "x [-+]?[0-9]*[,.]?[0-9] cm de di"
pt2 <- "x [-+]?[0-9]*[,.]?[0-9]cm de di"
pt3 <- "x [-+]?[0-9]*[,.]?[0-9]cm di"
pt4 <- "m x [-+]?[0-9]*[,.]?[0-9] cm DAP"
pt5 <- "m x [-+]?[0-9]*[,.]?[0-9] cm"
pt6 <- "de [-+]?[0-9]*[,.]?[0-9] m de DAP"
pt7 <- "[-+]?[0-9]*[,.]?[0-9] cm de DAP"
pt8 <- "[-+]?[0-9]*[,.]?[0-9] cm (DAP)"
pt9 <- "[-+]?[0-9]*[,.]?[0-9] cm dbh"
pt10 <- "DAP [-+]?[0-9]*[,.]?[0-9] cm"
pt11 <- "[-+]?[0-9]*[,.]?[0-9] cm D.A.P."
pt12 <- "D.A.P. = [-+]?[0-9]*[,.]?[0-9] cm"
pt13 <- "[-+]?[0-9]*[,.]?[0-9]cm de di"
pt14 <- "[-+]?[0-9]*[,.]?[0-9]cm dap"
pt15 <- "[-+]?[0-9]*[,.]?[0-9]cm. dia"
pt16 <- "dbh. [-+]?[0-9]*[,.]?[0-9]cm"
pt17 <- "[-+]?[0-9]*[,.]?[0-9]cm. in dia"
pt18 <- "[-+]?[0-9]*[,.]?[0-9] cm de di"
pt19 <- "[-+]?[0-9]*[,.]?[0-9] cm (DAP)"
pt20 <- "DBH [-+]?[0-9]*[,.]?[0-9] cm"
pt21
# x="Árvore de 13m de altura x 11cm de diâmetro do fuste."
<- NA
altura for (p in 1:21) {
<- get(paste("pt", p, sep = ""))
pt <- grep(pt, x, ignore.case = F)
gp if (length(gp) == 1 & is.na(altura)) {
# print(p)
<- strsplit(x, pt)[[1]]
rmm <- rmm[rmm != "" & rmm != "." & !is.na(rmm)]
rmm <- x
xx if (length(rmm) == 1) {
for (r in length(rmm):1) {
<- gsub(rmm[r], "", xx, fixed = T, useBytes = T)
xx
}else {
} if (length(rmm) == 2) {
<- nchar(rmm[1])
n1 <- nchar(rmm[2])
n2 <- nchar(x)
n0 <- n1 + 1
ns <- n0 - n2
nt <- substr(x, ns, nt)
xx else {
} if (length(rmm) > 2) {
<- NA
xx
}
}
}if (!is.na(xx)) {
<- trimws(gsub("[A-Z]|\\(|\\)|:|=", "", xx, ignore.case = T), which = "both")
xx <- gsub(",", ".", xx)
xx <- grep("-", xx)
tt if (length(tt) > 0) {
<- strsplit(xx, "-")[[1]]
xxx <- xxx[xxx != ""]
xxx <- gsub(" \\.", "", xxx)
xxx <- mean(as.numeric(trimws(xxx, which = "both")), na.rm = T)
xx else {
} <- strsplit(xx, " ")[[1]]
xx <- trimws(xx, which = "both")
xx <- xx[xx != "." & xx != "" & xx != "..."]
xx <- xx[1]
xx if (substr(xx, nchar(xx), nchar(xx)) == ".") {
<- substr(xx, 1, nchar(xx) - 1)
xx
}
}<- as.numeric(xx)
xx if (xx > 0) {
<- xx
altura
}
}
}
}return(altura)
}