tunned-geobr 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. tunned_geobr-0.1.0/LICENSE.txt +2 -0
  2. tunned_geobr-0.1.0/PKG-INFO +103 -0
  3. tunned_geobr-0.1.0/README.md +79 -0
  4. tunned_geobr-0.1.0/pyproject.toml +63 -0
  5. tunned_geobr-0.1.0/tests/__init__.py +0 -0
  6. tunned_geobr-0.1.0/tests/read_state.py +112 -0
  7. tunned_geobr-0.1.0/tests/test_list_geobr.py +8 -0
  8. tunned_geobr-0.1.0/tests/test_lookup_muni.py +24 -0
  9. tunned_geobr-0.1.0/tests/test_read_amazon.py +11 -0
  10. tunned_geobr-0.1.0/tests/test_read_biomes.py +11 -0
  11. tunned_geobr-0.1.0/tests/test_read_census_tract.py +42 -0
  12. tunned_geobr-0.1.0/tests/test_read_comparable_areas.py +14 -0
  13. tunned_geobr-0.1.0/tests/test_read_conservation_units.py +11 -0
  14. tunned_geobr-0.1.0/tests/test_read_country.py +11 -0
  15. tunned_geobr-0.1.0/tests/test_read_disaster_risk_area.py +11 -0
  16. tunned_geobr-0.1.0/tests/test_read_health_facilities.py +18 -0
  17. tunned_geobr-0.1.0/tests/test_read_health_region.py +19 -0
  18. tunned_geobr-0.1.0/tests/test_read_immediate_region.py +18 -0
  19. tunned_geobr-0.1.0/tests/test_read_indigenous_land.py +11 -0
  20. tunned_geobr-0.1.0/tests/test_read_intermediate_region.py +16 -0
  21. tunned_geobr-0.1.0/tests/test_read_meso_region.py +26 -0
  22. tunned_geobr-0.1.0/tests/test_read_metro_area.py +11 -0
  23. tunned_geobr-0.1.0/tests/test_read_micro_region.py +25 -0
  24. tunned_geobr-0.1.0/tests/test_read_municipal_seat.py +11 -0
  25. tunned_geobr-0.1.0/tests/test_read_municipality.py +32 -0
  26. tunned_geobr-0.1.0/tests/test_read_neighborhood.py +11 -0
  27. tunned_geobr-0.1.0/tests/test_read_pop_arrangements.py +11 -0
  28. tunned_geobr-0.1.0/tests/test_read_region.py +11 -0
  29. tunned_geobr-0.1.0/tests/test_read_schools.py +11 -0
  30. tunned_geobr-0.1.0/tests/test_read_semiarid.py +11 -0
  31. tunned_geobr-0.1.0/tests/test_read_state.py +37 -0
  32. tunned_geobr-0.1.0/tests/test_read_statistical_grid.py +25 -0
  33. tunned_geobr-0.1.0/tests/test_read_urban_area.py +11 -0
  34. tunned_geobr-0.1.0/tests/test_read_urban_concentrations.py +11 -0
  35. tunned_geobr-0.1.0/tests/test_read_weighting_area.py +26 -0
  36. tunned_geobr-0.1.0/tests/test_utils.py +165 -0
  37. tunned_geobr-0.1.0/tunned_geobr/__init__.py +38 -0
  38. tunned_geobr-0.1.0/tunned_geobr/constants.py +13 -0
  39. tunned_geobr-0.1.0/tunned_geobr/data/grid_state_correspondence_table.csv +140 -0
  40. tunned_geobr-0.1.0/tunned_geobr/list_geobr.py +39 -0
  41. tunned_geobr-0.1.0/tunned_geobr/lookup_muni.py +111 -0
  42. tunned_geobr-0.1.0/tunned_geobr/read_amazon.py +42 -0
  43. tunned_geobr-0.1.0/tunned_geobr/read_amazon_ibas.py +92 -0
  44. tunned_geobr-0.1.0/tunned_geobr/read_atlantic_forest_ibas.py +93 -0
  45. tunned_geobr-0.1.0/tunned_geobr/read_biomes.py +43 -0
  46. tunned_geobr-0.1.0/tunned_geobr/read_census_tract.py +97 -0
  47. tunned_geobr-0.1.0/tunned_geobr/read_climate_aggressiveness.py +74 -0
  48. tunned_geobr-0.1.0/tunned_geobr/read_comparable_areas.py +75 -0
  49. tunned_geobr-0.1.0/tunned_geobr/read_conservation_units.py +43 -0
  50. tunned_geobr-0.1.0/tunned_geobr/read_country.py +43 -0
  51. tunned_geobr-0.1.0/tunned_geobr/read_disaster_risk_area.py +47 -0
  52. tunned_geobr-0.1.0/tunned_geobr/read_geology.py +77 -0
  53. tunned_geobr-0.1.0/tunned_geobr/read_geomorphology.py +77 -0
  54. tunned_geobr-0.1.0/tunned_geobr/read_health_facilities.py +49 -0
  55. tunned_geobr-0.1.0/tunned_geobr/read_health_region.py +52 -0
  56. tunned_geobr-0.1.0/tunned_geobr/read_immediate_region.py +81 -0
  57. tunned_geobr-0.1.0/tunned_geobr/read_indigenous_land.py +44 -0
  58. tunned_geobr-0.1.0/tunned_geobr/read_intermediate_region.py +61 -0
  59. tunned_geobr-0.1.0/tunned_geobr/read_meso_region.py +78 -0
  60. tunned_geobr-0.1.0/tunned_geobr/read_metro_area.py +44 -0
  61. tunned_geobr-0.1.0/tunned_geobr/read_micro_region.py +78 -0
  62. tunned_geobr-0.1.0/tunned_geobr/read_mining_processes.py +76 -0
  63. tunned_geobr-0.1.0/tunned_geobr/read_municipal_seat.py +41 -0
  64. tunned_geobr-0.1.0/tunned_geobr/read_municipality.py +83 -0
  65. tunned_geobr-0.1.0/tunned_geobr/read_neighborhood.py +39 -0
  66. tunned_geobr-0.1.0/tunned_geobr/read_pedology.py +77 -0
  67. tunned_geobr-0.1.0/tunned_geobr/read_pop_arrangements.py +45 -0
  68. tunned_geobr-0.1.0/tunned_geobr/read_region.py +41 -0
  69. tunned_geobr-0.1.0/tunned_geobr/read_schools.py +44 -0
  70. tunned_geobr-0.1.0/tunned_geobr/read_semiarid.py +42 -0
  71. tunned_geobr-0.1.0/tunned_geobr/read_settlements.py +85 -0
  72. tunned_geobr-0.1.0/tunned_geobr/read_state.py +88 -0
  73. tunned_geobr-0.1.0/tunned_geobr/read_statistical_grid.py +127 -0
  74. tunned_geobr-0.1.0/tunned_geobr/read_urban_area.py +44 -0
  75. tunned_geobr-0.1.0/tunned_geobr/read_urban_concentrations.py +46 -0
  76. tunned_geobr-0.1.0/tunned_geobr/read_weighting_area.py +74 -0
  77. tunned_geobr-0.1.0/tunned_geobr/utils.py +326 -0
