tunned-geobr 0.1.2__py3-none-any.whl → 0.2.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.
- tunned_geobr/__init__.py +34 -2
- tunned_geobr/read_apcb_amazon.py +78 -0
- tunned_geobr/read_apcb_caatinga.py +78 -0
- tunned_geobr/read_apcb_cerrado_pantanal.py +78 -0
- tunned_geobr/read_apcb_mata_atlantica.py +78 -0
- tunned_geobr/read_apcb_pampa.py +78 -0
- tunned_geobr/read_apcb_zcm.py +78 -0
- tunned_geobr/read_archaeological_sites.py +94 -0
- tunned_geobr/read_atlantic_forest_law_limits.py +74 -0
- tunned_geobr/read_baze_sites.py +155 -0
- tunned_geobr/read_biosphere_reserves.py +85 -0
- tunned_geobr/read_cave_potential.py +79 -0
- tunned_geobr/read_census_tract_2022.py +101 -0
- tunned_geobr/read_ebas.py +80 -0
- tunned_geobr/read_federal_highways.py +79 -0
- tunned_geobr/read_fossil_occurrences.py +94 -0
- tunned_geobr/read_geographic_regions.py +88 -0
- tunned_geobr/read_heliports.py +81 -0
- tunned_geobr/read_municipality_direct.py +127 -0
- tunned_geobr/read_natural_caves.py +83 -0
- tunned_geobr/read_neighborhoods_2022.py +99 -0
- tunned_geobr/read_pan_strategic_areas.py +89 -0
- tunned_geobr/read_ports.py +80 -0
- tunned_geobr/read_private_aerodromes.py +81 -0
- tunned_geobr/read_public_aerodromes.py +81 -0
- tunned_geobr/read_quilombola_areas.py +85 -0
- tunned_geobr/read_quilombola_areas_temp.py +103 -0
- tunned_geobr/read_railways.py +80 -0
- tunned_geobr/read_rppn.py +107 -0
- tunned_geobr/read_sigef_properties.py +83 -0
- tunned_geobr/read_snci_properties.py +83 -0
- tunned_geobr/read_state_direct.py +103 -0
- tunned_geobr/read_state_highways.py +79 -0
- tunned_geobr/read_transmission_lines_ons.py +87 -0
- tunned_geobr/read_vegetation.py +84 -0
- tunned_geobr/read_water_bodies_ana.py +87 -0
- tunned_geobr/read_waterways.py +80 -0
- {tunned_geobr-0.1.2.dist-info → tunned_geobr-0.2.0.dist-info}/METADATA +35 -3
- tunned_geobr-0.2.0.dist-info/RECORD +82 -0
- tunned_geobr-0.1.2.dist-info/RECORD +0 -46
- {tunned_geobr-0.1.2.dist-info → tunned_geobr-0.2.0.dist-info}/WHEEL +0 -0
- {tunned_geobr-0.1.2.dist-info → tunned_geobr-0.2.0.dist-info}/entry_points.txt +0 -0
- {tunned_geobr-0.1.2.dist-info → tunned_geobr-0.2.0.dist-info}/licenses/LICENSE.txt +0 -0
tunned_geobr/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .
|
1
|
+
from .read_state_direct import read_state
|
2
2
|
from .read_amazon import read_amazon
|
3
3
|
from .read_biomes import read_biomes
|
4
4
|
from .read_country import read_country
|
@@ -16,7 +16,7 @@ from .list_geobr import list_geobr
|
|
16
16
|
from .read_census_tract import read_census_tract
|
17
17
|
from .read_meso_region import read_meso_region
|
18
18
|
from .read_micro_region import read_micro_region
|
19
|
-
from .
|
19
|
+
from .read_municipality_direct import read_municipality
|
20
20
|
from .read_weighting_area import read_weighting_area
|
21
21
|
from .read_neighborhood import read_neighborhood
|
22
22
|
from .read_health_region import read_health_region
|
@@ -36,3 +36,35 @@ from .read_climate_aggressiveness import read_climate_aggressiveness
|
|
36
36
|
from .read_amazon_ibas import read_amazon_ibas
|
37
37
|
from .read_atlantic_forest_ibas import read_atlantic_forest_ibas
|
38
38
|
from .read_settlements import read_settlements
|
39
|
+
from .read_apcb_amazon import read_apcb_amazon
|
40
|
+
from .read_apcb_caatinga import read_apcb_caatinga
|
41
|
+
from .read_apcb_cerrado_pantanal import read_apcb_cerrado_pantanal
|
42
|
+
from .read_apcb_mata_atlantica import read_apcb_mata_atlantica
|
43
|
+
from .read_apcb_pampa import read_apcb_pampa
|
44
|
+
from .read_apcb_zcm import read_apcb_zcm
|
45
|
+
from .read_natural_caves import read_natural_caves
|
46
|
+
from .read_ports import read_ports
|
47
|
+
from .read_public_aerodromes import read_public_aerodromes
|
48
|
+
from .read_private_aerodromes import read_private_aerodromes
|
49
|
+
from .read_state_highways import read_state_highways
|
50
|
+
from .read_federal_highways import read_federal_highways
|
51
|
+
from .read_railways import read_railways
|
52
|
+
from .read_waterways import read_waterways
|
53
|
+
from .read_heliports import read_heliports
|
54
|
+
from .read_snci_properties import read_snci_properties
|
55
|
+
from .read_sigef_properties import read_sigef_properties
|
56
|
+
from .read_atlantic_forest_law_limits import read_atlantic_forest_law_limits
|
57
|
+
from .read_fossil_occurrences import read_fossil_occurrences
|
58
|
+
from .read_cave_potential import read_cave_potential
|
59
|
+
from .read_rppn import read_rppn
|
60
|
+
from .read_archaeological_sites import read_archaeological_sites
|
61
|
+
from .read_ebas import read_ebas
|
62
|
+
from .read_vegetation import read_vegetation
|
63
|
+
from .read_transmission_lines_ons import read_transmission_lines_ons
|
64
|
+
from .read_water_bodies_ana import read_water_bodies_ana
|
65
|
+
from .read_pan_strategic_areas import read_pan_strategic_areas
|
66
|
+
from .read_geographic_regions import read_geographic_regions
|
67
|
+
from .read_biosphere_reserves import read_biosphere_reserves
|
68
|
+
from .read_census_tract_2022 import read_census_tract_2022
|
69
|
+
from .read_neighborhoods_2022 import read_neighborhoods_2022
|
70
|
+
from .read_baze_sites import read_baze_sites
|
@@ -0,0 +1,78 @@
|
|
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_apcb_amazon(simplified=False):
|
9
|
+
"""Download Priority Areas for Biodiversity Conservation (APCB) data for the Amazon region.
|
10
|
+
|
11
|
+
This function downloads and processes APCB data from the Ministry of Environment (MMA).
|
12
|
+
The data includes priority areas for biodiversity conservation in the Amazon region.
|
13
|
+
Original source: Ministério do Meio Ambiente (MMA)
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Amazon APCB data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_apcb_amazonia
|
28
|
+
|
29
|
+
# Read Amazon APCB data
|
30
|
+
>>> apcb = read_apcb_amazonia()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://www.gov.br/mma/pt-br/assuntos/biodiversidade-e-biomas/biomas-e-ecossistemas/conservacao-1/areas-prioritarias/arquivos/amazonia.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = []
|
49
|
+
for root, dirs, files in os.walk(temp_dir):
|
50
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
51
|
+
|
52
|
+
if not shp_files:
|
53
|
+
raise Exception("No shapefile found in the downloaded data")
|
54
|
+
|
55
|
+
# Read the shapefile
|
56
|
+
gdf = gpd.read_file(shp_files[0])
|
57
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
58
|
+
|
59
|
+
if simplified:
|
60
|
+
# Keep only the most relevant columns
|
61
|
+
columns_to_keep = [
|
62
|
+
'geometry',
|
63
|
+
'Nome', # Area name
|
64
|
+
'Importanci', # Importance
|
65
|
+
'Prioridade', # Priority
|
66
|
+
'Area_km2', # Area in km²
|
67
|
+
'Oportunida', # Opportunity
|
68
|
+
'Ameaca' # Threats
|
69
|
+
]
|
70
|
+
|
71
|
+
# Filter columns that actually exist in the dataset
|
72
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
73
|
+
gdf = gdf[existing_columns]
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
raise Exception(f"Error downloading Amazon APCB data: {str(e)}")
|
77
|
+
|
78
|
+
return gdf
|
@@ -0,0 +1,78 @@
|
|
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_apcb_caatinga(simplified=False):
|
9
|
+
"""Download Priority Areas for Biodiversity Conservation (APCB) data for the Caatinga region.
|
10
|
+
|
11
|
+
This function downloads and processes APCB data from the Ministry of Environment (MMA).
|
12
|
+
The data includes priority areas for biodiversity conservation in the Caatinga region.
|
13
|
+
Original source: Ministério do Meio Ambiente (MMA)
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Caatinga APCB data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_apcb_caatinga
|
28
|
+
|
29
|
+
# Read Caatinga APCB data
|
30
|
+
>>> apcb = read_apcb_caatinga()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://www.gov.br/mma/pt-br/assuntos/biodiversidade-e-biomas/biomas-e-ecossistemas/conservacao-1/areas-prioritarias/arquivos/caatinga.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = []
|
49
|
+
for root, dirs, files in os.walk(temp_dir):
|
50
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
51
|
+
|
52
|
+
if not shp_files:
|
53
|
+
raise Exception("No shapefile found in the downloaded data")
|
54
|
+
|
55
|
+
# Read the shapefile
|
56
|
+
gdf = gpd.read_file(shp_files[0])
|
57
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
58
|
+
|
59
|
+
if simplified:
|
60
|
+
# Keep only the most relevant columns
|
61
|
+
columns_to_keep = [
|
62
|
+
'geometry',
|
63
|
+
'Nome', # Area name
|
64
|
+
'Importanci', # Importance
|
65
|
+
'Prioridade', # Priority
|
66
|
+
'Area_km2', # Area in km²
|
67
|
+
'Oportunida', # Opportunity
|
68
|
+
'Ameaca' # Threats
|
69
|
+
]
|
70
|
+
|
71
|
+
# Filter columns that actually exist in the dataset
|
72
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
73
|
+
gdf = gdf[existing_columns]
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
raise Exception(f"Error downloading Caatinga APCB data: {str(e)}")
|
77
|
+
|
78
|
+
return gdf
|
@@ -0,0 +1,78 @@
|
|
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_apcb_cerrado_pantanal(simplified=False):
|
9
|
+
"""Download Priority Areas for Biodiversity Conservation (APCB) data for the Cerrado and Pantanal regions.
|
10
|
+
|
11
|
+
This function downloads and processes APCB data from the Ministry of Environment (MMA).
|
12
|
+
The data includes priority areas for biodiversity conservation in the Cerrado and Pantanal regions.
|
13
|
+
Original source: Ministério do Meio Ambiente (MMA)
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Cerrado and Pantanal APCB data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_apcb_cerrado_pantanal
|
28
|
+
|
29
|
+
# Read Cerrado and Pantanal APCB data
|
30
|
+
>>> apcb = read_apcb_cerrado_pantanal()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://www.gov.br/mma/pt-br/assuntos/biodiversidade-e-biomas/biomas-e-ecossistemas/conservacao-1/areas-prioritarias/arquivos/cerrado_pantanal.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = []
|
49
|
+
for root, dirs, files in os.walk(temp_dir):
|
50
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
51
|
+
|
52
|
+
if not shp_files:
|
53
|
+
raise Exception("No shapefile found in the downloaded data")
|
54
|
+
|
55
|
+
# Read the shapefile
|
56
|
+
gdf = gpd.read_file(shp_files[0])
|
57
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
58
|
+
|
59
|
+
if simplified:
|
60
|
+
# Keep only the most relevant columns
|
61
|
+
columns_to_keep = [
|
62
|
+
'geometry',
|
63
|
+
'Nome', # Area name
|
64
|
+
'Importanci', # Importance
|
65
|
+
'Prioridade', # Priority
|
66
|
+
'Area_km2', # Area in km²
|
67
|
+
'Oportunida', # Opportunity
|
68
|
+
'Ameaca' # Threats
|
69
|
+
]
|
70
|
+
|
71
|
+
# Filter columns that actually exist in the dataset
|
72
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
73
|
+
gdf = gdf[existing_columns]
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
raise Exception(f"Error downloading Cerrado and Pantanal APCB data: {str(e)}")
|
77
|
+
|
78
|
+
return gdf
|
@@ -0,0 +1,78 @@
|
|
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_apcb_mata_atlantica(simplified=False):
|
9
|
+
"""Download Priority Areas for Biodiversity Conservation (APCB) data for the Atlantic Forest region.
|
10
|
+
|
11
|
+
This function downloads and processes APCB data from the Ministry of Environment (MMA).
|
12
|
+
The data includes priority areas for biodiversity conservation in the Atlantic Forest region.
|
13
|
+
Original source: Ministério do Meio Ambiente (MMA)
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Atlantic Forest APCB data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_apcb_mata_atlantica
|
28
|
+
|
29
|
+
# Read Atlantic Forest APCB data
|
30
|
+
>>> apcb = read_apcb_mata_atlantica()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://www.gov.br/mma/pt-br/assuntos/biodiversidade-e-biomas/biomas-e-ecossistemas/conservacao-1/areas-prioritarias/arquivos/mataatlantica.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = []
|
49
|
+
for root, dirs, files in os.walk(temp_dir):
|
50
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
51
|
+
|
52
|
+
if not shp_files:
|
53
|
+
raise Exception("No shapefile found in the downloaded data")
|
54
|
+
|
55
|
+
# Read the shapefile
|
56
|
+
gdf = gpd.read_file(shp_files[0])
|
57
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
58
|
+
|
59
|
+
if simplified:
|
60
|
+
# Keep only the most relevant columns
|
61
|
+
columns_to_keep = [
|
62
|
+
'geometry',
|
63
|
+
'Nome', # Area name
|
64
|
+
'Importanci', # Importance
|
65
|
+
'Prioridade', # Priority
|
66
|
+
'Area_km2', # Area in km²
|
67
|
+
'Oportunida', # Opportunity
|
68
|
+
'Ameaca' # Threats
|
69
|
+
]
|
70
|
+
|
71
|
+
# Filter columns that actually exist in the dataset
|
72
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
73
|
+
gdf = gdf[existing_columns]
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
raise Exception(f"Error downloading Atlantic Forest APCB data: {str(e)}")
|
77
|
+
|
78
|
+
return gdf
|
@@ -0,0 +1,78 @@
|
|
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_apcb_pampa(simplified=False):
|
9
|
+
"""Download Priority Areas for Biodiversity Conservation (APCB) data for the Pampa region.
|
10
|
+
|
11
|
+
This function downloads and processes APCB data from the Ministry of Environment (MMA).
|
12
|
+
The data includes priority areas for biodiversity conservation in the Pampa region.
|
13
|
+
Original source: Ministério do Meio Ambiente (MMA)
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Pampa APCB data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_apcb_pampa
|
28
|
+
|
29
|
+
# Read Pampa APCB data
|
30
|
+
>>> apcb = read_apcb_pampa()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://www.gov.br/mma/pt-br/assuntos/biodiversidade-e-biomas/biomas-e-ecossistemas/conservacao-1/areas-prioritarias/arquivos/pampa.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = []
|
49
|
+
for root, dirs, files in os.walk(temp_dir):
|
50
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
51
|
+
|
52
|
+
if not shp_files:
|
53
|
+
raise Exception("No shapefile found in the downloaded data")
|
54
|
+
|
55
|
+
# Read the shapefile
|
56
|
+
gdf = gpd.read_file(shp_files[0])
|
57
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
58
|
+
|
59
|
+
if simplified:
|
60
|
+
# Keep only the most relevant columns
|
61
|
+
columns_to_keep = [
|
62
|
+
'geometry',
|
63
|
+
'Nome', # Area name
|
64
|
+
'Importanci', # Importance
|
65
|
+
'Prioridade', # Priority
|
66
|
+
'Area_km2', # Area in km²
|
67
|
+
'Oportunida', # Opportunity
|
68
|
+
'Ameaca' # Threats
|
69
|
+
]
|
70
|
+
|
71
|
+
# Filter columns that actually exist in the dataset
|
72
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
73
|
+
gdf = gdf[existing_columns]
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
raise Exception(f"Error downloading Pampa APCB data: {str(e)}")
|
77
|
+
|
78
|
+
return gdf
|
@@ -0,0 +1,78 @@
|
|
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_apcb_zcm(simplified=False):
|
9
|
+
"""Download Priority Areas for Biodiversity Conservation (APCB) data for the Coastal and Marine Zone.
|
10
|
+
|
11
|
+
This function downloads and processes APCB data from the Ministry of Environment (MMA).
|
12
|
+
The data includes priority areas for biodiversity conservation in the Coastal and Marine Zone (ZCM).
|
13
|
+
Original source: Ministério do Meio Ambiente (MMA)
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Coastal and Marine Zone APCB data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_apcb_zcm
|
28
|
+
|
29
|
+
# Read Coastal and Marine Zone APCB data
|
30
|
+
>>> apcb = read_apcb_zcm()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://www.gov.br/mma/pt-br/assuntos/biodiversidade-e-biomas/biomas-e-ecossistemas/conservacao-1/areas-prioritarias/arquivos/zcm.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = []
|
49
|
+
for root, dirs, files in os.walk(temp_dir):
|
50
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
51
|
+
|
52
|
+
if not shp_files:
|
53
|
+
raise Exception("No shapefile found in the downloaded data")
|
54
|
+
|
55
|
+
# Read the shapefile
|
56
|
+
gdf = gpd.read_file(shp_files[0])
|
57
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
58
|
+
|
59
|
+
if simplified:
|
60
|
+
# Keep only the most relevant columns
|
61
|
+
columns_to_keep = [
|
62
|
+
'geometry',
|
63
|
+
'Nome', # Area name
|
64
|
+
'Importanci', # Importance
|
65
|
+
'Prioridade', # Priority
|
66
|
+
'Area_km2', # Area in km²
|
67
|
+
'Oportunida', # Opportunity
|
68
|
+
'Ameaca' # Threats
|
69
|
+
]
|
70
|
+
|
71
|
+
# Filter columns that actually exist in the dataset
|
72
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
73
|
+
gdf = gdf[existing_columns]
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
raise Exception(f"Error downloading Coastal and Marine Zone APCB data: {str(e)}")
|
77
|
+
|
78
|
+
return gdf
|
@@ -0,0 +1,94 @@
|
|
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_archaeological_sites(simplified=False):
|
9
|
+
"""Download Archaeological Sites data from IPHAN.
|
10
|
+
|
11
|
+
This function downloads and processes data about archaeological sites in Brazil
|
12
|
+
from IPHAN (Instituto do Patrimônio Histórico e Artístico Nacional). The data
|
13
|
+
includes location and basic information about registered archaeological sites.
|
14
|
+
Original source: IPHAN - Instituto do Patrimônio Histórico e Artístico Nacional
|
15
|
+
|
16
|
+
Parameters
|
17
|
+
----------
|
18
|
+
simplified : boolean, by default False
|
19
|
+
If True, returns a simplified version of the dataset with fewer columns
|
20
|
+
|
21
|
+
Returns
|
22
|
+
-------
|
23
|
+
gpd.GeoDataFrame
|
24
|
+
Geodataframe with archaeological sites data
|
25
|
+
Columns:
|
26
|
+
- geometry: Site location
|
27
|
+
- nome: Site name
|
28
|
+
- municipio: Municipality
|
29
|
+
- uf: State
|
30
|
+
- tipo: Site type
|
31
|
+
- exposicao: Exposure type
|
32
|
+
- relevancia: Relevance
|
33
|
+
- preservacao: Preservation state
|
34
|
+
- datacao: Dating
|
35
|
+
- artefatos: Artifacts found
|
36
|
+
- fonte: Data source
|
37
|
+
|
38
|
+
Example
|
39
|
+
-------
|
40
|
+
>>> from tunned_geobr import read_archaeological_sites
|
41
|
+
|
42
|
+
# Read archaeological sites data
|
43
|
+
>>> sites = read_archaeological_sites()
|
44
|
+
"""
|
45
|
+
|
46
|
+
url = "http://portal.iphan.gov.br/geoserver/SICG/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=SICG:sitios&maxFeatures=50000&outputFormat=SHAPE-ZIP"
|
47
|
+
|
48
|
+
try:
|
49
|
+
# Download the zip file
|
50
|
+
response = requests.get(url)
|
51
|
+
if response.status_code != 200:
|
52
|
+
raise Exception("Failed to download data from IPHAN")
|
53
|
+
|
54
|
+
# Create a temporary directory
|
55
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
56
|
+
# Extract the zip file
|
57
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
58
|
+
zip_ref.extractall(temp_dir)
|
59
|
+
|
60
|
+
# Find the shapefile
|
61
|
+
shp_files = [f for f in os.listdir(temp_dir) if f.endswith('.shp')]
|
62
|
+
if not shp_files:
|
63
|
+
raise Exception("No shapefile found in the downloaded data")
|
64
|
+
|
65
|
+
# Read the shapefile
|
66
|
+
gdf = gpd.read_file(os.path.join(temp_dir, shp_files[0]))
|
67
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
68
|
+
|
69
|
+
# Print columns for debugging
|
70
|
+
print("Available columns:", gdf.columns)
|
71
|
+
|
72
|
+
if simplified:
|
73
|
+
# Keep only the most relevant columns
|
74
|
+
columns_to_keep = [
|
75
|
+
'geometry',
|
76
|
+
'nome', # Site name
|
77
|
+
'municipio', # Municipality
|
78
|
+
'uf', # State
|
79
|
+
'tipo', # Site type
|
80
|
+
'relevancia', # Relevance
|
81
|
+
'preservacao' # Preservation state
|
82
|
+
]
|
83
|
+
|
84
|
+
# Filter columns that actually exist in the dataset
|
85
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
86
|
+
gdf = gdf[existing_columns]
|
87
|
+
|
88
|
+
except Exception as e:
|
89
|
+
raise Exception(f"Error downloading archaeological sites data: {str(e)}")
|
90
|
+
|
91
|
+
return gdf
|
92
|
+
|
93
|
+
if __name__ == '__main__':
|
94
|
+
read_archaeological_sites()
|
@@ -0,0 +1,74 @@
|
|
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_atlantic_forest_law_limits(simplified=False):
|
9
|
+
"""Download Atlantic Forest Legal Limits data from MMA/IBGE.
|
10
|
+
|
11
|
+
This function downloads and processes data about the Atlantic Forest legal limits
|
12
|
+
as defined by Law 11.428/2006. The data is provided by IBGE and MMA (Ministry of Environment).
|
13
|
+
Original source: MMA - Ministério do Meio Ambiente
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
simplified : boolean, by default False
|
18
|
+
If True, returns a simplified version of the dataset with fewer columns
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
gpd.GeoDataFrame
|
23
|
+
Geodataframe with Atlantic Forest legal limits data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_atlantic_forest_law_limits
|
28
|
+
|
29
|
+
# Read Atlantic Forest legal limits data
|
30
|
+
>>> limits = read_atlantic_forest_law_limits()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "http://antigo.mma.gov.br/estruturas/202/_arquivos/shape_mata_atlantica_ibge_5milhoes_policonica_sirgas2000shp_202.zip"
|
34
|
+
|
35
|
+
try:
|
36
|
+
# Download the zip file
|
37
|
+
response = requests.get(url)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to download data from MMA")
|
40
|
+
|
41
|
+
# Create a temporary directory
|
42
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
43
|
+
# Extract the zip file
|
44
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
45
|
+
zip_ref.extractall(temp_dir)
|
46
|
+
|
47
|
+
# Find the shapefile
|
48
|
+
shp_files = [f for f in os.listdir(temp_dir) if f.endswith('.shp')]
|
49
|
+
if not shp_files:
|
50
|
+
raise Exception("No shapefile found in the downloaded data")
|
51
|
+
|
52
|
+
# Read the shapefile
|
53
|
+
gdf = gpd.read_file(os.path.join(temp_dir, shp_files[0]))
|
54
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
55
|
+
|
56
|
+
if simplified:
|
57
|
+
# Keep only the most relevant columns
|
58
|
+
columns_to_keep = [
|
59
|
+
'geometry',
|
60
|
+
'NM_TEMA', # Theme name
|
61
|
+
'NM_REGIAO', # Region name
|
62
|
+
'AREA_KM2', # Area in km²
|
63
|
+
'LEI', # Law reference
|
64
|
+
'FONTE' # Data source
|
65
|
+
]
|
66
|
+
|
67
|
+
# Filter columns that actually exist in the dataset
|
68
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
69
|
+
gdf = gdf[existing_columns]
|
70
|
+
|
71
|
+
except Exception as e:
|
72
|
+
raise Exception(f"Error downloading Atlantic Forest legal limits data: {str(e)}")
|
73
|
+
|
74
|
+
return gdf
|