Skip to content

cem-usp/pmtilesbr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PMTilesBR

Project Status: Active – The project has reached a stable, usable state and is being actively developed. DOI Badge FAIR checklist badge fair-software.eu License: GPLv3 License: CC BY-NC-SA 4.0 Contributor Covenant 3.0 code of conduct badge

Overview

This repository hosts PMTiles files for spatial visualization and analysis in Brazil.

PMTiles is a format for storing and serving tiled geospatial data. It is designed to be efficient, scalable, and easy to use, making it ideal for web applications and data visualization.

We plan to move these files to a more permanent hosting solution in the future.

If you find this project useful, please consider giving it a star!   GitHub Repository Stars

Why Use PMTiles?

When working with complex geometries in web mapping applications like Mapbox, MapLibre, and Leaflet, performance can become a real problem. Shapes with many vertices make rendering slow, bloat file sizes, and generally make life harder. PMTiles addresses this by letting you serve precompiled tiles directly from the web, rather than bundling them into your application.

Usage

Tiles are available in the pmtiles directory and are hosted at cem-usp.github.io/pmtilesbr. For descriptions and metadata for each file, visit the project site.

To load a file, pass its URL to your application. For example, using R:

library(geobr)
library(magrittr)
library(mapgl)
library(pmtiles) # github.com/walkerke/pmtiles
pmtiles_file <- file.path(
  "https://cem-usp.github.io/pmtilesbr",
  "pmtiles",
  "geobr-2024-read_municipality-simplified-min-zoom-2-max-zoom-10.pmtiles"
)
pmtiles_metadata <-
  pmtiles_file |>
  pm_show(tilejson = TRUE)
pmtiles_layer <-
  pmtiles_metadata |>
  extract2("vector_layers") |>
  extract2(1) |>
  extract2("id")
pmtiles_bbox <-
  pmtiles_metadata |>
  extract2("bounds") |>
  unlist()
municipality_data <- read_municipality(
  year = 2024,
  simplified = TRUE,
  showProgress = TRUE,
  keep_areas_operacionais = FALSE
)
set.seed(1998)

scale_fill_mapgl <- match_expr(
  column = "code_muni",
  values = municipality_data |>
    extract2("code_muni"),
  stops = c("#db5025", "#070808", "#efd46a") |>
    sample(
      municipality_data |>
        extract2("code_muni") |>
        length(),
      replace = TRUE,
      prob = c(7, 1, 2)
    ),
  default = "#868489"
)
pmtiles_bbox |>
   maplibre(
    bounds = _,
    projection = "mercator",
  ) |>
  add_pmtiles_source(
    id = "municipality_borders",
    url = pmtiles_file,
    source_type = "vector"
  ) |>
  add_fill_layer(
    id = "screen_fill",
    source = "municipality_borders",
    source_layer = pmtiles_layer,
    fill_color = scale_fill_mapgl
  ) |>
  add_line_layer(
    id = "screen_outline",
    source = "municipality_borders",
    source_layer = pmtiles_layer,
    line_color = "white",
    line_width = 0.01
  )

Brazil Municipality Boundaries

Tip

Use pmtilesbr.io to easily inspect each PMTiles file before using.

Rendering

The files were processed using the Quarto publishing system, along with the Tippecanoe tool and the R programming language. To ensure consistent results, the renv package is used to manage and restore the R environment.

After installing the dependencies mentioned above, follow these steps to render the tiles:

  1. Clone this repository to your local machine.
  2. Open the project in your preferred IDE.
  3. Install package dependencies by running renv::restore() in the R console. This will install all required software dependencies.
  4. Open the Quarto notebooks in the qmd directory and run the code as described .

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 check the issues tab to see if your topic has already been reported.

Citation

DOI Badge

Note

When using this data, you must also cite the original data sources.

To cite this work, please use the following format:

Vartanian, D., Fernandes, C. N., & Giannotti, M. A. (2026). PMTilesBR: Tiled geospatial data for Brazil [Computer software]. Center for Metropolitan Studies, University of São Paulo. https://doi.org/10.5281/zenodo.19157888

A BibLaTeX entry for LaTeX users is:

@software{vartanian2026,
  title = {PMTilesBR: Tiled geospatial data for Brazil},
  author = {{Daniel Vartanian} and {Camila Nastari Fernandes} and {Mariana Abrantes Giannotti}},
  year = {2026},
  address = {São Paulo},
  institution = {Center for Metropolitan Studies, University of São Paulo},
  langid = {en},
  doi = {https://doi.org/10.5281/zenodo.19157888}
}

License

License: GPLv3 License: CC BY-NC-SA 4.0

Note

The original data sources may be subject to their own licensing terms and conditions.

The code in this repository is licensed under the GNU General Public License Version 3, while the files are available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.

Copyright (C) 2026 Center for Metropolitan Studies

The code in this repository 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/>.

Acknowledgments

This work was developed with support from the Center for Metropolitan Studies (CEM) based at the School of Philosophy, Letters and Human Sciences (FFLCH) of the University of São Paulo (USP) and at the Brazilian Center for Analysis and Planning (CEBRAP).
This work was financed, in part, by the São Paulo Research Foundation (FAPESP), Brazil. Process Number 2025/17879-2.