@@ -0,0 +1,2 @@
1
+ YEAR: 2020
2
+ COPYRIGHT HOLDER: Institute for Appled Economic Research (Ipea)
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.1
2
+ Name: tunned-geobr
3
+ Version: 0.1.0
4
+ Summary: Fork personalizado do geobr com funcionalidades extras como download de dados da ANM
5
+ Author: Anderson Stolfi
6
+ License: MIT
7
+ Classifier: Intended Audience :: Science/Research
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Topic :: Scientific/Engineering :: GIS
11
+ Classifier: Topic :: Scientific/Engineering :: Visualization
12
+ Classifier: Programming Language :: Python
13
+ Project-URL: homepage, https://github.com/popogis24/tunned_geobr
14
+ Project-URL: repository, https://github.com/popogis24/tunned_geobr
15
+ Requires-Python: <4.0,>=3.9
16
+ Requires-Dist: geopandas<=1.1,>=1.0.0
17
+ Requires-Dist: shapely<=2.1.0,>=1.7.0
18
+ Requires-Dist: requests<3.0.0,>=2.25.1
19
+ Requires-Dist: lxml<6.0.0,>=5.1.0
20
+ Requires-Dist: html5lib==1.1
21
+ Requires-Dist: geobr<0.3.0,>=0.2.2
22
+ Requires-Dist: patool>=1.15.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # geobr: Download Official Spatial Data Sets of Brazil
26
+
27
+ <img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/geobr_logo_b.png?raw=true" alt="logo" width="140">
28
+ <img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/geobr_logo_y.png?raw=true" alt="logo" width="140">
29
+ <p align="justify">geobr is a computational package to download official spatial data sets of Brazil. The package includes a wide range of geospatial data in geopackage format (like shapefiles but better), available at various geographic scales and for various years with harmonized attributes, projection and topology (see detailed list of available data sets below). </p>
30
+
31
+ ## [READ FULL DOCS](https://github.com/ipeaGIT/geobr)
32
+
33
+ ## Contribute
34
+
35
+ To start the development environment run
36
+
37
+ ```sh
38
+ uv sync
39
+ ```
40
+
41
+ Test with
42
+
43
+ `uv run pytest -n auto`
44
+
45
+ You can use a helper to translate a function from R.
46
+ If you want to add `read_biomes`, just run
47
+
48
+ ```sh
49
+ uv run python helpers/translate_from_R.py read_biomes
50
+ ```
51
+
52
+ It will scrape the original R function to get documentation and metadata.
53
+ It adds:
54
+ - default year
55
+ - function name
56
+ - documentation one liner
57
+ - larger documentation
58
+ - very basic tests
59
+
60
+ ! Be aware that if the function that you are adding is more complicated than the template. So, always double check !
61
+
62
+
63
+
64
+
65
+ ## Translation Status
66
+
67
+ | Function | Translated? | Easy? |
68
+ | ------------------------- | ----------- | ----- |
69
+ | read_amazon | Yes | Super |
70
+ | read_biomes | Yes | Super |
71
+ | read_census_tract | Yes | No |
72
+ | read_comparable_areas | Yes | Yes |
73
+ | read_conservation_units | Yes | Super |
74
+ | read_country | Yes | Super |
75
+ | read_disaster_risk_area | Yes | Super |
76
+ | read_health_facilities | Yes | Super |
77
+ | read_health_region | Yes | Super |
78
+ | read_immediate_region | Yes | Yes |
79
+ | read_indigenous_land | Yes | Super |
80
+ | read_intermediate_region | Yes | Yes |
81
+ | read_meso_region | Yes | No |
82
+ | read_metro_area | Yes | Super |
83
+ | read_micro_region | Yes | No |
84
+ | read_municipal_seat | Yes | Super |
85
+ | read_municipality | Yes | No |
86
+ | read_region | Yes | Super |
87
+ | read_semiarid | Yes | Super |
88
+ | read_state | Yes | Super |
89
+ | read_statistical_grid | Yes | No |
90
+ | read_urban_area | Yes | Super |
91
+ | read_urban_concentrations | Yes | Super |
92
+ | read_weighting_area | Yes | No |
93
+ | list_geobr | Yes | Yes |
94
+ | lookup_muni | Yes | No |
95
+ | read_neighborhood | Yes | Yes |
96
+
97
+
98
+ # Release new version
99
+
100
+ ```
101
+ poetry version [patch|minor|major]
102
+ poetry publish --build
103
+ ```
@@ -0,0 +1,79 @@
1
+ # geobr: Download Official Spatial Data Sets of Brazil
2
+
3
+ <img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/geobr_logo_b.png?raw=true" alt="logo" width="140">
4
+ <img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/geobr_logo_y.png?raw=true" alt="logo" width="140">
5
+ <p align="justify">geobr is a computational package to download official spatial data sets of Brazil. The package includes a wide range of geospatial data in geopackage format (like shapefiles but better), available at various geographic scales and for various years with harmonized attributes, projection and topology (see detailed list of available data sets below). </p>
6
+
7
+ ## [READ FULL DOCS](https://github.com/ipeaGIT/geobr)
8
+
9
+ ## Contribute
10
+
11
+ To start the development environment run
12
+
13
+ ```sh
14
+ uv sync
15
+ ```
16
+
17
+ Test with
18
+
19
+ `uv run pytest -n auto`
20
+
21
+ You can use a helper to translate a function from R.
22
+ If you want to add `read_biomes`, just run
23
+
24
+ ```sh
25
+ uv run python helpers/translate_from_R.py read_biomes
26
+ ```
27
+
28
+ It will scrape the original R function to get documentation and metadata.
29
+ It adds:
30
+ - default year
31
+ - function name
32
+ - documentation one liner
33
+ - larger documentation
34
+ - very basic tests
35
+
36
+ ! Be aware that if the function that you are adding is more complicated than the template. So, always double check !
37
+
38
+
39
+
40
+
41
+ ## Translation Status
42
+
43
+ | Function | Translated? | Easy? |
44
+ | ------------------------- | ----------- | ----- |
45
+ | read_amazon | Yes | Super |
46
+ | read_biomes | Yes | Super |
47
+ | read_census_tract | Yes | No |
48
+ | read_comparable_areas | Yes | Yes |
49
+ | read_conservation_units | Yes | Super |
50
+ | read_country | Yes | Super |
51
+ | read_disaster_risk_area | Yes | Super |
52
+ | read_health_facilities | Yes | Super |
53
+ | read_health_region | Yes | Super |
54
+ | read_immediate_region | Yes | Yes |
55
+ | read_indigenous_land | Yes | Super |
56
+ | read_intermediate_region | Yes | Yes |
57
+ | read_meso_region | Yes | No |
58
+ | read_metro_area | Yes | Super |
59
+ | read_micro_region | Yes | No |
60
+ | read_municipal_seat | Yes | Super |
61
+ | read_municipality | Yes | No |
62
+ | read_region | Yes | Super |
63
+ | read_semiarid | Yes | Super |
64
+ | read_state | Yes | Super |
65
+ | read_statistical_grid | Yes | No |
66
+ | read_urban_area | Yes | Super |
67
+ | read_urban_concentrations | Yes | Super |
68
+ | read_weighting_area | Yes | No |
69
+ | list_geobr | Yes | Yes |
70
+ | lookup_muni | Yes | No |
71
+ | read_neighborhood | Yes | Yes |
72
+
73
+
74
+ # Release new version
75
+
76
+ ```
77
+ poetry version [patch|minor|major]
78
+ poetry publish --build
79
+ ```
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "tunned-geobr"
3
+ version = "0.1.0"
4
+ description = "Fork personalizado do geobr com funcionalidades extras como download de dados da ANM"
5
+ readme = "README.md"
6
+ requires-python = "<4.0,>=3.9"
7
+ authors = [
8
+ { name = "Anderson Stolfi" },
9
+ ]
10
+ dependencies = [
11
+ "geopandas>=1.0.0,<=1.1",
12
+ "shapely>=1.7.0,<=2.1.0",
13
+ "requests<3.0.0,>=2.25.1",
14
+ "lxml<6.0.0,>=5.1.0",
15
+ "html5lib==1.1",
16
+ "geobr>=0.2.2,<0.3.0",
17
+ "patool>=1.15.0",
18
+ ]
19
+ classifiers = [
20
+ "Intended Audience :: Science/Research",
21
+ "Intended Audience :: Developers",
22
+ "Intended Audience :: Education",
23
+ "Topic :: Scientific/Engineering :: GIS",
24
+ "Topic :: Scientific/Engineering :: Visualization",
25
+ "Programming Language :: Python",
26
+ ]
27
+
28
+ [project.license]
29
+ text = "MIT"
30
+
31
+ [project.urls]
32
+ homepage = "https://github.com/popogis24/tunned_geobr"
33
+ repository = "https://github.com/popogis24/tunned_geobr"
34
+
35
+ [build-system]
36
+ requires = [
37
+ "pdm-backend",
38
+ ]
39
+ build-backend = "pdm.backend"
40
+
41
+ [tool.pdm.build]
42
+ includes = [
43
+ "tunned_geobr",
44
+ ]
45
+ excludes = [
46
+ "**/*.gpkg",
47
+ ]
48
+
49
+ [tool.black]
50
+ line-length = 88
51
+ target-version = [
52
+ "py37",
53
+ ]
54
+ include = "\\.pyi?$"
55
+ exclude = "\n(\n /(\n \\.eggs # exclude a few common directories in the\n | \\.git # root of the project\n | \\.hg\n | \\.mypy_cache\n | \\.tox\n | \\.venv\n | _build\n | buck-out\n | build\n | dist\n )/\n | helpers/template\n)\n"
56
+
57
+ [tool.uv]
58
+ dev-dependencies = [
59
+ "pytest<7.0,>=6.0",
60
+ "pytest-xdist>=3.5.0",
61
+ "jinja2<4.0.0,>=3.1.4",
62
+ "fire<1.0.0,>=0.5.0",
63
+ ]
File without changes
@@ -0,0 +1,112 @@
1
+ import requests
2
+ import geopandas as gpd
3
+ import pandas as pd
4
+ import os
5
+ import tempfile
6
+ import sys
7
+ import fiona
8
+
9
+
10
+ def read_state(code_state, year=None, mode="simplified"):
11
+
12
+ # Get metadata with data addresses
13
+ metadata = download_metadata()
14
+
15
+ # Select geo
16
+ temp_meta = metadata.query('geo=="uf"')
17
+
18
+ # Select mode
19
+ if mode == "simplified":
20
+ temp_meta = temp_meta[temp_meta["download_path"].str.contains("simplified")]
21
+ elif mode == "normal":
22
+ temp_meta = temp_meta[~temp_meta["download_path"].str.contains("simplified")]
23
+ else:
24
+ print("not a valid argument for mode")
25
+
26
+ # Verify year input
27
+ if year is None:
28
+ print("Using data from year 2010\n")
29
+ year = 2010
30
+ temp_meta = temp_meta[temp_meta.year == 2010]
31
+ elif year in temp_meta.year.unique():
32
+ temp_meta = temp_meta[temp_meta.year == year]
33
+ else:
34
+ print(
35
+ "Error: Invalid Value to argument 'year'. It must be one of the following: ",
36
+ temp_meta["year"].unique(),
37
+ )
38
+ sys.exit()
39
+
40
+ # BLOCK 2.1 From 1872 to 1991 ----------------------------
41
+ if year < 1992:
42
+ if code_mun is None:
43
+ sys.exit("Value to argument 'code_state' cannot be NULL")
44
+ print("Loading data for the whole country\n")
45
+
46
+ # list paths of files to download
47
+ filesD = temp_meta.download_path.astype(str)
48
+
49
+ temp_sf = gpd.read_file(filesD.iloc[0])
50
+
51
+ return temp_sf
52
+
53
+ else:
54
+ # BLOCK 2.2 From 2000 onwards ----------------------------
55
+
56
+ # Verify code_state input
57
+
58
+ # Test if code_state input is null
59
+ if code_state is None:
60
+ sys.exit("Value to argument 'code_state' cannot be NULL")
61
+
62
+ if code_state == "all":
63
+ print("Loading data for the whole country\n")
64
+
65
+ # read files and pile them up
66
+
67
+ filesD = list(temp_meta.download_path.astype(str))
68
+
69
+ temp_sf = list()
70
+
71
+ for fp in filesD:
72
+
73
+ gdf = gpd.read_file(fp)
74
+
75
+ temp_sf.append(gdf)
76
+
77
+ temp_sf = gpd.GeoDataFrame(pd.concat(temp_sf, ignore_index=True))
78
+
79
+ return temp_sf
80
+
81
+ if (str(code_state)[0:2] not in temp_meta.code.unique()) and (
82
+ str(code_state)[0:2] not in temp_meta.code_abbrev.unique()
83
+ ):
84
+
85
+ sys.exit("Error: Invalid Value to argument code_state.")
86
+ else:
87
+
88
+ # list paths of files to download
89
+
90
+ if isinstance(code_state, int):
91
+
92
+ filesD = temp_meta[
93
+ temp_meta.code == str(code_state)[0:2]
94
+ ].download_path.iloc[0]
95
+
96
+ if isinstance(code_state, str):
97
+
98
+ filesD = temp_meta[
99
+ temp_meta.code_abbrev == str(code_state)[0:2]
100
+ ].download_path.iloc[0]
101
+
102
+ # download files
103
+
104
+ temp_sf = gpd.read_file(filesD)
105
+
106
+ if len(str(code_state)) == 2:
107
+
108
+ return temp_sf
109
+
110
+ else:
111
+
112
+ sys.exit("Error: Invalid Value to argument code_state.")
@@ -0,0 +1,8 @@
1
+ from geobr import list_geobr
2
+
3
+
4
+ def test_list_geobr(capsys):
5
+ list_geobr()
6
+ # Tests whether the function prints output
7
+ captured = capsys.readouterr()
8
+ assert len(captured.out) > 200
@@ -0,0 +1,24 @@
1
+ import pandas as pd
2
+ import pytest
3
+ from geobr.lookup_muni import lookup_muni
4
+
5
+
6
+ def test_lookup_muni():
7
+ # Check it is DataFrame object
8
+
9
+ assert isinstance(lookup_muni(name_muni="fortaleza"), pd.DataFrame)
10
+ assert isinstance(lookup_muni(code_muni=2304400), pd.DataFrame)
11
+ assert isinstance(lookup_muni(name_muni="all"), pd.DataFrame)
12
+ assert isinstance(lookup_muni(code_muni="all"), pd.DataFrame)
13
+ assert isinstance(lookup_muni(), pd.DataFrame)
14
+
15
+ # Check number of columns
16
+ df = lookup_muni(name_muni="rio de janeiro")
17
+ assert len(df.columns) == 13
18
+
19
+ assert len(lookup_muni()) > len(lookup_muni(code_muni=2304400))
20
+
21
+ # When using two arguments (supposed to give a warning)
22
+ with pytest.raises(Exception):
23
+ lookup_muni(code_muni=9999999)
24
+ lookup_muni(name_muni="alem paraiba do longinquo caminho curto")
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_amazon
4
+
5
+
6
+ def test_read_amazon():
7
+
8
+ assert isinstance(read_amazon(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_amazon(year=9999999)
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_biomes
4
+
5
+ def test_read_biomes():
6
+
7
+ assert isinstance(read_biomes(),
8
+ gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_biomes(year=9999999)
@@ -0,0 +1,42 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_census_tract
4
+
5
+
6
+ def test_read_census_tract():
7
+
8
+ assert isinstance(
9
+ read_census_tract(code_tract=11, zone="rural", year=2000),
10
+ gpd.geodataframe.GeoDataFrame,
11
+ )
12
+ assert isinstance(
13
+ read_census_tract(code_tract="AC", zone="rural", year=2000),
14
+ gpd.geodataframe.GeoDataFrame,
15
+ )
16
+ assert isinstance(
17
+ read_census_tract(code_tract="AP", zone="rural"), gpd.geodataframe.GeoDataFrame
18
+ )
19
+ assert isinstance(
20
+ read_census_tract(code_tract=11, zone="urban", year=2000),
21
+ gpd.geodataframe.GeoDataFrame,
22
+ )
23
+ assert isinstance(
24
+ read_census_tract(code_tract="AP", zone="urban", year=2000),
25
+ gpd.geodataframe.GeoDataFrame,
26
+ )
27
+ assert isinstance(
28
+ read_census_tract(code_tract="AP", zone="urban", year=2010),
29
+ gpd.geodataframe.GeoDataFrame,
30
+ )
31
+ assert isinstance(
32
+ read_census_tract(code_tract="all", year=2000), gpd.geodataframe.GeoDataFrame
33
+ )
34
+
35
+ with pytest.raises(Exception):
36
+
37
+ read_census_tract(year=9999999)
38
+ read_census_tract(code_tract="AP", year=2000, zone="ABCD")
39
+
40
+ read_census_tract(code_tract=None)
41
+ read_census_tract(code_tract="AC_ABCD")
42
+ read_census_tract()
@@ -0,0 +1,14 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_comparable_areas
4
+
5
+
6
+ def test_read_comparable_areas():
7
+
8
+ assert isinstance(read_comparable_areas(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_comparable_areas(year=9999999)
12
+ read_comparable_areas(12323423, 2010)
13
+
14
+ assert isinstance(read_comparable_areas(2000, 2010), gpd.geodataframe.GeoDataFrame)
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_conservation_units
4
+
5
+
6
+ def test_read_conservation_units():
7
+
8
+ assert isinstance(read_conservation_units(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_conservation_units(year=9999999)
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_country
4
+
5
+
6
+ def test_read_country():
7
+
8
+ assert isinstance(read_country(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_country(year=9999999)
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_disaster_risk_area
4
+
5
+
6
+ def test_read_disaster_risk_area():
7
+
8
+ assert isinstance(read_disaster_risk_area(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_disaster_risk_area(year=9999999)
@@ -0,0 +1,18 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_health_facilities
4
+
5
+
6
+ def test_read_health_facilities():
7
+
8
+ df = read_health_facilities()
9
+
10
+ assert isinstance(df, gpd.geodataframe.GeoDataFrame)
11
+
12
+ assert len(df) == 517629
13
+
14
+ with pytest.raises(Exception):
15
+ read_health_facilities(year=9999999)
16
+
17
+ with pytest.raises(Exception):
18
+ read_health_facilities(year="banana")
@@ -0,0 +1,19 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_health_region
4
+
5
+
6
+ def test_read_health_region():
7
+
8
+ assert isinstance(read_health_region(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_health_region(year=9999999)
12
+
13
+
14
+ def test_read_health_region_macro():
15
+
16
+ assert isinstance(read_health_region(macro=True), gpd.geodataframe.GeoDataFrame)
17
+
18
+ with pytest.raises(Exception):
19
+ read_health_region(year=9999999)
@@ -0,0 +1,18 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_immediate_region
4
+
5
+
6
+ def test_read_immediate_region():
7
+
8
+ assert isinstance(read_immediate_region(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ assert isinstance(
11
+ read_immediate_region(code_immediate="AC"), gpd.geodataframe.GeoDataFrame
12
+ )
13
+
14
+ assert len(read_immediate_region(code_immediate=110002).columns) == 8
15
+
16
+ with pytest.raises(Exception):
17
+ read_immediate_region(year=9999999)
18
+ read_immediate_region(code_intermediate=5201108312313213)
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_indigenous_land
4
+
5
+
6
+ def test_read_indigenous_land():
7
+
8
+ assert isinstance(read_indigenous_land(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_indigenous_land(year=9999999)
@@ -0,0 +1,16 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_intermediate_region
4
+
5
+
6
+ def test_read_intermediate_region():
7
+
8
+ assert isinstance(read_intermediate_region(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_intermediate_region(year=9999999)
12
+ read_intermediate_region(12323423535)
13
+
14
+ assert len(read_intermediate_region("SP")) > 0
15
+
16
+ assert len(read_intermediate_region(1101)) > 0
@@ -0,0 +1,26 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_meso_region
4
+
5
+
6
+ def test_read_meso_region():
7
+
8
+ assert isinstance(read_meso_region(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ assert isinstance(read_meso_region(code_meso=1401), gpd.geodataframe.GeoDataFrame)
11
+ assert isinstance(
12
+ read_meso_region(code_meso="AC", year=2010), gpd.geodataframe.GeoDataFrame
13
+ )
14
+ assert isinstance(
15
+ read_meso_region(code_meso=11, year=2010), gpd.geodataframe.GeoDataFrame
16
+ )
17
+ assert isinstance(
18
+ read_meso_region(code_meso="all", year=2010), gpd.geodataframe.GeoDataFrame
19
+ )
20
+
21
+ with pytest.raises(Exception):
22
+ read_meso_region(year=9999999)
23
+
24
+ read_meso_region(code_meso=5201108312313213)
25
+
26
+ read_meso_region(code_meso=9999999, year=9999999)
@@ -0,0 +1,11 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_metro_area
4
+
5
+
6
+ def test_read_metro_area():
7
+
8
+ assert isinstance(read_metro_area(), gpd.geodataframe.GeoDataFrame)
9
+
10
+ with pytest.raises(Exception):
11
+ read_metro_area(year=9999999)
@@ -0,0 +1,25 @@
1
+ import geopandas as gpd
2
+ import pytest
3
+ from geobr import read_micro_region
4
+
5
+
6
+ def test_read_micro_region():
7
+
8
+ assert isinstance(
9
+ read_micro_region(code_micro=11008), gpd.geodataframe.GeoDataFrame
10
+ )
11
+ assert isinstance(
12
+ read_micro_region(code_micro="AC", year=2010), gpd.geodataframe.GeoDataFrame
13
+ )
14
+ assert isinstance(
15
+ read_micro_region(code_micro=11, year=2010), gpd.geodataframe.GeoDataFrame
16
+ )
17
+ assert isinstance(
18
+ read_micro_region(code_micro="all", year=2010), gpd.geodataframe.GeoDataFrame
19
+ )
20
+
21
+ with pytest.raises(Exception):
22
+
23
+ read_micro_region(year=9999999)
24
+
25
+ read_micro_region(code_micro=9999999)