library(svamap)
library(rgeos)
library(sp)
##
data(rough_lan)
pts <- read_point_data("//sva.se/UPP/Temp/Falkenrapporter/E16-036 Grundrapport.csv")
##
pts@data$Publicera <- factor(pts@data$Publicera, levels = c("Ja", "Nej"))
##
##Now keep all negatives unless Publicera is "Nej"; Drop all Positives unless Publicera is "Ja"
##
pts <- pts[(pts@data$Status..numerisk. == 0 &
(pts@data$Publicera != "Nej" | is.na(pts@data$Publicera))
) |
(pts@data$Publicera == "Ja" & !is.na(pts@data$Publicera)),]
## Drop the points that are not "Vilt (Jakt - fiske - natur)"
########################
selection <-
as.logical(pts[, "Djurh\u00E5llning"]@data == "Vilt (Jakt - fiske - natur)" &
!is.na(pts[, "Djurh\u00E5llning"]@data))
pts <- pts[selection,]
########################
##
rough_lan@proj4string <- pts@proj4string
##Count points per polygon
########################
## Project to planar
polys <- match_to_county(pts, rough_lan, "NUTS_ID")
polys <- polys[[1]]
## Just keep the basic info for the table
df <- polys@data[,c("name", "count")]
df$count <- as.integer(df$count)
df$count[is.na(df$count)] <- 0
total <- sum(df$count)
df <- rbind(df, c("Total", total))
## write the table
nolink <- c("<META NAME='ROBOTS' CONTENT='NOINDEX, NOFOLLOW'>")
tab <- html_table(df,
align = c("l", "r"),
col.names = c("L\u00E4n", "Antal unders\u00F6kta"),
html_head = generate_header(ordering = TRUE, otherstuff = nolink),
footer = TRUE
)
## Deploy table
path <- "deploy_pages/cwd_table"
dir.create(path, recursive = TRUE, showWarnings = FALSE)
file.copy(tab, file.path(path, "table.html"), overwrite = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.