rspatial / geodata

download geographic data
GNU General Public License v3.0
151 stars 15 forks source link

`sp_occurrence` changes original coordinate column names #21

Closed AMBarbosa closed 2 years ago

AMBarbosa commented 2 years ago

I often like to have students use geodata::sp_occurrence instead of the more widely used rgbif functions, because it's simpler to install and the resulting object is simpler to handle. However, this breaks downstream code that uses the original GBIF column names "decimalLongitude" and "decimalLatitude", and makes it difficult to have everyone use whichever function they prefer and then use the remaining scripts seamlessly. Is there a good reason for geodata::sp_occurrence to change these names to 'lon' and 'lat'? Could an option be provided for keeping the original column names? Cheers

rhijmans commented 2 years ago

You can now keep the or9ginal names with argument fixnames=FALSE

f <- sp_occurrence("solanum", "cantense")
g <- sp_occurrence("solanum", "cantense", fix=FALSE)

names(f)[!(names(f) %in% names(g))]
#[1] "adm1"  "adm2"  "cloc"  "fullCountry" "ISO2"   "lat"   "lon"        
names(g)[!(names(g) %in% names(f))]
#[1] "countryCode"   "county"   "decimalLatitude"  "decimalLongitude" "stateProvince"