tunned-geobr 0.1.0__py3-none-any.whl

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 (46) hide show
  1. tunned_geobr/__init__.py +38 -0
  2. tunned_geobr/constants.py +13 -0
  3. tunned_geobr/data/grid_state_correspondence_table.csv +140 -0
  4. tunned_geobr/list_geobr.py +39 -0
  5. tunned_geobr/lookup_muni.py +111 -0
  6. tunned_geobr/read_amazon.py +42 -0
  7. tunned_geobr/read_amazon_ibas.py +92 -0
  8. tunned_geobr/read_atlantic_forest_ibas.py +93 -0
  9. tunned_geobr/read_biomes.py +43 -0
  10. tunned_geobr/read_census_tract.py +97 -0
  11. tunned_geobr/read_climate_aggressiveness.py +74 -0
  12. tunned_geobr/read_comparable_areas.py +75 -0
  13. tunned_geobr/read_conservation_units.py +43 -0
  14. tunned_geobr/read_country.py +43 -0
  15. tunned_geobr/read_disaster_risk_area.py +47 -0
  16. tunned_geobr/read_geology.py +77 -0
  17. tunned_geobr/read_geomorphology.py +77 -0
  18. tunned_geobr/read_health_facilities.py +49 -0
  19. tunned_geobr/read_health_region.py +52 -0
  20. tunned_geobr/read_immediate_region.py +81 -0
  21. tunned_geobr/read_indigenous_land.py +44 -0
  22. tunned_geobr/read_intermediate_region.py +61 -0
  23. tunned_geobr/read_meso_region.py +78 -0
  24. tunned_geobr/read_metro_area.py +44 -0
  25. tunned_geobr/read_micro_region.py +78 -0
  26. tunned_geobr/read_mining_processes.py +76 -0
  27. tunned_geobr/read_municipal_seat.py +41 -0
  28. tunned_geobr/read_municipality.py +83 -0
  29. tunned_geobr/read_neighborhood.py +39 -0
  30. tunned_geobr/read_pedology.py +77 -0
  31. tunned_geobr/read_pop_arrangements.py +45 -0
  32. tunned_geobr/read_region.py +41 -0
  33. tunned_geobr/read_schools.py +44 -0
  34. tunned_geobr/read_semiarid.py +42 -0
  35. tunned_geobr/read_settlements.py +85 -0
  36. tunned_geobr/read_state.py +88 -0
  37. tunned_geobr/read_statistical_grid.py +127 -0
  38. tunned_geobr/read_urban_area.py +44 -0
  39. tunned_geobr/read_urban_concentrations.py +46 -0
  40. tunned_geobr/read_weighting_area.py +74 -0
  41. tunned_geobr/utils.py +326 -0
  42. tunned_geobr-0.1.0.dist-info/METADATA +103 -0
  43. tunned_geobr-0.1.0.dist-info/RECORD +46 -0
  44. tunned_geobr-0.1.0.dist-info/WHEEL +4 -0
  45. tunned_geobr-0.1.0.dist-info/entry_points.txt +4 -0
  46. tunned_geobr-0.1.0.dist-info/licenses/LICENSE.txt +2 -0
