-
Notifications
You must be signed in to change notification settings - Fork 120
Description
Hi geobr team 👋 — I’ve been trying to use read_municipality() to load shapefiles for Brazilian municipalities, but keep encountering a persistent error that seems to stem from missing metadata files hosted on GitHub.
library(geobr)
# Attempting to load Acrelândia (code_muni = 1200179) for 2017
read_municipality(code_muni = 1200179, year = 2017)
# Also fails for 2020
read_municipality(code_muni = 1200179, year = 2020)
Error in !downloaded_files$success : invalid argument type
After debugging, I found that the error is coming from download_metadata(), which tries to fetch this URL: https://raw.githubusercontent.com/ipeaGIT/geobr/master/r-package/metadata/metadata_simplified_municipality_2017.csv
This returns a 404 error (file not found), and the same happens for 2020 and other years. As a result, read_municipality() gets a malformed object and crashes when it tries to access downloaded_files$success.
Even when manually patching download_metadata() to return a valid list object, the underlying problem remains — the required metadata CSVs for those years do not exist.
✅ Expected Behavior
read_municipality() should check if the metadata URL exists before attempting to read it.
If the file doesn't exist, it should raise a user-friendly message explaining the problem.
Alternatively, fallback options or guidance on supported years would be helpful.
This seems to impact all requests to read_municipality() for certain years (2017, 2020) — even for valid municipality codes like 1200179. Is there something that I've done wrong in the download process?