Skip to contents

Match country names to their equivalent naturalearth WKT polygons using rnaturalearth::ne_countries().

Usage

match_countries(countrynames, returnmulti = TRUE, onlywkt = FALSE)

Arguments

countrynames

a vector of country names to match to naturalearth.

returnmulti

return the GBIF taxon ids only (otherwise return the full lookup dataframe).

onlywkt

only return location_wkt (see note for more details).

Value

A list containing:

  • $location_wkt: a multipolygon containing all locations (or a named vector of individual country polygons).

  • $missing_locs: any provided countries not found in naturalearth.

  • $found_locs: any provided countries that were found in naturalearth.

Author

Francis Windram

Examples

match_countries(c("United Kingdom", "Germany"))
#> $location_wkt
#> [1] "MULTIPOLYGON (((14.119686 53.757029, 14.353315 53.248171, 14.074521 52.981263, 14.4376 52.62485, 14.685026 52.089947, 14.607098 51.745188, 15.016996 51.106674, 14.570718 51.002339, 14.307013 51.117268, 14.056228 50.926918, 13.338132 50.733234, 12.966837 50.484076, 12.240111 50.266338, 12.415191 49.969121, 12.521024 49.547415, 13.031329 49.307068, 13.595946 48.877172, 13.243357 48.416115, 12.884103 48.289146, 13.025851 47.637584, 12.932627 47.467646, 12.62076 47.672388, 12.141357 47.703083, 11.426414 47.523766, 10.544504 47.566399, 10.402084 47.302488, 9.896068 47.580197, 9.594226 47.525058, 8.522612 47.830828, 8.317301 47.61358, 7.466759 47.620582, 7.593676 48.333019, 8.099279 49.017784, 6.65823 49.201958, 6.18632 49.463803, 6.242751 49.902226, 6.043073 50.128052, 6.156658 50.803721, 5.988658 51.851616, 6.589397 51.852029, 6.84287 52.22844, 7.092053 53.144043, 6.90514 53.482162, 7.100425 53.693932, 7.936239 53.748296, 8.121706 53.527792, 8.800734 54.020786, 8.572118 54.395646, 8.526229 54.962744, 9.282049 54.830865, 9.921906 54.983104, 9.93958 54.596642, 10.950112 54.363607, 10.939467 54.008693, 11.956252 54.196486, 12.51844 54.470371, 13.647467 54.075511, 14.119686 53.757029)),((-6.197885 53.867565, -6.95373 54.073702, -7.572168 54.059956, -7.366031 54.595841, -7.572168 55.131622, -6.733847 55.17286, -5.661949 54.554603, -6.197885 53.867565)),((-3.093831 53.404547, -3.09208 53.404441, -2.945009 53.985, -3.614701 54.600937, -3.630005 54.615013, -4.844169 54.790971, -5.082527 55.061601, -4.719112 55.508473, -5.047981 55.783986, -5.586398 55.311146, -5.644999 56.275015, -6.149981 56.78501, -5.786825 57.818848, -5.009999 58.630013, -4.211495 58.550845, -3.005005 58.635, -4.073828 57.553025, -3.055002 57.690019, -1.959281 57.6848, -2.219988 56.870017, -3.119003 55.973793, -2.085009 55.909998, -2.005676 55.804903, -1.114991 54.624986, -0.430485 54.464376, 0.184981 53.325014, 0.469977 52.929999, 1.681531 52.73952, 1.559988 52.099998, 1.050562 51.806761, 1.449865 51.289428, 0.550334 50.765739, -0.787517 50.774989, -2.489998 50.500019, -2.956274 50.69688, -3.617448 50.228356, -4.542508 50.341837, -5.245023 49.96, -5.776567 50.159678, -4.30999 51.210001, -3.414851 51.426009, -3.422719 51.426848, -4.984367 51.593466, -5.267296 51.9914, -4.222347 52.301356, -4.770013 52.840005, -4.579999 53.495004, -3.093831 53.404547)))"
#> 
#> $missing_locs
#> character(0)
#> 
#> $found_locs
#> [1] "Germany"        "United Kingdom"
#>