Closed max-sfeeri closed 2 years ago
Thanks for reporting! Can you test again using the development version of {bdc}
, please? We’ll push a new version to CRAN in a few weeks.
if (!require("remotes")) install.packages("remotes")
#> Loading required package: remotes
## install the development version
remotes::install_github("brunobrr/bdc", force = TRUE)
#> Downloading GitHub repo brunobrr/bdc@HEAD
#>
#> * checking for file ‘/tmp/RtmpJcjy26/remotes2624128d4591/brunobrr-bdc-ff3f265/DESCRIPTION’ ... OK
#> * preparing ‘bdc’:
#> * checking DESCRIPTION meta-information ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building ‘bdc_1.0.0.tar.gz’
#> Installing package into '/home/karlo/.local/lib/R/library/4.1'
#> (as 'lib' is unspecified)
library(bdc)
decimalLatitude <- c(62.587273591263624, 66.62443625769812, 60.91266175537055, 59.166132649248496)
decimalLongitude <- c(30.81351622904529, 21.219645421093123, 10.65224213789756, 25.883878594365648)
country <- c("", "", "", "")
testframe <- data.frame(decimalLatitude, decimalLongitude, country)
bdc_country_from_coordinates(testframe)
#> Loading required package: rnaturalearth
#> Loading required package: rnaturalearthdata
#>
#> bdc_country_from_coordinates:
#> Country names were added to 4 records.
#> decimalLatitude decimalLongitude country
#> 1 62.58727 30.81352 Finland
#> 2 66.62444 21.21965 Sweden
#> 3 60.91266 10.65224 Norway
#> 4 59.16613 25.88388 Estonia
Created on 2022-03-09 by the reprex package (v2.0.1)
Thanks for the quick reply! I'll try this out tomorrow and report back.
Update: seems to be working! Tried it out with a few different configurations of coordinates, and now it returns the correct countries in the correct order.
Great! I'm closing this issue for now. Feel free to reopen if needed.
I am using bdc_country_from_coordinates() to find the appropriate countries for a long list of coordinates that do not have country information assigned to they. I found that the method does find the correct country for each coordinate, but in the process of outputting them, assigns the wrong country to the points.
Example that reproduces issue:
point1 = Finland, point2 = Sweden, point3 = Norway, point4 = Estonia)
bdc_country_from_coordinates: Country names were added to 4 records.
decimalLatitude decimalLongitude country 1 62.58727 30.81352 Estonia 2 66.62444 21.21965 Norway 3 60.91266 10.65224 Sweden 4 59.16613 25.88388 Finland
The output order is: Estonia, Norway, Sweden & Finland. The correct output order for these points should be Finland, Sweden, Norway & Estonia.