brunobrr / bdc

Check out the vignettes with detailed documentation on each module of the bdc package
https://brunobrr.github.io/bdc
GNU General Public License v3.0
23 stars 7 forks source link

Issue with bdc_country_from_coordinates #247

Closed tmasri01 closed 1 year ago

tmasri01 commented 1 year ago

Hi! I'm running into an issue with bdc_country_from_coordinates. When I run the command, it doesn't stop, I've let it run for an hour.

Thank you :)

kguidonimartins commented 1 year ago

The function example seems to work fine. See below:

x <-
  data.frame(
    decimalLatitude = c(-22.9834, -39.857030, -17.06811, -46.69778),
    decimalLongitude = c(-69.095, -68.443588, 37.438108, -13.82444),
    country = c("", NA, NA, "Brazil")
  )

bdc::bdc_country_from_coordinates(
  data = x,
  lat = "decimalLatitude",
  lon = "decimalLongitude",
  country = "country"
)
#> Loading required package: rnaturalearth
#> Loading required package: rnaturalearthdata
#>
#> Attaching package: 'rnaturalearthdata'
#> The following object is masked from 'package:rnaturalearth':
#>
#>     countries110
#>
#> bdc_country_from_coordinates:
#> Country names were added to 3 records.
#> # A tibble: 4 × 3
#>   decimalLatitude decimalLongitude country
#>             <dbl>            <dbl> <chr>
#> 1           -23.0            -69.1 Chile
#> 2           -39.9            -68.4 Argentina
#> 3           -17.1             37.4 Mozambique
#> 4           -46.7            -13.8 Brazil

Created on 2023-02-28 by the reprex package (v2.0.1)

Can you provide a minimal reproducible example, please? Have a look at: https://reprex.tidyverse.org/

tmasri01 commented 1 year ago

I just ran a subset of 10,000 occurrences and it works just fine. My original dataset has 350,000 occurrences has been running for a few hours, perhaps it's too big?

For now I will run the code in smaller subsets. Thanks for the help!

kguidonimartins commented 1 year ago

Well done! This function still needs to be optimized for large datasets. We plan to include arguments for parallelization soon. I'm closing this issue. Please don't hesitate to reopen it whenever you need to.