knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

neighbor

{neighbor} gets and visualizes the neighbors of a spatial object (area objects) that has at least one point (or vertex) in common, but no intersection. This package uses the poly2nb function from the spdep package with the contiguity neighborhood type: queen and rook.

Installation

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("denis-or/neighbor")

Example

In this example, we are going to use the geobr package to get spatial data for Roraima, northern Brazil.

library(neighbor)
library(geobr)
rr <- geobr::read_municipality("RR")

Now we get the neighbors with the get_neighbor function:

nb <- neighbor::get_neighbor(shapefile = rr, tipo = "Queen")

In the next step, we will visualize the map with the connections between the municipalities. Note that we have added the ggtitle element from the ggplot package to the function.

neighbor::view_connections(nb) +
  ggplot2::ggtitle("Neighborhood of the municipalities of Roraima.")

We will also look at the neighboring municipalities named on the map.

neighbor::view_neighbor(nb) +
  ggplot2::ggtitle("Neighboring municipalities of Roraima.")

Author

Denis de Oliveira Rodrigues - catoper@gmail.com

License

{neighbor} is licensed under the MIT license. Check out LICENSE.md for the full text.



denis-or/neighbor documentation built on Dec. 19, 2021, 10:11 p.m.