# NOT RUN {
df <- sample_data_1
# Remove impossible coordinates
NROW(df)
df[1, "latitude"] <- 170
df <- dframe(df) %>% coord_impossible()
NROW(df)
attr(df, "coord_impossible")
# Remove incomplete cases
NROW(df)
df_inc <- dframe(df) %>% coord_incomplete()
NROW(df_inc)
attr(df_inc, "coord_incomplete")
# Remove imprecise cases
df <- sample_data_5
NROW(df)
## remove records that don't have decimals at all
df_imp <- dframe(df) %>% coord_imprecise(which = "has_dec")
NROW(df_imp)
attr(df_imp, "coord_imprecise")
## remove records that have all zeros
df_imp <- dframe(df) %>% coord_imprecise(which = "no_zeros")
NROW(df_imp)
attr(df_imp, "coord_imprecise")
## remove both records that don't have decimals at all and those that
## have all zeros
df_imp <- dframe(df) %>% coord_imprecise(which = "both")
NROW(df_imp)
attr(df_imp, "coord_imprecise")
# Remove unlikely points
NROW(df)
df_unlikely <- dframe(df) %>% coord_unlikely()
NROW(df_unlikely)
attr(df_unlikely, "coord_unlikely")
# Remove points not within correct political borders
if (requireNamespace("rgbif", quietly = TRUE) && interactive()) {
library("rgbif")
wkt <- 'POLYGON((30.1 10.1,40 40,20 40,10 20,30.1 10.1))'
res <- rgbif::occ_data(geometry = wkt, limit=300)$data
} else {
res <- sample_data_4
}
## By specific country name
if (
interactive() &&
requireNamespace("sf", quietly=TRUE) &&
requireNamespace("s2", quietly=TRUE) &&
requireNamespace("rworldmap", quietly=TRUE)
) {
NROW(res)
df_within <- dframe(res) %>% coord_within(country = "Israel")
NROW(df_within)
attr(df_within, "coord_within")
## By a field in your data - makes sure your points occur in one
## of those countries
NROW(res)
df_within <- dframe(res) %>% coord_within(field = "country")
NROW(df_within)
head(df_within)
attr(df_within, "coord_within")
}
# Remove those very near political centroids
## not ready yet
# NROW(df)
# df_polcent <- dframe(df) %>% coord_pol_centroids()
# NROW(df_polcent)
# attr(df_polcent, "coord_polcent")
## lat/long column names can vary
df <- sample_data_1
head(df)
names(df)[2:3] <- c('mylon', 'mylat')
head(df)
df[1, "mylat"] <- 170
dframe(df) %>% coord_impossible(lat = "mylat", lon = "mylon")
df <- sample_data_6
# Remove uncertain occurances
NROW(df)
df1<-df %>% coord_uncertain()
NROW(df1)
attr(df, "coord_uncertain")
NROW(df)
df2<-df %>% coord_uncertain(coorduncertainityLimit = 20000)
NROW(df2)
NROW(df)
df3<-df %>% coord_uncertain(coorduncertainityLimit = 20000,ignore.na=TRUE)
NROW(df3)
# }
Run the code above in your browser using DataLab