ropensci / CoordinateCleaner

Automated flagging of common spatial and temporal errors in biological and palaeontological collection data, for the use in conservation, ecology and palaeontology.
https://docs.ropensci.org/CoordinateCleaner/
79 stars 21 forks source link

clean_coordinates() fails for data subsets #87

Closed AMBarbosa closed 10 months ago

AMBarbosa commented 11 months ago

Lately, clean_coordinates() throws an error when applying the outliers test if the input data has had some rows removed. Here's a reproducible example:

dat <- geodata::sp_occurrence(genus = "Harpia", species = "harpyja", fixnames = FALSE)

dat_cc <- CoordinateCleaner::clean_coordinates(dat, lon = "decimalLongitude", lat = "decimalLatitude", species = "species")

# error because of missing coordinates; remove them and try again:

dat_cc <- CoordinateCleaner::clean_coordinates(subset(dat, !is.na(dat$decimalLatitude)), lon = "decimalLongitude", lat = "decimalLatitude", species = "species")

# Testing coordinate validity
# Flagged 0 records.
# Testing equal lat/lon
# Flagged 0 records.
# Testing zero coordinates
# Flagged 0 records.
# Testing country capitals
# Flagged 16 records.
# Testing country centroids
# Flagged 4 records.
# Testing sea coordinates
# trying URL 'https://naturalearth.s3.amazonaws.com/50m_physical/ne_50m_land.zip'
# Content type 'application/zip' length 457183 bytes (446 KB)
# downloaded 446 KB
# 
# Flagged 35 records.
# Testing geographic outliers
# Flagged 116 records.
# Error in `$<-.data.frame`(`*tmp*`, "otl", value = c(`1` = TRUE, `2` = TRUE,  : 
# replacement has 3789 rows, data has 3785
amadotalita commented 11 months ago

I am having the same problem for weeks now.

azizka commented 11 months ago

thanks for the note. We are working on version 3.x which will hopefully adress this issue and should be released end of september

BrunoVilela commented 10 months ago

The issue has been solved in the updated version, which is currently available on the master branch