Overview
orbis is an R package designed to simplify spatial data analysis. It adheres to tidyverse principles, integrates seamlessly with the tidyverse ecosystem, and provides a set of tools for working with raster and vector data.
If you find this project useful, please consider giving it a star!
Installation
You can install orbis using the remotes package:
# install.packages("remotes")
remotes::install_github("danielvartan/orbis", dependencies = TRUE)Usage
orbis is equipped with several functions to help with your analysis, such as:
- 
shift_and_rotate(): Shift and rotate raster or vector data.
- 
remove_unique_outliers(): Remove unique outliers from raster files.
- 
map_fill_data(): Prepare data to fill a map.
- 
filter_points(): Filter latitude/longitude points that intersects with a givensfgeometry.
- 
brazil_municipality(): Get Brazilian municipalities data.
- 
sidra_download_by_year(): Download and aggregate data by year from SIDRA API (to avoid overloading).
- 
worldclim_download(): Download WorldClim data.
- 
worldclim_to_ascii(): Convert WorldClim GeoTIFF files to Esri ASCII raster format.
Here are some examples of how to use a few of these functions.
shift_and_rotate()
shift_and_rotate() was developed to simplify shifting and rotating spatial data, especially for rasters and vectors that cross the dateline (e.g. the Russian territory).
Set the Environment
plot_vector <- function(vector) {
  plot <-
    vector |>
    ggplot() +
    geom_spatvector(fill = "#3243A6", color = "white")
  print(plot)
}Shift and Rotate the Country Vector -45 Degrees to the Left
russia_vector |> shift_and_rotate(-45) |> plot_vector()
remove_unique_outliers()
remove_unique_outliers() was developed to simplify the removal of abnormal values in raster files. It can be used with GeoTIFF and Esri ASCII raster formats.
Create a Fictional Esri ASCII File
asc_content <- c(
  "ncols         5",
  "nrows         5",
  "xllcorner     0.0",
  "yllcorner     0.0",
  "cellsize      1.0",
  "NODATA_value  -9999",
  "1 2 3 4 5 ",
  "6 7 8 9 10 ",
  "11 12 1000 14 15 ", # Extreme outlier (1000)
  "16 1 18 19 20 ",
  "21 22 23 24 25 "
)
temp_file <- tempfile(fileext = ".asc")
asc_content |> write_lines(temp_file)Visualize Values After remove_unique_outliers()
temp_file |> remove_unique_outliers()
map_fill_data()
map_fill_data() was developed to simplify the preparation of data to fill a map.
Set the Environment
plot_vector_shape <- function(vector) {
  plot <-
    vector |>
    ggplot() +
    geom_spatvector(fill = "white", color = "#3243A6")
  print(plot)
}
plot_vector_data <- function(data, vector) {
  plot <-
    data |>
    ggplot() +
    geom_spatvector(aes(fill = value), color = "white") +
    scale_fill_continuous(
        palette = c("#072359", "#3243A6", "#9483AF"),
        na.value = "white"
    ) +
    labs(fill = NULL)
  print(plot)
}Define the Data
data <- tibble(
  state = sample(brazil_states_vector$NAME_1, size = 1000, replace = TRUE),
  value = sample(1:1000, size = 1000, replace = TRUE)
)
data
#> # A tibble: 1,000 × 2
#>   state              value
#>   <chr>              <int>
#> 1 Minas Gerais         881
#> 2 Mato Grosso do Sul   300
#> 3 Amazonas             778
#> 4 Sergipe              393
#> 5 Acre                 682
#> 6 Roraima              369
#> # ℹ 994 more rowsCreate the Map Fill Data
data <- data |> map_fill_data(col_fill = "value", col_ref = "state")
#> ! There are duplicated values in state. value will be aggregated using the mean.
data
#> # A tibble: 27 × 2
#>   state              value
#>   <chr>              <dbl>
#> 1 Minas Gerais        581.
#> 2 Mato Grosso do Sul  538.
#> 3 Amazonas            543.
#> 4 Sergipe             464.
#> 5 Acre                546.
#> 6 Roraima             530.
#> # ℹ 21 more rows
filter_points()
filter_points() was developed to filter latitude/longitude points that intersect with a given sf geometry. This is particularly useful for removing points that fall in the ocean when working with country or state boundaries.
Set the Environment
Define the Points
data <- tibble(
  latitude = brazil_state_latitude(),
  longitude = brazil_state_longitude()
)
data
#> # A tibble: 27 × 2
#>   latitude longitude
#>      <dbl>     <dbl>
#> 1  -9.98       -67.8
#> 2  -9.65       -35.7
#> 3   0.0402     -51.1
#> 4  -3.13       -60.0
#> 5 -13.0        -38.5
#> 6  -3.73       -38.5
#> # ℹ 21 more rowsVisualize the Points on a Map
brazil_states_geometry <- read_state()
#> Using year/date 2010
data |> plot_points(brazil_states_geometry)
Set the Geometry to Filter the Points
sp_state_geometry <- read_state(code = "SP")
#> Using year/date 2010
sp_state_geometry |> plot_geometry()
Filter the Points
data <- data |> filter_points(sp_state_geometry)
data
#> # A tibble: 1 × 2
#>   latitude longitude
#>      <dbl>     <dbl>
#> 1    -23.6     -46.6Visualize the Filtered Points
data |> plot_points(brazil_states_geometry)
Click here to see the full list of functions.
Citation
If you use this package in your research, please cite it to acknowledge the effort put into its development and maintenance. Your citation helps support its continued improvement.
citation("orbis")
#> To cite orbis in publications use:
#> 
#>   Vartanian, D. (2025). orbis: Spatial data analysis tools [Computer
#>   software]. https://danielvartan.github.io/orbis
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Misc{,
#>     title = {orbis: Spatial data analysis tools},
#>     author = {Daniel Vartanian},
#>     year = {2025},
#>     url = {https://danielvartan.github.io/orbis},
#>     note = {R package},
#>   }License
Copyright (C) 2025 Daniel Vartanian
orbis is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.Contributing
Contributions are always welcome! Whether you want to report bugs, suggest new features, or help improve the code or documentation, your input makes a difference. Before opening a new issue, please take a moment to review our Guidelines for Contributing and check the issues tab to see if your topic has already been reported.
You can also support the development of orbis by becoming a sponsor. Click here to make a donation. Please mention orbis in your donation message.




