-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
156 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#' check whether the requested data exist on Natural Earth | ||
#' | ||
#' checks from a list dependent on type, category and scale. If it returns FALSE the data may still exist on the website. | ||
#' Doesn't yet do checking on raster names because I found the naming convention too tricky. | ||
#' | ||
#' @param scale scale of map to return, one of \code{110}, \code{50}, \code{10} or \code{'small'}, \code{'medium'}, \code{'large'} | ||
#' @param type type of natural earth file to download one of 'countries', 'map_units', 'map_subunits', 'sovereignty', 'states' | ||
#' OR the portion of any natural earth vector url after the scale and before the . | ||
#' e.g. for 'ne_50m_urban_areas.zip' this would be 'urban_areas' | ||
#' @param category one of natural earth categories : 'cultural', 'physical', 'raster' | ||
|
||
#' @examples | ||
#' check_data_exist( scale = 110, category = 'cultural', type = 'countries' ) | ||
#' # type not in list for this category | ||
#' check_data_exist( scale = 110, category = 'physical', type = 'airports' ) | ||
#' # type in list but scale shows FALSE | ||
#' check_data_exist( scale = 110, category = 'cultural', type = 'airports' ) | ||
#' | ||
#' @return TRUE or FALSE | ||
#' @export | ||
|
||
check_data_exist <- function(scale = 110, | ||
type, | ||
category = c('cultural', 'physical', 'raster') | ||
) | ||
{ | ||
|
||
# check permitted category | ||
category <- match.arg(category) | ||
|
||
# todo doesn't yet check raster | ||
# I would need to create a data_list_raster.csv file | ||
if (category=='raster') return(TRUE) | ||
|
||
# check on permitted scales, convert names to numeric | ||
scale <- check_scale(scale) | ||
|
||
|
||
df_data <- read.csv( system.file("extdata", paste0("data_list_", category, ".csv"), package = "rnaturalearth") ) | ||
|
||
|
||
#first check if type is within the list | ||
if ( ! type %in% df_data$type ) | ||
{ | ||
warning(type," seems not to be in the list for category=", category, " maybe try the other category of c('cultural', 'physical')") | ||
return(FALSE) | ||
} | ||
|
||
#df_data[df_data$type=='roads', 'scale110'] | ||
|
||
exist <- df_data[df_data$type==type,paste0("scale",scale)] | ||
|
||
|
||
if (!exist) | ||
{ | ||
warning("your combination of type, category, scale", | ||
" seem not to exist in the list of Natural Earth data so you may get a download fail message.", | ||
" Check ?ne_download or http://www.naturalearthdata.com/features/ to see data availability.") | ||
} | ||
|
||
return(exist) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
type,scale110, scale50,scale10 | ||
countries,TRUE,TRUE,TRUE | ||
map_units,TRUE,TRUE,TRUE | ||
map_subunits,FALSE,TRUE,TRUE | ||
sovereignty,TRUE,TRUE,TRUE | ||
tiny_countries,TRUE,TRUE,TRUE | ||
states,FALSE,TRUE,TRUE | ||
populated_places,TRUE,TRUE,TRUE | ||
boundary_lines_land,TRUE,TRUE,TRUE | ||
pacific_groupings,TRUE,TRUE,TRUE | ||
breakaway_disputed_areas,FALSE,TRUE,TRUE | ||
boundary_lines_disputed_areas,FALSE,TRUE,TRUE | ||
boundary_lines_maritime_indicator,FALSE,TRUE,TRUE | ||
airports,FALSE,TRUE,TRUE | ||
ports,FALSE,TRUE,TRUE | ||
urban_areas,FALSE,TRUE,TRUE | ||
roads,FALSE,FALSE,TRUE | ||
railroads,FALSE,FALSE,TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
type,scale110, scale50,scale10 | ||
coastline,TRUE,TRUE,TRUE | ||
land,TRUE,TRUE,TRUE | ||
ocean,TRUE,TRUE,TRUE | ||
rivers_lake_centerlines,TRUE,TRUE,TRUE | ||
lakes,TRUE,TRUE,TRUE | ||
glaciated_areas,TRUE,TRUE,TRUE | ||
antarctic_ice_shelves_polys,TRUE,TRUE,TRUE | ||
geographic_lines,TRUE,TRUE,TRUE | ||
graticules_1,TRUE,TRUE,TRUE | ||
graticules_5,TRUE,TRUE,TRUE | ||
graticules_10,TRUE,TRUE,TRUE | ||
graticules_15,TRUE,TRUE,TRUE | ||
graticules_20,TRUE,TRUE,TRUE | ||
graticules_30,TRUE,TRUE,TRUE | ||
wgs84_bounding_box,TRUE,TRUE,TRUE | ||
playas,FALSE,TRUE,TRUE | ||
minor_islands,FALSE,FALSE,TRUE | ||
reefs,FALSE,FALSE,TRUE |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.