Title: | African Administrative Boundary Polygons |
---|---|
Description: | Will make administrative boundary polygons for Africa easily accessible from R. |
Authors: | Andy South [aut, cre] |
Maintainer: | Andy South <[email protected]> |
License: | GPL (>= 3) | file LICENSE |
Version: | 0.0.0.9002 |
Built: | 2024-10-27 03:19:22 UTC |
Source: | https://github.com/afrimapr/afriadmin |
return all africa country names (may not need the function, given that I've saved as data afcountries)
afcountrynames(nameoriso3c = "name", filtercountries = NULL)
afcountrynames(nameoriso3c = "name", filtercountries = NULL)
nameoriso3c |
whether to return vector of 'name' or 'iso3c' or 'both' |
filtercountries |
optional filter countries that are in 'gadm2' potential to add others |
character vector of african country names
afcountrynames()
afcountrynames()
*in progress aim to plot admin levels for a single country either on same map or facetted to make it easier to see the structure
afplotadmin(country, datasource = "gadm", addcontext = FALSE)
afplotadmin(country, datasource = "gadm", addcontext = FALSE)
country |
a character vector of country names or iso3c character codes. |
datasource |
data source, initial default 'gadm' |
addcontext |
whether to plot neighbouring countries as well |
sf
returns admin polygons for specified countries and optionally plots map
afriadmin( country, level = 1, datasource = "geoboundaries", type = "simple", version = NULL, path = tempdir(), quiet = FALSE, plot = "mapview" )
afriadmin( country, level = 1, datasource = "geoboundaries", type = "simple", version = NULL, path = tempdir(), quiet = FALSE, plot = "mapview" )
country |
a character vector of country names or iso3c character codes. |
level |
which admin level to return |
datasource |
data source, 'geoboundaries' or 'gadm' |
type |
for geoboundaries, boundary type defaults to 'simple' One of 'HPSCU', 'HPSCGS', 'SSCGS', 'SSCU', or 'precise' 'simple' 'precise standard' 'simple standard' Determines the type of boundary link you receive. More on details |
version |
for geoboundaries defaults to the most recent version of geoBoundaries available. The geoboundaries version requested, with underscores. For example, 3_0_0 would return data from version 3.0.0 of geoBoundaries. |
path |
where to save downloaded data for gadm, defaults to tempdir() |
quiet |
for geoboundaries, if TRUE no message while downloading and reading the data. Default to FALSE |
plot |
option to display map 'mapview' for interactive, 'sf' for static |
sf
sfnga2 <- afriadmin("nigeria", level=2)
sfnga2 <- afriadmin("nigeria", level=2)
african country names and iso 3 letter country codes
afcountries
afcountries
dataframe
rnaturalearth
africa country polygons from GADM
sf_af_gadm0
sf_af_gadm0
sf
*in progress
alllevels(country, datasource = "gadm", plot = "tmap")
alllevels(country, datasource = "gadm", plot = "tmap")
country |
a character vector of country names or iso3c character codes. |
datasource |
data source, initial default 'gadm' |
plot |
option to display map 'mapview' for interactive, 'sf' for static |
sf
returns a mapview (or potentially later sf plot object), most arguments take a vector allowing two layers to be specified
compareadmin( country, level = c(1, 1), datasource = c("geoboundaries", "gadm"), type = c("simple", "simple"), version = c(NULL, NULL), quiet = FALSE, colors = c("red", "blue"), lwds = c(2, 2), col.regions = list(RColorBrewer::brewer.pal(9, "YlGn"), RColorBrewer::brewer.pal(9, "BuPu")), alpha = c(0.9, 0.9), layer.names = NULL, plotlegend = TRUE, alpha.regions = c(0.1, 0.1), plot = "mapview", plotshow = TRUE )
compareadmin( country, level = c(1, 1), datasource = c("geoboundaries", "gadm"), type = c("simple", "simple"), version = c(NULL, NULL), quiet = FALSE, colors = c("red", "blue"), lwds = c(2, 2), col.regions = list(RColorBrewer::brewer.pal(9, "YlGn"), RColorBrewer::brewer.pal(9, "BuPu")), alpha = c(0.9, 0.9), layer.names = NULL, plotlegend = TRUE, alpha.regions = c(0.1, 0.1), plot = "mapview", plotshow = TRUE )
country |
a character vector of country names or iso3c character codes. |
level |
1 |
datasource |
c('geoboundaries','gadm') |
type |
for geoboundaries, boundary type defaults to 'simple' One of 'HPSCU', 'HPSCGS', 'SSCGS', 'SSCU', or 'precise' 'simple' 'precise standard' 'simple standard' Determines the type of boundary link you receive. More on details |
version |
for geoboundaries defaults to the most recent version of geoBoundaries available. The geoboundaries version requested, with underscores. For example, 3_0_0 would return data from version 3.0.0 of geoBoundaries. |
quiet |
for geoboundaries, if TRUE no message while downloading and reading the data. Default to FALSE |
colors |
for the 2 sources of polygon boundaries default red,blue |
lwds |
line widths for the 2 sources of boundaries default 2,2 |
col.regions |
colour palettes for polygon fills |
alpha |
transparency for the two source boundaries default 0.9,0.9 |
layer.names |
optional names for the two source layers |
plotlegend |
whether to add legend |
alpha.regions |
transparency for the two source fills default 0.9,0.9 |
plot |
option to display map 'mapview' for interactive, 'namestable' for a table of names, 'sf' for static |
plotshow |
whether to display plot |
sf
compareadmin("togo", level=2) #comparing different types from geoboundaries compareadmin("togo", level=2, datasource=c('geoboundaries','geoboundaries'), type=c('sscu','hpscu') )
compareadmin("togo", level=2) #comparing different types from geoboundaries compareadmin("togo", level=2, datasource=c('geoboundaries','geoboundaries'), type=c('sscu','hpscu') )
#todo vectorise
country2iso(country)
country2iso(country)
country |
a character vector of country names |
character vector of iso3c codes
iso3c <- country2iso("nigeria")
iso3c <- country2iso("nigeria")
admin levels available by country from GADM (and names of the levels)
GADM36SF
GADM36SF
dataframe
https://cran.r-project.org/web/packages/GADMTools/index.html
#todo vectorise
hdxadmin(country, level = 2, plot = "sf")
hdxadmin(country, level = 2, plot = "sf")
country |
a character vector of country names |
level |
which admin level to return |
plot |
option to display map 'mapview' for interactive, 'sf' for static |
not sure yet
#hdxadmin("nigeria")
#hdxadmin("nigeria")
NOTE I changed ZBM to ZMB for Zambia
hdxlive( country, level = 2, colr_hdx = rgb(0, 0, 1, alpha = 0.4), colr_gadm = rgb(1, 0, 0, alpha = 0.4), lwd = 2, legend = TRUE, add = FALSE, alpha = 0.5, plot = "compare_sf" )
hdxlive( country, level = 2, colr_hdx = rgb(0, 0, 1, alpha = 0.4), colr_gadm = rgb(1, 0, 0, alpha = 0.4), lwd = 2, legend = TRUE, add = FALSE, alpha = 0.5, plot = "compare_sf" )
country |
a character vector of country names |
level |
which admin level to return |
colr_hdx |
colour for hdx boundaries in plots defaults blue semi-transparent |
colr_gadm |
colour for gadm boundaries in plots defaults red semi-transparent |
lwd |
line width in plots |
legend |
legend in sf plots TRUE/FALSE |
add |
whether to add sf plot to existing plot |
alpha |
transparency in mapview plots |
plot |
option to display map 'mapview' for interactive, 'sf' for static, 'compare' to sf compare with gadm |
start by checking whether I can open a few geojson files copied across
not sure yet
#hdxlive("angola") #hdxlive('benin',level=2) #hdxlive('zimbabwe',level=2) #to compare gadm and hdx #hdxlive('malawi',level=2, plot='compare_mapview')
#hdxlive("angola") #hdxlive('benin',level=2) #hdxlive('zimbabwe',level=2) #to compare gadm and hdx #hdxlive('malawi',level=2, plot='compare_mapview')
#todo vectorise
iso2country(iso3c)
iso2country(iso3c)
iso3c |
a character vector of country codes |
character vector of country names
name <- iso2country("nga")
name <- iso2country("nga")
initialy gadm but could be other sources too
maxadmin(country, datasource = "geoboundaries")
maxadmin(country, datasource = "geoboundaries")
country |
a character vector of country names |
datasource |
data source, initial default 'gadm' |
#todo change this to work on downloads (or save a table) #todo add geoboundaries option #todo vectorise
integer vector of max admin levels
maxlevel <- maxadmin("nigeria", datasource='geoboundaries')
maxlevel <- maxadmin("nigeria", datasource='geoboundaries')