Skip to content

feat: Add download_all_layers function#380

Closed
popogis24 wants to merge 1 commit intoipeaGIT:masterfrom
popogis24:feature/download-all-layers
Closed

feat: Add download_all_layers function#380
popogis24 wants to merge 1 commit intoipeaGIT:masterfrom
popogis24:feature/download-all-layers

Conversation

@popogis24
Copy link
Copy Markdown

Add download_all_layers function

This PR adds a new function that allows users to download all available geobr layers at once.

Features

  • New download_all_layers function that downloads all available layers using their default years
  • Support for two output formats:
    • GeoJSON (default)
    • GPKG (GeoPackage)
  • Configurable output folder (defaults to 'geobr_layers')
  • Proper error handling and driver validation
  • Comprehensive test coverage

Example Usage

from geobr import download_all_layers

Download all layers in GeoJSON format (default)
download_all_layers()

Download all layers in GeoPackage format
download_all_layers(driver="GPKG")

Download to a custom folder
download_all_layers(output_folder="my_layers")

- Add new function to download all available geobr layers at once
- Support GeoJSON (default) and GPKG output formats
- Add comprehensive tests for the new functionality
- Implement proper error handling for invalid drivers
@rafapereirabr
Copy link
Copy Markdown
Member

Thanks for the PR, @popogis24 . I'm not sure, though, this is function we should have. What exactly is the use case here ?

@popogis24
Copy link
Copy Markdown
Author

popogis24 commented Mar 7, 2025

The main use case for this function is to streamline the process of downloading all available geobr layers in a single step, ensuring users have a local copy of the complete dataset without needing to call multiple functions manually.
This is particularly useful for applications that require offline access to geospatial data or for batch processing workflows where multiple layers are needed at once.

For example, I have a system that requires a spatial database to be always up to date, and this function would help me ensure that the latest data is downloaded automatically, without needing to do it manually.

@popogis24 popogis24 closed this Jul 23, 2025
@rafapereirabr
Copy link
Copy Markdown
Member

the data sets in geobr are not fully stable yet. Hence we use temporary cache that only lives within each session; untill we fix this, we strongly do not recommend storing geobr data locally because some data sets might be updated / fixed every now and then

@popogis24
Copy link
Copy Markdown
Author

popogis24 commented Jul 23, 2025

okay.

btw, I created tunned-geobr (it's just a fork with new scripts for more layers) if you want to take a look. It simply downloads data from the original sources to a temporary folder and returns it as a geopandas or dask-geopandas DataFrame (for some layers). I also added a lot of new layers, all scraped individually with custom logic.
(https://github.com/popogis24/tunned_geobr)

@rafapereirabr
Copy link
Copy Markdown
Member

Hi @popogis24 , the {geobr} package is led by myself and my team at Ipea but it is essentially and open project and we are glad to receive contributions from the community. In fact, the Python version of {geobr} was originally a community contribution ! I am sure some of the layers you're working with could be well incorporated into {geobr}, you would like to contribute to the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants