plot.spatialvalid minor issue
ThaiseEmilio opened this issue · comments
Hiya,
I am following the tutorial using my own data and found a minor problem with plot.spatialvalid as the attribute the lon and lat columns are not recognized automatically.
flags <- CleanCoordinates(x = gbif, lon = "decimalLongitude", lat = "decimalLatitude",
countries = "countryCode3",
species = "species",
countrycheck = T,
outliers = T) # most test are on by default
plot(flags)
Error in[.data.frame
(x, , c("decimallongitude", "decimallatitude")) :
undefined columns selected
My quick-and-dirty solution was renaming the columns in the CleanCoordinates output before plotting.
colnames(flags)[2:3]<-c("decimallongitude", "decimallatitude")
plot(flags)
Regions defined for each Polygons
This works fine but will be easier if it was not necessary and this implementation will be welcome.
Thanks,
Thaise
Hej,
thanks for the issue, that indeed seems unnecessary. Objects of class spatialvalid should have standardized column names. I couldn't reproduce the problem though. Which version of CoordinateCleaner are you using, and could you provide (a few lines) of example data?
Hiya,
Thanks for the reply. I just installed the GitHub version.
packageVersion("CoordinateCleaner")
[1] ‘1.1.1’
Please see below the the full code.
Thanks,
Thaise
rm(list=ls())
install.packages("devtools")
library(devtools)
install_github("azizka/CoordinateCleaner")
library(tidyverse)
library(rgbif)
library(countrycode)
library(CoordinateCleaner)
packageVersion("CoordinateCleaner")
gbif <- occ_search(scientificName = "Phoenix dactylifera", limit = 20000,
return = "data", hasCoordinate = T)
#select columns of interest
gbif <- gbif %>%
dplyr::select(species, decimalLongitude, decimalLatitude, countryCode, individualCount,
gbifID, family, taxonRank, coordinateUncertaintyInMeters, year,
basisOfRecord, institutionCode, datasetName)
#convert country code from ISO2c to ISO3c
gbif$countryCode3 <- countrycode(gbif$countryCode, origin = 'iso2c', destination = 'iso3c')
#flag problems
dat <- data.frame(gbif)
flags <- CleanCoordinates(x = gbif, lon = "decimalLongitude", lat = "decimalLatitude",
countries = "countryCode3",
species = "species",
countrycheck = T,
outliers = T) # most test are on by default
plot(flags) # return error
colnames(flags)[2:3]<-c("decimallongitude", "decimallatitude")
plot(flags) # now ok
fixed in version 2.0-2