Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update read_health_facilities on python #347

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions python-package/geobr/read_health_facilities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from geobr.utils import select_metadata, download_gpkg


def read_health_facilities(verbose=False):
def read_health_facilities(date=202303, verbose=False):
""" Download geolocated data of health facilities as an sf object.

Data comes from the National Registry of Healthcare facilities (Cadastro Nacional de Estabelecimentos de Saude - CNES),
Expand All @@ -19,6 +19,8 @@ def read_health_facilities(verbose=False):

Parameters
----------
date : Numeric. Date of the data in YYYYMM format. Defaults to `202303`,
which was the latest data available by the time of this update.
verbose : bool, optional
by default False

Expand All @@ -40,7 +42,7 @@ def read_health_facilities(verbose=False):
>>> df = read_health_facilities()
"""

metadata = select_metadata("health_facilities", year=2015, simplified=False)
metadata = select_metadata("health_facilities", year=date, simplified=False)

gdf = download_gpkg(metadata)

Expand Down
2 changes: 1 addition & 1 deletion python-package/geobr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def select_year(metadata, year):
years = ", ".join([str(i) for i in metadata["year"].unique()])

raise Exception(
"Error: Invalid Value to argument year. "
"Error: Invalid Value to argument 'year/date'. "
"It must be one of the following: "
f'{_get_unique_values(metadata, "year")}'
)
Expand Down
5 changes: 4 additions & 1 deletion python-package/tests/test_read_health_facilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ def test_read_health_facilities():

assert isinstance(df, gpd.geodataframe.GeoDataFrame)

assert len(df) == 360177
assert len(df) == 517629

with pytest.raises(Exception):
read_health_facilities(year=9999999)

with pytest.raises(Exception):
read_health_facilities(year="banana")
Loading