Skip to content

Commit

Permalink
rename functions world_countries and world_states to ne_countries & n…
Browse files Browse the repository at this point in the history
…e_states
  • Loading branch information
andysouth committed Nov 25, 2015
1 parent 8901053 commit 2a7c2a9
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 77 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Generated by roxygen2: do not edit by hand

export(ne_countries)
export(ne_download)
export(ne_file_name)
export(ne_load)
export(world_countries)
export(world_states)
export(ne_states)
import(rgdal)
import(sp)
2 changes: 1 addition & 1 deletion R/get_data.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Get data from within the package
#'
#' returns world country polygons at a specified scale, used by world_countries()
#' returns world country polygons at a specified scale, used by ne_countries()
#'
#' @param scale scale of map to return, one of \code{110}, \code{50}, \code{'small'}, \code{'medium'}
#' @param type country type, one of 'countries', 'map_units', 'sovereignty'
Expand Down
2 changes: 1 addition & 1 deletion R/rnaturalearth-package.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @name rnaturalearth
#' @docType package
#' @seealso world_countries
#' @seealso ne_countries
#' @import sp rgdal
#rgdal is needed for ne_download but we may want to put that in a separate package ?
NULL
Expand Down
10 changes: 5 additions & 5 deletions R/world_countries.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Get world country polygons
#' Get natural earth world country polygons
#'
#' returns world country polygons at a specified scale
#'
Expand All @@ -9,9 +9,9 @@
#' @param geounit a character vector of geounit names.
#' @param sovereignty a character vector of sovereignty names.
#' @examples
#' spdf_world <- world_countries()
#' spdf_africa <- world_countries(continent='africa')
#' spdf_france <- world_countries(country='france')
#' spdf_world <- ne_countries()
#' spdf_africa <- ne_countries(continent='africa')
#' spdf_france <- ne_countries(country='france')
#'
#' if (require(sp)) {
#' plot(spdf_world)
Expand All @@ -21,7 +21,7 @@
#' @return A \code{SpatialPolygonsDataFrame} object.
#' @export
#'
world_countries <- function(scale = 110,
ne_countries <- function(scale = 110,
type = 'countries',
continent = NULL,
country = NULL,
Expand Down
14 changes: 7 additions & 7 deletions R/world_states.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Get world state (admin level 1) polygons
#' Get natural earth world state (admin level 1) polygons
#'
#' returns world state polygons (administrative level 1) for specified countries
#' returns state polygons (administrative level 1) for specified countries
#'
#' @param country a character vector of country names.
#' @param geounit a character vector of geounit names.
Expand All @@ -9,20 +9,20 @@
#' @examples
#'
#' #comparing using country and geounit to filter
#' spdf_france_country <- world_states(country='france')
#' spdf_france_geounit <- world_states(geounit='france')
#' spdf_france_country <- ne_states(country='france')
#' spdf_france_geounit <- ne_states(geounit='france')
#'
#' if (require(sp)) {
#' plot(spdf_france_country)
#' plot(spdf_france_geounit)
#'
#' plot(world_states(country ='united kingdom'))
#' plot(world_states(geounit='england'))
#' plot(ne_states(country ='united kingdom'))
#' plot(ne_states(geounit='england'))
#' }
#' @return A \code{SpatialPolygonsDataFrame} object.
#' @export
#'
world_states <- function( country = NULL,
ne_states <- function( country = NULL,
geounit = NULL,
iso_a2 = NULL,
spdf = NULL) {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Here using `sp::plot` as a simple, quick way to plot maps. Maps could also be ma
require(sp)

#world countries
plot(world_countries())
plot(ne_countries())
#uk
plot(world_countries(country = 'united kingdom'))
plot(ne_countries(country = 'united kingdom'))
#states, admin level1 boundaries
plot(world_states(country ='spain'))
plot(ne_states(country ='spain'))

```

Expand Down
2 changes: 1 addition & 1 deletion man/get_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/world_countries.Rd → man/ne_countries.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions man/world_states.Rd → man/ne_states.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rnaturalearth.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions tests/testthat/test-world_countries.r
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
context("world countries : data saved in package")
context("ne countries : data saved in package")

spdf_world <- world_countries()
spdf_africa <- world_countries(continent='africa')
spdf_france <- world_countries(country='france')
spdf_world <- ne_countries()
spdf_africa <- ne_countries(continent='africa')
spdf_france <- ne_countries(country='france')

test_that("type of object returned is as expected", {
expect_is(spdf_world, "SpatialPolygonsDataFrame")
Expand All @@ -21,33 +21,33 @@ test_that("number of rows/polygons in objects is as expected", {

test_that("scale argument gives expected relative sizes of objects", {

expect_more_than( object.size(world_countries(scale='medium')),
object.size(world_countries(scale='small')) )
expect_more_than( object.size(ne_countries(scale='medium')),
object.size(ne_countries(scale='small')) )

expect_more_than( object.size(world_countries(scale=50)),
object.size(world_countries(scale=110)) )
expect_more_than( object.size(ne_countries(scale=50)),
object.size(ne_countries(scale=110)) )

})

test_that("equivalent scale arguments as numeric or text give identical results", {

expect_identical( world_countries(scale='medium'),
world_countries(scale=50) )
expect_identical( ne_countries(scale='medium'),
ne_countries(scale=50) )

expect_identical( world_countries(scale='small'),
world_countries(scale=110) )
expect_identical( ne_countries(scale='small'),
ne_countries(scale=110) )

})

test_that("Error message if incorrect filters are applied", {
expect_error(world_countries(continent='madeupname'))
expect_error(world_countries(country='madeupname'))
expect_error(world_countries(geounit='madeupname'))
expect_error(world_countries(sovereignty ='madeupname'))
expect_error(ne_countries(continent='madeupname'))
expect_error(ne_countries(country='madeupname'))
expect_error(ne_countries(geounit='madeupname'))
expect_error(ne_countries(sovereignty ='madeupname'))
})

test_that("Error message if incorrect type argument", {
expect_error(world_countries(type='madeupname'))
expect_error(ne_countries(type='madeupname'))
})


18 changes: 9 additions & 9 deletions vignettes/rnaturalearth.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ require(sp)
```{r, eval=TRUE, echo=TRUE, message=FALSE}
#world at small scale (low resolution)
sp::plot(world_countries(type='countries', scale='small'))
sp::plot(ne_countries(type='countries', scale='small'))
#countries, UK undivided
sp::plot(world_countries(country = 'united kingdom', type='countries'))
sp::plot(ne_countries(country = 'united kingdom', type='countries'))
#map_units, UK divided into England, Scotland, Wales and Northern Ireland
sp::plot(world_countries(country = 'united kingdom', type='map_units'))
sp::plot(ne_countries(country = 'united kingdom', type='map_units'))
#countries, large scale
sp::plot(world_countries(country = 'united kingdom', scale='large'))
sp::plot(ne_countries(country = 'united kingdom', scale='large'))
#countries, medium scale
#temporarily commented out to avoid utf conversion travis error with Curacao
#sp::plot(world_countries(country = 'united kingdom', scale='medium'))
#sp::plot(ne_countries(country = 'united kingdom', scale='medium'))
#countries, small scale
sp::plot(world_countries(country = 'united kingdom', scale='small'))
sp::plot(ne_countries(country = 'united kingdom', scale='small'))
#states country='united kingdom'
sp::plot(world_states(country ='united kingdom'))
sp::plot(ne_states(country ='united kingdom'))
#states geounit='england'
sp::plot(world_states(geounit='england'))
sp::plot(ne_states(geounit='england'))
#states country='france'
sp::plot(world_states(country ='france'))
sp::plot(ne_states(country ='france'))
```

Expand Down
28 changes: 14 additions & 14 deletions vignettes/what-is-a-country.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ require(sp)
```{r, eval=TRUE, echo=TRUE, message=FALSE}
#countries, UK undivided
sp::plot(world_countries(country = 'united kingdom', type='countries'))
sp::plot(ne_countries(country = 'united kingdom', type='countries'))
#map_units, UK divided into England, Scotland, Wales and Northern Ireland
sp::plot(world_countries(country = 'united kingdom', type='map_units'))
sp::plot(ne_countries(country = 'united kingdom', type='map_units'))
#sovereignty, Falkland Islands included in UK
sp::plot(world_countries(country = 'united kingdom', type='sovereignty'), col='red')
sp::plot(ne_countries(country = 'united kingdom', type='sovereignty'), col='red')
sp::plot(coastline110, col='lightgrey', lty=3, add=TRUE)
#France, country includes French Guiana
sp::plot(world_countries(country = 'france'))
sp::plot(ne_countries(country = 'france'))
#France map_units includes French Guiana too
sp::plot(world_countries(country = 'france', type='map_units'))
sp::plot(ne_countries(country = 'france', type='map_units'))
#France filter map_units by geounit to exclude French Guiana
sp::plot(world_countries(geounit = 'france', type='map_units'))
sp::plot(ne_countries(geounit = 'france', type='map_units'))
#France sovereignty includes South Pacicic islands
sp::plot(world_countries(country = 'france', type='sovereignty'), col='red')
sp::plot(ne_countries(country = 'france', type='sovereignty'), col='red')
sp::plot(coastline110, col='lightgrey', lty=3, add=TRUE)
Expand All @@ -59,14 +59,14 @@ sp::plot(coastline110, col='lightgrey', lty=3, add=TRUE)
```{r, eval=TRUE, echo=TRUE, message=FALSE}
#countries, large scale
sp::plot(world_countries(country = 'united kingdom', scale='large'))
sp::plot(ne_countries(country = 'united kingdom', scale='large'))
#countries, medium scale
#temporarily commented out to avoid utf conversion travis error with Curacao
#sp::plot(world_countries(country = 'united kingdom', scale='medium'))
#sp::plot(ne_countries(country = 'united kingdom', scale='medium'))
#countries, small scale
sp::plot(world_countries(country = 'united kingdom', scale='small'))
sp::plot(ne_countries(country = 'united kingdom', scale='small'))
```
Expand All @@ -76,14 +76,14 @@ sp::plot(world_countries(country = 'united kingdom', scale='small'))
```{r, eval=TRUE, echo=TRUE, message=FALSE}
#states country='united kingdom'
sp::plot(world_states(country ='united kingdom'))
sp::plot(ne_states(country ='united kingdom'))
#states geounit='england'
sp::plot(world_states(geounit='england'))
sp::plot(ne_states(geounit='england'))
#states country='france'
sp::plot(world_states(country ='france'))
sp::plot(ne_states(country ='france'))
#states geounit='france'
sp::plot(world_states(geounit='france'))
sp::plot(ne_states(geounit='france'))
```

Expand Down

0 comments on commit 2a7c2a9

Please sign in to comment.