tunned-geobr 1.0.4__py3-none-any.whl → 1.0.6__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 +1 -0
- tunned_geobr/list_geobr.py +1 -0
- tunned_geobr/read_climate.py +85 -0
- tunned_geobr/read_exploration_blocks.py +86 -0
- {tunned_geobr-1.0.4.dist-info → tunned_geobr-1.0.6.dist-info}/METADATA +1 -1
- {tunned_geobr-1.0.4.dist-info → tunned_geobr-1.0.6.dist-info}/RECORD +9 -7
- {tunned_geobr-1.0.4.dist-info → tunned_geobr-1.0.6.dist-info}/WHEEL +0 -0
- {tunned_geobr-1.0.4.dist-info → tunned_geobr-1.0.6.dist-info}/entry_points.txt +0 -0
- {tunned_geobr-1.0.4.dist-info → tunned_geobr-1.0.6.dist-info}/licenses/LICENSE.txt +0 -0
tunned_geobr/__init__.py
CHANGED
@@ -127,3 +127,4 @@ from .read_quilombola_areas import read_quilombola_areas
|
|
127
127
|
from .read_icmbio_embargoes import read_icmbio_embargoes
|
128
128
|
from .read_icmbio_infractions import read_icmbio_infractions
|
129
129
|
from .read_ibama_embargoes import read_ibama_embargoes
|
130
|
+
from .read_climate import read_climate
|
tunned_geobr/list_geobr.py
CHANGED
@@ -84,6 +84,7 @@ def list_geobr():
|
|
84
84
|
{"Function": "read_geomorphology", "Geography": "Geomorphology", "Years": "All", "Source": "IBGE"},
|
85
85
|
{"Function": "read_pedology", "Geography": "Pedology", "Years": "All", "Source": "IBGE"},
|
86
86
|
{"Function": "read_climate_aggressiveness", "Geography": "Climate Aggressiveness", "Years": "All", "Source": "IBGE"},
|
87
|
+
{"Function": "read_climate", "Geography": "Climate", "Years": "All", "Source": "IBGE"},
|
87
88
|
|
88
89
|
# Transportation and infrastructure datasets
|
89
90
|
{"Function": "read_public_aerodromes", "Geography": "Public Aerodromes", "Years": "All", "Source": "MapBiomas"},
|
@@ -0,0 +1,85 @@
|
|
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_climate(simplified=False):
|
9
|
+
"""Download Brazilian Climate data from IBGE.
|
10
|
+
|
11
|
+
This function downloads and processes the Brazilian Climate data.
|
12
|
+
from IBGE (Brazilian Institute of Geography and Statistics).
|
13
|
+
Original source: IBGE - Instituto Brasileiro de Geografia e Estatística
|
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 Brazilian climate data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_climate
|
28
|
+
|
29
|
+
# Read climate data
|
30
|
+
>>> climate = read_climate()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://geoftp.ibge.gov.br/informacoes_ambientais/climatologia/vetores/brasil/Clima_5000mil.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 climate data from IBGE")
|
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
|
+
|
58
|
+
# Convert to SIRGAS 2000 (EPSG:4674) if not already
|
59
|
+
if gdf.crs is None:
|
60
|
+
gdf.crs = 4674
|
61
|
+
elif gdf.crs.to_epsg() != 4674:
|
62
|
+
gdf = gdf.to_crs(4674)
|
63
|
+
|
64
|
+
if simplified:
|
65
|
+
# Keep only the most relevant columns
|
66
|
+
# Note: Column names may need adjustment based on actual data
|
67
|
+
columns_to_keep = [
|
68
|
+
'geometry',
|
69
|
+
'NOME', # Vegetation name
|
70
|
+
'TIPO', # Vegetation type
|
71
|
+
'REGIAO', # Region
|
72
|
+
'BIOMA', # Biome
|
73
|
+
'AREA_KM2' # Area in square kilometers
|
74
|
+
]
|
75
|
+
|
76
|
+
# Filter columns that actually exist in the dataset
|
77
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
78
|
+
gdf = gdf[existing_columns]
|
79
|
+
|
80
|
+
except Exception as e:
|
81
|
+
raise Exception(f"Error downloading vegetation data: {str(e)}")
|
82
|
+
return gdf
|
83
|
+
|
84
|
+
if __name__ == '__main__':
|
85
|
+
read_climate()
|
@@ -0,0 +1,86 @@
|
|
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_exploration_blocks(simplified=False):
|
9
|
+
"""Download Brazilian Exploration Blocks data from ANP.
|
10
|
+
|
11
|
+
This function downloads and processes the Brazilian Exploration Blocks data
|
12
|
+
from ANP (National Petroleum Agency).
|
13
|
+
Original source: ANP - Agência Nacional do Petróleo, Gás Natural e Biocombustíveis
|
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 Brazilian exploration blocks data
|
24
|
+
|
25
|
+
Example
|
26
|
+
-------
|
27
|
+
>>> from tunned_geobr import read_exploration_blocks
|
28
|
+
|
29
|
+
# Read exploration blocks data
|
30
|
+
>>> blocks = read_exploration_blocks()
|
31
|
+
"""
|
32
|
+
|
33
|
+
url = "https://gishub.anp.gov.br/geoserver/BD_ANP/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=BD_ANP%3ABLOCOS_EXPLORATORIOS_SIRGAS&maxFeatures=40000&outputFormat=SHAPE-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 exploration blocks data from ANP")
|
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
|
+
|
58
|
+
# Convert to SIRGAS 2000 (EPSG:4674) if not already
|
59
|
+
if gdf.crs is None:
|
60
|
+
gdf.crs = 4674
|
61
|
+
elif gdf.crs.to_epsg() != 4674:
|
62
|
+
gdf = gdf.to_crs(4674)
|
63
|
+
|
64
|
+
if simplified:
|
65
|
+
# Keep only the most relevant columns
|
66
|
+
# Note: Column names based on typical ANP data structure
|
67
|
+
columns_to_keep = [
|
68
|
+
'geometry',
|
69
|
+
'NOME', # Block name
|
70
|
+
'OPERADOR', # Operator
|
71
|
+
'BACIA', # Basin
|
72
|
+
'CONTRATO', # Contract
|
73
|
+
'AREA_KM2' # Area in square kilometers
|
74
|
+
]
|
75
|
+
|
76
|
+
# Filter columns that actually exist in the dataset
|
77
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
78
|
+
gdf = gdf[existing_columns]
|
79
|
+
|
80
|
+
except Exception as e:
|
81
|
+
raise Exception(f"Error downloading exploration blocks data: {str(e)}")
|
82
|
+
|
83
|
+
return gdf
|
84
|
+
|
85
|
+
if __name__ == '__main__':
|
86
|
+
read_exploration_blocks()
|
@@ -1,10 +1,10 @@
|
|
1
|
-
tunned_geobr-1.0.
|
2
|
-
tunned_geobr-1.0.
|
3
|
-
tunned_geobr-1.0.
|
4
|
-
tunned_geobr-1.0.
|
5
|
-
tunned_geobr/__init__.py,sha256=
|
1
|
+
tunned_geobr-1.0.6.dist-info/METADATA,sha256=4OjqUhyA4Js8BnGvXTz8nRjj0z1Q34F8GlhRZVX_yZo,5018
|
2
|
+
tunned_geobr-1.0.6.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
tunned_geobr-1.0.6.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
tunned_geobr-1.0.6.dist-info/licenses/LICENSE.txt,sha256=mECZRcbde3HssOKe1Co4zgqBLGVN0OWpTsEy3LIbcRA,75
|
5
|
+
tunned_geobr/__init__.py,sha256=hOI1zU8GGz2yBn8S6kIAqwmICaJbTIQ3rvtjLaBgZUs,7432
|
6
6
|
tunned_geobr/data/grid_state_correspondence_table.csv,sha256=FpkBuX_-lRXQ1yBrQODxQgG9oha9Fd8A8zGKfdsDAmk,2660
|
7
|
-
tunned_geobr/list_geobr.py,sha256=
|
7
|
+
tunned_geobr/list_geobr.py,sha256=cPi2m8jZHoYE1SpYVdvkU9rjw7MzJukt5kRTsqtiwz8,17374
|
8
8
|
tunned_geobr/lookup_muni.py,sha256=ny1zU4i6OagvL4Mrc6XQWPgn2RrJa_mXlKXh81oVYsM,3462
|
9
9
|
tunned_geobr/read_ama_anemometric_towers.py,sha256=M3qKBTBYdqHzTuWtRrBiLA88Ymt6g0cf7sakJd5mTRo,4686
|
10
10
|
tunned_geobr/read_amazon.py,sha256=HiwKnYebWe3nDMDRUqHpKJIO76bA4ERm4iJlCPhagQg,1286
|
@@ -26,6 +26,7 @@ tunned_geobr/read_biomethane_plants.py,sha256=HP51IQB7KMTOzpfcXNNn3Gg95nUlTjuDat
|
|
26
26
|
tunned_geobr/read_biosphere_reserves.py,sha256=ihW5xbRpIb-vxMr4LDKSflWVCK3mn1gZb2A_GPddR7s,3147
|
27
27
|
tunned_geobr/read_cave_potential.py,sha256=P3LrYTQtfb0OpNAJCOWif9q5zrhI0PEgarEg2o8eNXc,3015
|
28
28
|
tunned_geobr/read_census_tract.py,sha256=aKSvMzfAYSR0P-TDS5xyo4XSO3NRjuYgfb_psDh3kUc,4005
|
29
|
+
tunned_geobr/read_climate.py,sha256=D2-q1vvBuhiMwqXZPCr_O12ZWNj_wyZYMe7_GaUFAG8,2973
|
29
30
|
tunned_geobr/read_climate_aggressiveness.py,sha256=Y53LYy39DNVbuVO_U3iYhyCb-Q3QQm73T2k8ZEXvtG4,2804
|
30
31
|
tunned_geobr/read_comparable_areas.py,sha256=XUOsBiDyYX5z4fj0bofD9Ty6dW4xKRY80MSo_f69Sac,2109
|
31
32
|
tunned_geobr/read_compression_stations.py,sha256=WH1edJ7FARZCDRJoIx-33olm_umIGBbVodWajgVrq3U,5337
|
@@ -45,6 +46,7 @@ tunned_geobr/read_existent_solar.py,sha256=JXbgvPk0XVsERZidVIEbXfC6c-cq1KEIWan1c
|
|
45
46
|
tunned_geobr/read_existent_substations.py,sha256=v9Noi50t5sGMaLqDh5L10H1qH6n5tO2zqx0objPWe50,5385
|
46
47
|
tunned_geobr/read_existent_transmission_lines.py,sha256=rImT61mjwKLauC6MLuN5csTOr1L6DZGezntXv8t7y8Y,5409
|
47
48
|
tunned_geobr/read_existent_uhe.py,sha256=sT5SoZte2sVON2av9FjSXa4-d4vm9wltnqhShbcImzY,7563
|
49
|
+
tunned_geobr/read_exploration_blocks.py,sha256=n2ij1Ar2quxyFw7v-5oKsKmvFsiNszadMCQrom5RuvI,3135
|
48
50
|
tunned_geobr/read_exploration_production_environment.py,sha256=nmf5zUDXF1mFHqGudnctj94aEZzdtnCxM7Ikrx0p9kk,4695
|
49
51
|
tunned_geobr/read_federal_highways.py,sha256=nULCIBFRPKlXWuCMujX_AJv7ZUcwSQtQzhhuFUJ44o0,2797
|
50
52
|
tunned_geobr/read_federal_union_areas.py,sha256=gP2yJMPzz0xna18ldLIbqK0m3LuW84NkX9L0E4ZjNXE,5358
|
@@ -137,4 +139,4 @@ tunned_geobr/read_water_bodies_ana.py,sha256=Z-dpTPVgRHVndTeSFxx8uXn7ufMg2jm0Dlz
|
|
137
139
|
tunned_geobr/read_waterways.py,sha256=mEdoVogYWr5EYZ8bE3xMCVWyLrHYU7xTL2lUE0XbDAM,2951
|
138
140
|
tunned_geobr/read_weighting_area.py,sha256=m2X5Ua3jRqLlkqCQbIzR2jmo58pzqkyR3UYcGtgy20E,2325
|
139
141
|
tunned_geobr/utils.py,sha256=WT9PSGWvcERjj3yhfTvyWSE5ZiEjO4tYK5xIj5jJCg8,8170
|
140
|
-
tunned_geobr-1.0.
|
142
|
+
tunned_geobr-1.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|