@@ -0,0 +1,81 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg, change_type_list, test_options
2
+
3
+
4
+ def read_immediate_region(
5
+ code_immediate="all", year=2017, simplified=True, verbose=False
6
+ ):
7
+ """ Download shape files of Brazil's Immediate Geographic Areas as sf objects
8
+
9
+ The Immediate Geographic Areas are part of the geographic division of
10
+ Brazil created in 2017 by IBGE to replace the "Micro Regions" division.
11
+ Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000"
12
+ and CRS(4674)
13
+
14
+ Parameters
15
+ ----------
16
+ code_immediate:
17
+ 6-digit code of an immediate region. If the two-digit code or a
18
+ two-letter uppercase abbreviation of a state is passed, (e.g. 33 or
19
+ "RJ") the function will load all immediate regions of that state. If
20
+ code_immediate="all", all immediate regions of the country are loaded
21
+ (defaults to "all").
22
+ year : int, optional
23
+ Year of the data, by default 2017
24
+ simplify: boolean, by default True
25
+ Data 'type', indicating whether the function returns the 'original' dataset
26
+ with high resolution or a dataset with 'simplify' borders (Default)
27
+ verbose : bool, optional
28
+ by default False
29
+
30
+ Returns
31
+ -------
32
+ gpd.GeoDataFrame
33
+ Metadata and geopackage of selected states
34
+
35
+ Raises
36
+ ------
37
+ Exception
38
+ If parameters are not found or not well defined
39
+
40
+ Example
41
+ -------
42
+ >>> from cursed_geobr import read_immediate_region
43
+
44
+ # Read specific state at a given year
45
+ >>> df = read_immediate_region(year=2017)
46
+ """
47
+
48
+ test_options(code_immediate, "code_immediate", not_allowed=[None])
49
+
50
+ metadata = select_metadata("immediate_regions", year=year, simplified=simplified)
51
+
52
+ gdf = download_gpkg(metadata)
53
+
54
+ # ensure type
55
+ code_immediate = str(code_immediate)
56
+
57
+ if code_immediate == "all":
58
+
59
+ if verbose:
60
+ print(
61
+ "Loading data for the whole country. "
62
+ "This might take a few minutes.\n"
63
+ )
64
+
65
+ return gdf
66
+
67
+ elif code_immediate in gdf["abbrev_state"].tolist():
68
+
69
+ return gdf.query(f'abbrev_state == "{code_immediate}"')
70
+
71
+ elif code_immediate in change_type_list(gdf["code_state"].tolist()):
72
+
73
+ return gdf.query(f'code_state == "{code_immediate}"')
74
+
75
+ elif code_immediate in change_type_list(gdf["code_immediate"].tolist()):
76
+
77
+ return gdf.query(f'code_immediate == "{code_immediate}"')
78
+
79
+ else:
80
+
81
+ raise Exception("Invalid Value to argument 'code_immediate'")
@@ -0,0 +1,44 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_indigenous_land(date=201907, simplified=True, verbose=False):
5
+ """ Download official data of indigenous lands as an sf object.
6
+
7
+ The data set covers the whole of Brazil and it includes indigenous lands from all ethnicities and
8
+ in different stages of demarcation. The original data comes from the National Indian Foundation (FUNAI)
9
+ and can be found at http://www.funai.gov.br/index.php/shape. Although original data is updated monthly,
10
+ the geobr package will only keep the data for a few months per year.
11
+
12
+ Parameters
13
+ ----------
14
+ date : int, optional
15
+ A date numer in YYYYMM format, by default 201907
16
+ simplified: boolean, by default True
17
+ Data 'type', indicating whether the function returns the 'original' dataset
18
+ with high resolution or a dataset with 'simplified' borders (Default)
19
+ verbose : bool, optional
20
+ by default False
21
+
22
+ Returns
23
+ -------
24
+ gpd.GeoDataFrame
25
+ Metadata and geopackage of selected states
26
+
27
+ Raises
28
+ ------
29
+ Exception
30
+ If parameters are not found or not well defined
31
+
32
+ Example
33
+ -------
34
+ >>> from cursed_geobr import read_indigenous_land
35
+
36
+ # Read specific state at a given year
37
+ >>> df = read_indigenous_land(date=201907)
38
+ """
39
+
40
+ metadata = select_metadata("indigenous_land", year=date, simplified=simplified)
41
+
42
+ gdf = download_gpkg(metadata)
43
+
44
+ return gdf
@@ -0,0 +1,61 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_intermediate_region(
5
+ code_intermadiate="all", year=2019, simplified=True, verbose=False
6
+ ):
7
+ r"""Download spatial data of Brazil's Intermediate Geographic Areas
8
+
9
+ The intermediate Geographic Areas are part of the geographic division of
10
+ Brazil created in 2017 by IBGE. These regions were created to replace the
11
+ "Meso Regions" division. Data at scale 1:250,000, using Geodetic reference
12
+ system "SIRGAS2000" and CRS(4674)
13
+
14
+ Parameters
15
+ ----------
16
+ code_intermadiate: str or int, by default "all"
17
+ 4-digit code of an intermediate region. If the two-digit code or a
18
+ two-letter uppercase abbreviation of a state is passed,
19
+ (e.g. 33 or "RJ") the function will load all intermediate regions of that
20
+ state. If `code_intermediate="all"` (Default), all intermediate regions of
21
+ the country are loaded.
22
+ year : int, optional
23
+ Year of the data, by default 2019
24
+ simplified: boolean, by default True
25
+ Data 'type', indicating whether the function returns the 'original' dataset
26
+ with high resolution or a dataset with 'simplified' borders (Default)
27
+ verbose : bool, optional
28
+ by default False
29
+
30
+ Returns
31
+ -------
32
+ gpd.GeoDataFrame
33
+ Metadata and geopackage of selected states
34
+
35
+ Raises
36
+ ------
37
+ Exception
38
+ If parameters are not found or not well defined
39
+
40
+ Example
41
+ -------
42
+ >>> from cursed_geobr import read_intermediate_region
43
+
44
+ # Read specific state at a given year
45
+ >>> df = read_intermediate_region(year=2019)
46
+ """
47
+
48
+ metadata = select_metadata("intermediate_regions", year=year, simplified=simplified)
49
+
50
+ gdf = download_gpkg(metadata)
51
+
52
+ if code_intermadiate == "all":
53
+ return gdf
54
+
55
+ for col in ["abbrev_state", "code_state", "code_intermediate"]:
56
+ if code_intermadiate in gdf[col].unique():
57
+ return gdf[gdf[col] == code_intermadiate]
58
+ else:
59
+ raise ValueError(
60
+ f"Invalid value to argumet `code_intermadiate`: {code_intermadiate}"
61
+ )
@@ -0,0 +1,78 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_meso_region(code_meso="all", year=2010, simplified=True, verbose=False):
5
+ """Download shape files of meso region as sf objects. Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
6
+
7
+ Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
8
+
9
+ Parameters
10
+ ----------
11
+ code_meso: int or string, by default 'all'
12
+ The 4-digit code of a meso region. If the two-digit code or a two-letter uppercase abbreviation of
13
+ a state is passed, (e.g. 33 or "RJ") the function will load all meso regions of that state.
14
+ If code_meso="all", all meso regions of the country are loaded.
15
+ year : int, optional
16
+ Year of the data, by default 2010
17
+ simplified: boolean, by default True
18
+ Data 'type', indicating whether the function returns the 'original' dataset
19
+ with high resolution or a dataset with 'simplified' borders (Default)
20
+ verbose : bool, optional
21
+ by default False
22
+
23
+ Returns
24
+ -------
25
+ gpd.GeoDataFrame
26
+ Metadata and geopackage of selected states
27
+
28
+ Raises
29
+ ------
30
+ Exception
31
+ If parameters are not found or not well defined
32
+
33
+ Example
34
+ -------
35
+ >>> from cursed_geobr import read_meso_region
36
+
37
+ # Read specific meso region at a given year
38
+ >>> df = read_meso_region(code_meso=3301, year=2018)
39
+
40
+ # Read all meso regions of a state at a given year
41
+ >>> df = read_meso_region(code_meso=12, year=2017)
42
+ >>> df = read_meso_region(code_meso="AM", year=2000)
43
+
44
+ # Read all meso regions of the country at a given year
45
+ >>> df = read_meso_region(code_meso="all", year=2010)
46
+ """
47
+
48
+ metadata = select_metadata("meso_region", year=year, simplified=simplified)
49
+
50
+ if code_meso == "all":
51
+
52
+ if verbose:
53
+ print("Loading data for the whole country. This might take a few minutes.")
54
+
55
+ return download_gpkg(metadata)
56
+
57
+ metadata = metadata[
58
+ metadata[["code", "code_abbrev"]].apply(
59
+ lambda x: str(code_meso)[:2] in str(x["code"])
60
+ or str(code_meso)[:2] # if number e.g. 12
61
+ in str(x["code_abbrev"]), # if UF e.g. RO
62
+ 1,
63
+ )
64
+ ]
65
+
66
+ if not len(metadata):
67
+ raise Exception("Invalid Value to argument code_meso.")
68
+
69
+ gdf = download_gpkg(metadata)
70
+
71
+ if len(str(code_meso)) == 2:
72
+ return gdf
73
+
74
+ elif code_meso in gdf["code_meso"].tolist():
75
+ return gdf.query(f"code_meso == {code_meso}")
76
+
77
+ else:
78
+ raise Exception("Invalid Value to argument code_meso.")
@@ -0,0 +1,44 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_metro_area(year=2018, simplified=True, verbose=False):
5
+ """ Download shape files of official metropolitan areas in Brazil as an sf object.
6
+
7
+ The function returns the shapes of municipalities grouped by their respective metro areas.
8
+ Metropolitan areas are created by each state in Brazil. The data set includes the municipalities that belong to
9
+ all metropolitan areas in the country according to state legislation in each year. Orignal data were generated
10
+ by Institute of Geography. Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674).
11
+
12
+ Parameters
13
+ ----------
14
+ year : int, optional
15
+ Year of the data, by default 2018
16
+ simplified: boolean, by default True
17
+ Data 'type', indicating whether the function returns the 'original' dataset
18
+ with high resolution or a dataset with 'simplified' borders (Default)
19
+ verbose : bool, optional
20
+ by default False
21
+
22
+ Returns
23
+ -------
24
+ gpd.GeoDataFrame
25
+ Metadata and geopackage of selected states
26
+
27
+ Raises
28
+ ------
29
+ Exception
30
+ If parameters are not found or not well defined
31
+
32
+ Example
33
+ -------
34
+ >>> from cursed_geobr import read_metro_area
35
+
36
+ # Read specific state at a given year
37
+ >>> df = read_metro_area(year=2018)
38
+ """
39
+
40
+ metadata = select_metadata("metropolitan_area", year=year, simplified=simplified)
41
+
42
+ gdf = download_gpkg(metadata)
43
+
44
+ return gdf
@@ -0,0 +1,78 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_micro_region(code_micro="all", year=2010, simplified=True, verbose=False):
5
+ """Download shape files of micro region as sf objects
6
+
7
+ Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
8
+
9
+ Parameters
10
+ ----------
11
+ code_micro:
12
+ 5-digit code of a micro region. If the two-digit code or a two-letter uppercase abbreviation of
13
+ a state is passed, (e.g. 33 or "RJ") the function will load all micro regions of that state.
14
+ If code_micro="all", all micro regions of the country are loaded.
15
+ year : int, optional
16
+ Year of the data, by default 2010
17
+ simplified: boolean, by default True
18
+ Data 'type', indicating whether the function returns the 'original' dataset
19
+ with high resolution or a dataset with 'simplified' borders (Default)
20
+ verbose : bool, optional
21
+ by default False
22
+
23
+ Returns
24
+ -------
25
+ gpd.GeoDataFrame
26
+ Metadata and geopackage of selected states
27
+
28
+ Raises
29
+ ------
30
+ Exception
31
+ If parameters are not found or not well defined
32
+
33
+ Example
34
+ -------
35
+ >>> from cursed_geobr import read_micro_region
36
+
37
+ # Read specific meso region at a given year
38
+ >>> df = read_micro_region(code_micro=11008, year=2018)
39
+
40
+ # Read all meso regions of a state at a given year
41
+ >>> df = read_micro_region(code_micro=12, year=2017)
42
+ >>> df = read_micro_region(code_micro="AM", year=2000)
43
+
44
+ # Read all meso regions of the country at a given year
45
+ >>> df = read_micro_region(code_micro="all", year=2010)
46
+ """
47
+
48
+ metadata = select_metadata("micro_region", year=year, simplified=simplified)
49
+
50
+ if code_micro == "all":
51
+
52
+ if verbose:
53
+ print("Loading data for the whole country. This might take a few minutes.")
54
+
55
+ return download_gpkg(metadata)
56
+
57
+ metadata = metadata[
58
+ metadata[["code", "code_abbrev"]].apply(
59
+ lambda x: str(code_micro)[:2] in str(x["code"])
60
+ or str(code_micro)[:2] # if number e.g. 12
61
+ in str(x["code_abbrev"]), # if UF e.g. RO
62
+ 1,
63
+ )
64
+ ]
65
+
66
+ if not len(metadata):
67
+ raise Exception("Invalid Value to argument code_micro.")
68
+
69
+ gdf = download_gpkg(metadata)
70
+
71
+ if len(str(code_micro)) == 2:
72
+ return gdf
73
+
74
+ elif code_micro in gdf["code_micro"].tolist():
75
+ return gdf.query(f"code_micro == {code_micro}")
76
+
77
+ else:
78
+ raise Exception("Invalid Value to argument code_micro.")
@@ -0,0 +1,76 @@
1
+ import geopandas as gpd
2
+ import tempfile
3
+ import os
4
+ import requests
5
+ from zipfile import ZipFile
6
+ from io import BytesIO
7
+
8
+ def read_mining_processes(simplified=False):
9
+ """Download official mining process data from ANM (National Mining Agency).
10
+
11
+ This function downloads and processes mining permit data from Brazil's National Mining Agency (ANM).
12
+ The data includes all mining processes such as research permits, mining concessions, etc.
13
+ Original source: SIGMINE/ANM
14
+
15
+ Parameters
16
+ ----------
17
+ simplified : boolean, by default True
18
+ If True, returns a simplified version of the dataset with fewer columns
19
+
20
+ Returns
21
+ -------
22
+ gpd.GeoDataFrame
23
+ Geodataframe with mining process data
24
+
25
+ Example
26
+ -------
27
+ >>> from cursed_geobr import read_mining_processes
28
+
29
+ # Read mining processes data
30
+ >>> mining = read_mining_processes()
31
+ """
32
+
33
+ url = "https://app.anm.gov.br/dadosabertos/SIGMINE/PROCESSOS_MINERARIOS/BRASIL.zip"
34
+
35
+ try:
36
+ # Download the zip file with SSL verification disabled (use with caution)
37
+ response = requests.get(url, verify=False)
38
+ if response.status_code != 200:
39
+ raise Exception("Failed to download data from ANM")
40
+
41
+ # Suppress SSL verification warnings
42
+ import warnings
43
+ warnings.filterwarnings('ignore', message='Unverified HTTPS request')
44
+
45
+ # Create a temporary directory
46
+ with tempfile.TemporaryDirectory() as temp_dir:
47
+ # Extract zip content
48
+ with ZipFile(BytesIO(response.content)) as zip_ref:
49
+ zip_ref.extractall(temp_dir)
50
+
51
+ # Find the shapefile
52
+ shp_files = [f for f in os.listdir(temp_dir) if f.endswith('.shp')]
53
+ if not shp_files:
54
+ raise Exception("No shapefile found in the downloaded data")
55
+
56
+ # Read the shapefile
57
+ gdf = gpd.read_file(os.path.join(temp_dir, shp_files[0]))
58
+
59
+ if simplified:
60
+ # Keep only the most relevant columns
61
+ columns_to_keep = [
62
+ 'geometry',
63
+ 'PROCESSO',
64
+ 'FASE',
65
+ 'NOME',
66
+ 'SUBS',
67
+ 'USO',
68
+ 'UF',
69
+ 'AREA_HA'
70
+ ]
71
+ gdf = gdf[columns_to_keep]
72
+
73
+ except Exception as e:
74
+ raise Exception(f"Error downloading mining processes data: {str(e)}")
75
+
76
+ return gdf
@@ -0,0 +1,41 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_municipal_seat(year=2010, verbose=False):
5
+ """ Download official data of municipal seats (sede dos municipios) in Brazil as an sf object.
6
+
7
+ This function reads the official data on the municipal seats (sede dos municipios) of Brazil.
8
+ The data brings the spatial coordinates (lat lon) of of municipal seats for various years
9
+ between 1872 and 2010. Orignal data were generated by Brazilian Institute of Geography
10
+ and Statistics (IBGE).
11
+
12
+ Parameters
13
+ ----------
14
+ year : int, optional
15
+ Year of the data, by default 2010
16
+ verbose : bool, optional
17
+ by default False
18
+
19
+ Returns
20
+ -------
21
+ gpd.GeoDataFrame
22
+ Metadata and geopackage of selected states
23
+
24
+ Raises
25
+ ------
26
+ Exception
27
+ If parameters are not found or not well defined
28
+
29
+ Example
30
+ -------
31
+ >>> from cursed_geobr import read_municipal_seat
32
+
33
+ # Read specific state at a given year
34
+ >>> df = read_municipal_seat(year=2010)
35
+ """
36
+
37
+ metadata = select_metadata("municipal_seat", year=year)
38
+
39
+ gdf = download_gpkg(metadata)
40
+
41
+ return gdf
@@ -0,0 +1,83 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_municipality(code_muni="all", year=2010, simplified=True, verbose=False):
5
+ """Download shape files of Brazilian municipalities as sf objects.
6
+
7
+ Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
8
+
9
+ Parameters
10
+ ----------
11
+ code_muni:
12
+ The 7-digit code of a municipality. If the two-digit code or a two-letter uppercase abbreviation of
13
+ a state is passed, (e.g. 33 or "RJ") the function will load all municipalities of that state.
14
+ If code_muni="all", all municipalities of the country will be loaded.
15
+ year : int, optional
16
+ Year of the data, by default 2010
17
+ simplified: boolean, by default True
18
+ Data 'type', indicating whether the function returns the 'original' dataset
19
+ with high resolution or a dataset with 'simplified' borders (Default)
20
+ verbose : bool, optional
21
+ by default False
22
+
23
+ Returns
24
+ -------
25
+ gpd.GeoDataFrame
26
+ Metadata and geopackage of selected states
27
+
28
+ Raises
29
+ ------
30
+ Exception
31
+ If parameters are not found or not well defined
32
+
33
+ Example
34
+ -------
35
+ >>> from cursed_geobr import read_municipality
36
+
37
+ # Read specific meso region at a given year
38
+ >>> df = read_municipality(code_muni=1200179, year=2018)
39
+
40
+ # Read all meso regions of a state at a given year
41
+ >>> df = read_municipality(code_muni=12, year=2017)
42
+ >>> df = read_municipality(code_muni="AM", year=2000)
43
+
44
+ # Read all meso regions of the country at a given year
45
+ >>> df = read_municipality(code_muni="all", year=2010)
46
+ """
47
+
48
+ metadata = select_metadata("municipality", year=year, simplified=simplified)
49
+
50
+ if year < 1992:
51
+
52
+ return download_gpkg(metadata)
53
+
54
+ if code_muni == "all":
55
+
56
+ if verbose:
57
+ print("Loading data for the whole country. This might take a few minutes.")
58
+
59
+ return download_gpkg(metadata)
60
+
61
+ metadata = metadata[
62
+ metadata[["code", "code_abbrev"]].apply(
63
+ lambda x: str(code_muni)[:2] in str(x["code"])
64
+ or str(code_muni)[:2] # if number e.g. 12
65
+ in str(x["code_abbrev"]), # if UF e.g. RO
66
+ 1,
67
+ )
68
+ ]
69
+
70
+ if not len(metadata):
71
+ raise Exception("Invalid Value to argument code_muni.")
72
+
73
+ gdf = download_gpkg(metadata)
74
+
75
+ if len(str(code_muni)) == 2:
76
+ return gdf
77
+
78
+ elif code_muni in gdf["code_muni"].tolist():
79
+ return gdf.query(f"code_muni == {code_muni}")
80
+
81
+ else:
82
+ raise Exception("Invalid Value to argument code_muni.")
83
+ return gdf
@@ -0,0 +1,39 @@
1
+ from cursed_geobr.utils import select_metadata, download_gpkg
2
+
3
+
4
+ def read_neighborhood(year=2010, simplified=True, verbose=False):
5
+ """ Download neighborhood limits of Brazilian municipalities as a geopandas geodataframe object
6
+
7
+ Parameters
8
+ ----------
9
+ year : int, optional
10
+ Year of the data, by default 2010
11
+ simplified: boolean, by default True
12
+ Data 'type', indicating whether the function returns the 'original' dataset
13
+ with high resolution or a dataset with 'simplified' borders (Default)
14
+ verbose : bool, optional
15
+ by default False
16
+
17
+ Returns
18
+ -------
19
+ gpd.GeoDataFrame
20
+ Metadata and geopackage of selected states
21
+
22
+ Raises
23
+ ------
24
+ Exception
25
+ If parameters are not found or not well defined
26
+
27
+ Example
28
+ -------
29
+ >>> from cursed_geobr import read_neighborhood
30
+
31
+ # Read specific neighborhoods at a given year
32
+ >>> df = read_neighborhood(year=2010)
33
+ """
34
+
35
+ metadata = select_metadata("neighborhood", year=year, simplified=simplified)
36
+
37
+ gdf = download_gpkg(metadata)
38
+
39
+ return gdf