knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
{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.
And the development version from GitHub with:
# install.packages("remotes") remotes::install_github("denis-or/neighbor")
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.")
Denis de Oliveira Rodrigues - catoper@gmail.com
{neighbor}
is licensed under the MIT license. Check out
LICENSE.md
for the full text.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.