tunned-geobr 0.2.3__py3-none-any.whl → 0.2.5__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 +59 -1
- tunned_geobr/list_geobr.py +72 -1
- tunned_geobr/read_ama_anemometric_towers.py +119 -0
- tunned_geobr/read_areas_under_contract.py +129 -0
- tunned_geobr/read_biodiesel_plants.py +128 -0
- tunned_geobr/read_biomethane_plants.py +128 -0
- tunned_geobr/read_compression_stations.py +128 -0
- tunned_geobr/read_drainage_ducts.py +128 -0
- tunned_geobr/read_etanol_plants.py +128 -0
- tunned_geobr/read_existent_biomass_ute.py +128 -0
- tunned_geobr/read_existent_cgh.py +168 -0
- tunned_geobr/read_existent_eolic.py +165 -0
- tunned_geobr/read_existent_fossile_ute.py +128 -0
- tunned_geobr/read_existent_nuclear_ute.py +128 -0
- tunned_geobr/read_existent_pch.py +168 -0
- tunned_geobr/read_existent_solar.py +165 -0
- tunned_geobr/read_existent_substations.py +128 -0
- tunned_geobr/read_existent_transmission_lines.py +128 -0
- tunned_geobr/read_existent_uhe.py +168 -0
- tunned_geobr/read_exploration_production_environment.py +119 -0
- tunned_geobr/read_federal_union_areas.py +129 -0
- tunned_geobr/read_fuel_bases.py +128 -0
- tunned_geobr/read_gas_distribution_pipelines.py +128 -0
- tunned_geobr/read_gas_transport_pipelines.py +128 -0
- tunned_geobr/read_glp_bases.py +128 -0
- tunned_geobr/read_gnl_terminals.py +128 -0
- tunned_geobr/read_hydroelectric_feasibility_studies.py +119 -0
- tunned_geobr/read_hydroelectric_inventory_aai_studies.py +119 -0
- tunned_geobr/read_isolated_systems.py +128 -0
- tunned_geobr/read_natural_gas_delivery_points.py +128 -0
- tunned_geobr/read_natural_gas_processing_hub.py +128 -0
- tunned_geobr/read_og_basement.py +119 -0
- tunned_geobr/read_og_effective_geographic_basin.py +129 -0
- tunned_geobr/read_og_ipa_direct_evidence.py +119 -0
- tunned_geobr/read_og_ipa_exploratory_activity.py +119 -0
- tunned_geobr/read_og_ipa_exploratory_intensity.py +129 -0
- tunned_geobr/read_og_ipa_need_for_knowledge.py +119 -0
- tunned_geobr/read_og_ipa_prospectiveness.py +119 -0
- tunned_geobr/read_og_ipa_supply_infrastructure.py +119 -0
- tunned_geobr/read_og_legal_pre_salt_polygon.py +119 -0
- tunned_geobr/read_og_predominant_fluid_type.py +129 -0
- tunned_geobr/read_og_probabilistic_effective_basin.py +129 -0
- tunned_geobr/read_og_total_ipa.py +129 -0
- tunned_geobr/read_og_unconventional_resources.py +129 -0
- tunned_geobr/read_oil_and_derivatives_terminal.py +128 -0
- tunned_geobr/read_pan_strategic_areas 2.py +71 -0
- tunned_geobr/read_pio_ducts.py +128 -0
- tunned_geobr/read_pio_terminals.py +128 -0
- tunned_geobr/read_planned_biomass_ute.py +166 -0
- tunned_geobr/read_planned_cgh.py +166 -0
- tunned_geobr/read_planned_eolic.py +165 -0
- tunned_geobr/read_planned_fossile_ute.py +166 -0
- tunned_geobr/read_planned_nuclear_ute.py +165 -0
- tunned_geobr/read_planned_pch.py +166 -0
- tunned_geobr/read_planned_solar.py +165 -0
- tunned_geobr/read_planned_substations.py +164 -0
- tunned_geobr/read_planned_transmission_lines.py +165 -0
- tunned_geobr/read_planned_uhe.py +166 -0
- tunned_geobr/read_processing_facilities.py +128 -0
- tunned_geobr/read_quilombola_areas.py +74 -56
- tunned_geobr/read_sedimentary_basins.py +119 -0
- tunned_geobr/read_subsystem_interconnected.py +163 -0
- {tunned_geobr-0.2.3.dist-info → tunned_geobr-0.2.5.dist-info}/METADATA +1 -1
- {tunned_geobr-0.2.3.dist-info → tunned_geobr-0.2.5.dist-info}/RECORD +67 -10
- tunned_geobr/constants.py +0 -13
- tunned_geobr/read_quilombola_areas_temp.py +0 -103
- {tunned_geobr-0.2.3.dist-info → tunned_geobr-0.2.5.dist-info}/WHEEL +0 -0
- {tunned_geobr-0.2.3.dist-info → tunned_geobr-0.2.5.dist-info}/entry_points.txt +0 -0
- {tunned_geobr-0.2.3.dist-info → tunned_geobr-0.2.5.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
import geopandas as gpd
|
2
|
+
import os
|
3
|
+
import tempfile
|
4
|
+
import urllib.parse
|
5
|
+
import requests
|
6
|
+
import shutil
|
7
|
+
from zipfile import ZipFile
|
8
|
+
from pathlib import Path
|
9
|
+
from io import BytesIO
|
10
|
+
import warnings
|
11
|
+
import json
|
12
|
+
|
13
|
+
def read_subsystem_interconnected(simplified=False, verbose=False):
|
14
|
+
"""Download Subsystem of the National Interconnected System data from EPE.
|
15
|
+
|
16
|
+
This function downloads and processes subsystem of the National Interconnected System data from EPE
|
17
|
+
(Energy Research Company). The data includes information about the different subsystems
|
18
|
+
of Brazil's National Interconnected System.
|
19
|
+
Original source: EPE (Empresa de Pesquisa Energética)
|
20
|
+
|
21
|
+
Parameters
|
22
|
+
----------
|
23
|
+
simplified : boolean, by default False
|
24
|
+
If True, returns a simplified version of the dataset with fewer columns
|
25
|
+
verbose : boolean, by default False
|
26
|
+
If True, prints detailed information about the download process
|
27
|
+
|
28
|
+
Returns
|
29
|
+
-------
|
30
|
+
gpd.GeoDataFrame
|
31
|
+
Geodataframe with subsystem of the National Interconnected System data
|
32
|
+
|
33
|
+
Example
|
34
|
+
-------
|
35
|
+
>>> from tunned_geobr import read_subsystem_interconnected
|
36
|
+
|
37
|
+
# Read subsystem of the National Interconnected System data
|
38
|
+
>>> subsystem_data = read_subsystem_interconnected()
|
39
|
+
"""
|
40
|
+
|
41
|
+
# URL for the EPE geoserver
|
42
|
+
url = r"https://gisepeprd2.epe.gov.br/arcgis/rest/services/Download_Dados_Webmap_EPE/GPServer/Extract%20Data%20Task/execute?f=json&env%3AoutSR=102100&Layers_to_Clip=%5B%22Subsistema%20do%20Sistema%20Interligado%20Nacional%22%5D&Area_of_Interest=%7B%22geometryType%22%3A%22esriGeometryPolygon%22%2C%22features%22%3A%5B%7B%22geometry%22%3A%7B%22rings%22%3A%5B%5B%5B-8655251.47456396%2C-4787514.465591563%5D%2C%5B-8655251.47456396%2C1229608.401015912%5D%2C%5B-3508899.2341809804%2C1229608.401015912%5D%2C%5B-3508899.2341809804%2C-4787514.465591563%5D%2C%5B-8655251.47456396%2C-4787514.465591563%5D%5D%5D%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%7D%7D%7D%5D%2C%22sr%22%3A%7B%22wkid%22%3A102100%7D%7D&Feature_Format=Shapefile%20-%20SHP%20-%20.shp&Raster_Format=Tagged%20Image%20File%20Format%20-%20TIFF%20-%20.tif"
|
43
|
+
|
44
|
+
try:
|
45
|
+
# Disable SSL verification warning
|
46
|
+
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
|
47
|
+
|
48
|
+
if verbose:
|
49
|
+
print("Requesting data from EPE server...")
|
50
|
+
|
51
|
+
response = requests.get(url, timeout=60, verify=False)
|
52
|
+
if not response.ok:
|
53
|
+
raise Exception(f"Error getting JSON response: {response.status_code}")
|
54
|
+
|
55
|
+
json_response = response.json()
|
56
|
+
|
57
|
+
if verbose:
|
58
|
+
print(f"JSON response received: {json.dumps(json_response, indent=2)[:500]}...")
|
59
|
+
|
60
|
+
if 'results' not in json_response or len(json_response['results']) == 0:
|
61
|
+
raise Exception("Invalid JSON response structure")
|
62
|
+
|
63
|
+
if 'value' not in json_response['results'][0] or 'url' not in json_response['results'][0]['value']:
|
64
|
+
raise Exception("URL not found in JSON response")
|
65
|
+
|
66
|
+
file_url = json_response['results'][0]['value']['url']
|
67
|
+
|
68
|
+
if verbose:
|
69
|
+
print(f"Downloading file from: {file_url}")
|
70
|
+
|
71
|
+
file_response = requests.get(file_url, stream=True, timeout=60, verify=False)
|
72
|
+
if not file_response.ok:
|
73
|
+
raise Exception(f"Error downloading file: {file_response.status_code}")
|
74
|
+
|
75
|
+
# Check if content is actually a zip file
|
76
|
+
content = file_response.content
|
77
|
+
if len(content) < 100:
|
78
|
+
if verbose:
|
79
|
+
print(f"Warning: Downloaded content is very small ({len(content)} bytes)")
|
80
|
+
print(f"Content preview: {content[:100]}")
|
81
|
+
|
82
|
+
# Create a temporary directory to extract the files
|
83
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
84
|
+
if verbose:
|
85
|
+
print(f"Extracting files to temporary directory: {temp_dir}")
|
86
|
+
|
87
|
+
try:
|
88
|
+
# Extract the zip file
|
89
|
+
with ZipFile(BytesIO(content)) as zip_ref:
|
90
|
+
zip_ref.extractall(temp_dir)
|
91
|
+
|
92
|
+
if verbose:
|
93
|
+
print(f"Files in zip: {zip_ref.namelist()}")
|
94
|
+
except Exception as zip_error:
|
95
|
+
if verbose:
|
96
|
+
print(f"Error extracting zip: {str(zip_error)}")
|
97
|
+
print(f"Saving content to debug.zip for inspection")
|
98
|
+
with open("debug.zip", "wb") as f:
|
99
|
+
f.write(content)
|
100
|
+
raise Exception(f"Failed to extract zip file: {str(zip_error)}")
|
101
|
+
|
102
|
+
# Find the shapefile
|
103
|
+
all_files = os.listdir(temp_dir)
|
104
|
+
if verbose:
|
105
|
+
print(f"Files in temp directory: {all_files}")
|
106
|
+
|
107
|
+
shp_files = [f for f in all_files if f.endswith('.shp')]
|
108
|
+
if not shp_files:
|
109
|
+
# Try looking in subdirectories
|
110
|
+
for root, dirs, files in os.walk(temp_dir):
|
111
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
112
|
+
|
113
|
+
if not shp_files:
|
114
|
+
raise Exception("No shapefile found in the downloaded data")
|
115
|
+
|
116
|
+
# Read the shapefile
|
117
|
+
shp_path = shp_files[0] if os.path.isabs(shp_files[0]) else os.path.join(temp_dir, shp_files[0])
|
118
|
+
if verbose:
|
119
|
+
print(f"Reading shapefile: {shp_path}")
|
120
|
+
|
121
|
+
gdf = gpd.read_file(shp_path)
|
122
|
+
|
123
|
+
# Convert to SIRGAS 2000 (EPSG:4674)
|
124
|
+
gdf = gdf.to_crs(4674)
|
125
|
+
|
126
|
+
if verbose:
|
127
|
+
print(f"Data loaded successfully with {len(gdf)} records")
|
128
|
+
print(f"Columns: {gdf.columns.tolist()}")
|
129
|
+
|
130
|
+
if simplified:
|
131
|
+
# Keep only the most relevant columns
|
132
|
+
columns_to_keep = [
|
133
|
+
'geometry',
|
134
|
+
'nome', # Subsystem name
|
135
|
+
'sigla', # Subsystem acronym
|
136
|
+
'area_km2' # Area in km²
|
137
|
+
]
|
138
|
+
|
139
|
+
# Filter columns that actually exist in the dataset
|
140
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
141
|
+
if len(existing_columns) <= 1:
|
142
|
+
if verbose:
|
143
|
+
print("Warning: No matching columns found for simplified version. Returning all columns.")
|
144
|
+
else:
|
145
|
+
gdf = gdf[existing_columns]
|
146
|
+
|
147
|
+
except Exception as e:
|
148
|
+
raise Exception(f"Error downloading or processing subsystem of the National Interconnected System data: {str(e)}")
|
149
|
+
|
150
|
+
return gdf
|
151
|
+
|
152
|
+
if __name__ == '__main__':
|
153
|
+
try:
|
154
|
+
subsystem_data = read_subsystem_interconnected(verbose=True)
|
155
|
+
print(f"Downloaded subsystem of the National Interconnected System data with {len(subsystem_data)} records and {len(subsystem_data.columns)} columns")
|
156
|
+
|
157
|
+
# Test simplified version
|
158
|
+
simplified_data = read_subsystem_interconnected(simplified=True)
|
159
|
+
print(f"Simplified data has {len(simplified_data.columns)} columns: {simplified_data.columns.tolist()}")
|
160
|
+
except Exception as e:
|
161
|
+
print(f"Error: {str(e)}")
|
162
|
+
import traceback
|
163
|
+
traceback.print_exc()
|
@@ -1,12 +1,12 @@
|
|
1
|
-
tunned_geobr-0.2.
|
2
|
-
tunned_geobr-0.2.
|
3
|
-
tunned_geobr-0.2.
|
4
|
-
tunned_geobr-0.2.
|
5
|
-
tunned_geobr/__init__.py,sha256=
|
6
|
-
tunned_geobr/constants.py,sha256=ZHj4pKtrxoUMFFgw-4ikuFcCkxEjzIbWL_gzhutGDB4,262
|
1
|
+
tunned_geobr-0.2.5.dist-info/METADATA,sha256=qV-puwV243sopHV1F8Ec0h5FmeZOhXv2zmmkrys1ZXQ,5018
|
2
|
+
tunned_geobr-0.2.5.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
tunned_geobr-0.2.5.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
tunned_geobr-0.2.5.dist-info/licenses/LICENSE.txt,sha256=mECZRcbde3HssOKe1Co4zgqBLGVN0OWpTsEy3LIbcRA,75
|
5
|
+
tunned_geobr/__init__.py,sha256=6kbBMfBy0NidzGz_heNFEFPLLVVaNphTqGOFV-6qzqI,7354
|
7
6
|
tunned_geobr/data/grid_state_correspondence_table.csv,sha256=FpkBuX_-lRXQ1yBrQODxQgG9oha9Fd8A8zGKfdsDAmk,2660
|
8
|
-
tunned_geobr/list_geobr.py,sha256=
|
7
|
+
tunned_geobr/list_geobr.py,sha256=l-sXzMr94uHZfeYDKgcdlnwaVbB50rrw02I0ehRIWAg,17305
|
9
8
|
tunned_geobr/lookup_muni.py,sha256=ny1zU4i6OagvL4Mrc6XQWPgn2RrJa_mXlKXh81oVYsM,3462
|
9
|
+
tunned_geobr/read_ama_anemometric_towers.py,sha256=I3YUhwt_-kOYYupTM3H0-MgmyMpz3zLgI4l3re7U4K8,4691
|
10
10
|
tunned_geobr/read_amazon.py,sha256=7o2uoJ-NAwsENAjoNTbR8AFIg_piEiWttpICPzkA9IM,1285
|
11
11
|
tunned_geobr/read_amazon_ibas.py,sha256=RtOo5wPfc26S2HYJCLylNCPM5cHBOLGTP4uKEtGC3Bw,3500
|
12
12
|
tunned_geobr/read_apcb_amazon.py,sha256=IQZc_hyDcwYtRkQmdJMuQuZVcCGeuF9S5p3xeOghUgo,2834
|
@@ -16,31 +16,57 @@ tunned_geobr/read_apcb_mata_atlantica.py,sha256=ZFvV8kZXfoZuEWPYu05Qky0F6I5KqD-X
|
|
16
16
|
tunned_geobr/read_apcb_pampa.py,sha256=ILypuNxVy1R3WLQr4xc4ICW5iOnMXWO9A-uGsBK3EIU,2819
|
17
17
|
tunned_geobr/read_apcb_zcm.py,sha256=I0j8RWbIkOr2Wa6uskhD70_oQpo4boUTg_bikL-P7n8,2893
|
18
18
|
tunned_geobr/read_archaeological_sites.py,sha256=h0RhY6Yt0icO195lrBbRTAN0wyt-cSCNMjAlfTUqSpA,3408
|
19
|
+
tunned_geobr/read_areas_under_contract.py,sha256=y0fMHrqgnZpTXNKPb6GEaU0X9Fylwwqj0PRonLVUV5M,5341
|
19
20
|
tunned_geobr/read_atlantic_forest_ibas.py,sha256=67rY-yo_Sv8g26YVVXgXy_z4pPV4j8Y2GGs8I5jBX0k,3570
|
20
21
|
tunned_geobr/read_atlantic_forest_law_limits.py,sha256=lDovZnFyLVUgM37hN0pMN8zUY9iyZlNNAfuQjb-EBFI,2758
|
21
22
|
tunned_geobr/read_baze_sites.py,sha256=nwlEp3R34IecIUiv-3q5yKA-6rbNAqMK463Em4msjvI,6343
|
23
|
+
tunned_geobr/read_biodiesel_plants.py,sha256=aCEbxtCe1L00UF2mGvRcyywNG_82-q1IlYiyiq0g4R0,5264
|
22
24
|
tunned_geobr/read_biomes.py,sha256=OM69JHTm6MfjdwXl3QGLMdAA6h_WUhGZ0v_1Pt2N-Ds,1337
|
25
|
+
tunned_geobr/read_biomethane_plants.py,sha256=7fWgZtoiGfVX72bLyLgIEGU8zvxkazTgBLCaLVAwTEA,5276
|
23
26
|
tunned_geobr/read_biosphere_reserves.py,sha256=ihW5xbRpIb-vxMr4LDKSflWVCK3mn1gZb2A_GPddR7s,3147
|
24
27
|
tunned_geobr/read_cave_potential.py,sha256=P3LrYTQtfb0OpNAJCOWif9q5zrhI0PEgarEg2o8eNXc,3015
|
25
28
|
tunned_geobr/read_census_tract.py,sha256=yuNx_sYWNe0XJCG9f87RNlL7aBq3aS0tTaeJMRo1wEY,3258
|
26
29
|
tunned_geobr/read_census_tract_2022.py,sha256=JtoJJtZ2rFiC5gtuZ7V_5teYFkuq1-GkV4GalSkhorQ,4066
|
27
30
|
tunned_geobr/read_climate_aggressiveness.py,sha256=Y53LYy39DNVbuVO_U3iYhyCb-Q3QQm73T2k8ZEXvtG4,2804
|
28
31
|
tunned_geobr/read_comparable_areas.py,sha256=SxUnlN-c2ALG5GsYkk8OiRMU7TKmocxet1cPCsFCj8M,2108
|
32
|
+
tunned_geobr/read_compression_stations.py,sha256=oTBMziFpYy2WML95pz1PNbaKtkhlklLvzjPYAebcz2Q,5282
|
29
33
|
tunned_geobr/read_conservation_units.py,sha256=JxnJZhEHGIeH5BKD5Dm9fgph1lfhvlwnAQPh3aG8Ld8,1379
|
30
34
|
tunned_geobr/read_country.py,sha256=clBQlsVA_xCNc0JosKYiUe8q_ySQbkew-kRlSajEfJs,1357
|
31
35
|
tunned_geobr/read_disaster_risk_area.py,sha256=zlSVIwfcD0yZ5A7lAUHMSuML9RaAzzxXKfheSDbnmxE,1845
|
36
|
+
tunned_geobr/read_drainage_ducts.py,sha256=slK44CLo9sN9tVaY0rkpJT-IsKBjuHcMYojc-y7SPME,5199
|
32
37
|
tunned_geobr/read_ebas.py,sha256=4TDZt4b2-tKnTfEJEHUuomsRBUFTJXcH8HFYkGlx6cI,2759
|
38
|
+
tunned_geobr/read_etanol_plants.py,sha256=jMMZ_DBVNcbqFyc00j7JHK-bJmZiBqYubgDrtN3YhhU,5231
|
39
|
+
tunned_geobr/read_existent_biomass_ute.py,sha256=LxPz2C-gX3ZZAfS-3IhrUIidE7p8v5J8wX2qwnx714M,5388
|
40
|
+
tunned_geobr/read_existent_cgh.py,sha256=_2xnbAybV0AW8g2NJndkAkKvf2I-CETPPtiIM0NqnmI,7556
|
41
|
+
tunned_geobr/read_existent_eolic.py,sha256=atKqzb14gQMigHKwdDoYUVkQU1bX4DfdBM468ySot8o,7335
|
42
|
+
tunned_geobr/read_existent_fossile_ute.py,sha256=S_AdxedciScLc3vUjDsOylUeYkGUGP5hTM92spwCb-8,5385
|
43
|
+
tunned_geobr/read_existent_nuclear_ute.py,sha256=j8Qvykm0Yyuim3_8src_Hq6iQfVHHRQ9VjD6u1Se8Gk,5373
|
44
|
+
tunned_geobr/read_existent_pch.py,sha256=mI2A1Vm4ikFNJ8vNaEOWcBkbTWfSdav3mIQvUcRWQKc,7563
|
45
|
+
tunned_geobr/read_existent_solar.py,sha256=JXbgvPk0XVsERZidVIEbXfC6c-cq1KEIWan1cBnlmH8,7348
|
46
|
+
tunned_geobr/read_existent_substations.py,sha256=hKVMz09Fm5ES1L_26vlPF96j45HOJmNepsVvaTvD6lk,5301
|
47
|
+
tunned_geobr/read_existent_transmission_lines.py,sha256=yWoHMPoa66eMApAqtC_0WMGquULqxMXO0G_Y8i7jRzE,5327
|
48
|
+
tunned_geobr/read_existent_uhe.py,sha256=sT5SoZte2sVON2av9FjSXa4-d4vm9wltnqhShbcImzY,7563
|
49
|
+
tunned_geobr/read_exploration_production_environment.py,sha256=M8u7k0JCzOKGof-Emps0CvIC0SUUkZjvZ9KsImXUzik,4754
|
33
50
|
tunned_geobr/read_federal_highways.py,sha256=nULCIBFRPKlXWuCMujX_AJv7ZUcwSQtQzhhuFUJ44o0,2797
|
51
|
+
tunned_geobr/read_federal_union_areas.py,sha256=SnzdGs0zJreh8RALGairO57mvva3wUJjTWTUv-O1Ai0,5303
|
34
52
|
tunned_geobr/read_fossil_occurrences.py,sha256=LxL5D_6H758lgQBpl_CWZuggEOZg31THVD2dAiM85N4,3598
|
53
|
+
tunned_geobr/read_fuel_bases.py,sha256=Fmu9swdPp4Pdri_HDP95Hegj2ZY87ZGE6C7t0vd61MM,5123
|
54
|
+
tunned_geobr/read_gas_distribution_pipelines.py,sha256=ALNxscxsc8uq_Lw_oPpBW2yeHlPJXug-7l8Weaatqdg,5341
|
55
|
+
tunned_geobr/read_gas_transport_pipelines.py,sha256=xItLOd_HClYg7e-Zf6X5LJzVDR1bOGw--PCFqkQsM30,5299
|
35
56
|
tunned_geobr/read_geographic_regions.py,sha256=11ZDKhfYrUUbmcROMipdJHglHLgXm6sZXbkf3uz2Bws,3474
|
36
57
|
tunned_geobr/read_geology.py,sha256=dzMUN1RYD4VcGOkle8iJtNZGiPQJ8x9kEdDirKgS-9Y,2766
|
37
58
|
tunned_geobr/read_geomorphology.py,sha256=7TFy9CYLUL0lFBTKT_lZeUL7r5c9mWp64VpXUwKTLHY,2843
|
59
|
+
tunned_geobr/read_glp_bases.py,sha256=PZK3iUHoeZipB80DvpzDg4jjPE8YiiMzeFq8ik70uKw,5135
|
60
|
+
tunned_geobr/read_gnl_terminals.py,sha256=AAfhECIHCOtiLV283krSl44CAd8GKWJzTs4dgPMEa-g,5188
|
38
61
|
tunned_geobr/read_health_facilities.py,sha256=NEU2BGEBmIPbT0Z02EOKLtfC9-_AmNrIHaD-83kmh5Q,2012
|
39
62
|
tunned_geobr/read_health_region.py,sha256=uT3TUSpQFuC0BdvVbg7UKf8_RNVmeNAdMlLZvgPWN4c,1832
|
40
63
|
tunned_geobr/read_heliports.py,sha256=liLQ5J7UgHcxcsx7xpkh_4oxxh4rNz7hprTwnWSViw4,2791
|
64
|
+
tunned_geobr/read_hydroelectric_feasibility_studies.py,sha256=61hBf0218A--VF_SP9F4xcgtM3GYAjFuBk6VkZtvmP0,4764
|
65
|
+
tunned_geobr/read_hydroelectric_inventory_aai_studies.py,sha256=_2Cl6haiM4lJwDW5d2SNCVkUfywBOs9Q4qBLCndiamw,4814
|
41
66
|
tunned_geobr/read_immediate_region.py,sha256=rR8qyHoAzl3tP2eKvpPOIWjMDrHHDWBUD8wZdNFVtzU,2554
|
42
67
|
tunned_geobr/read_indigenous_land.py,sha256=TGmLHj8s7mvsO8y9GWhNVwCMw_zdSzdSOFCH7dD3iRM,1459
|
43
68
|
tunned_geobr/read_intermediate_region.py,sha256=vzDHaUJhx_zaAu-s8jt4lxM93JJRYMbAqNH3gs1GCss,2185
|
69
|
+
tunned_geobr/read_isolated_systems.py,sha256=dWhfm8CnB7cgi1DetuHr6e0F5QDjIKEsAHOcj0chQIk,5231
|
44
70
|
tunned_geobr/read_meso_region.py,sha256=q_3FO7wtRy8LEF7TxF18YqlICb--C2gvp0uIgc0c4g8,2601
|
45
71
|
tunned_geobr/read_metro_area.py,sha256=CAo79d5sLlTPhejlpWlQb5bQT5YRpBi-pfdRdKbPxT8,1497
|
46
72
|
tunned_geobr/read_micro_region.py,sha256=tbIUSTWOxfz-8Fh9z274XNfI-IC1r8V2lQbgWViLufQ,2509
|
@@ -49,20 +75,50 @@ tunned_geobr/read_municipal_seat.py,sha256=9Vi-q1jzY8n086O-nNY1sVkVzV_NZbdzE5juo
|
|
49
75
|
tunned_geobr/read_municipality.py,sha256=oovNlQdCbfD9KN3ywWU4SRzWQUK7Q_kGQRztK-Mq-9A,2593
|
50
76
|
tunned_geobr/read_municipality_direct.py,sha256=v2oRUyYlkOrJy_FTmxZMo3kug9rzAoescrkc293H1OY,5650
|
51
77
|
tunned_geobr/read_natural_caves.py,sha256=-XjoRxhT_yYy0fZu87S6RRUZ-cyaWPqWqOrd9Y8ERKo,3073
|
78
|
+
tunned_geobr/read_natural_gas_delivery_points.py,sha256=mKeywQ610Qw9ttY1_v-KclMIml3Tff3knhAAlBgAh0c,5309
|
79
|
+
tunned_geobr/read_natural_gas_processing_hub.py,sha256=hAbCt4BunWQ78bDOtl7zrunJUia0bPr_LpdZiNwKAFw,5306
|
52
80
|
tunned_geobr/read_neighborhood.py,sha256=H96W8QEDqPtJ6lIJaegaRKZftzaGKmKkmbs-ZNBsM-Q,1084
|
53
81
|
tunned_geobr/read_neighborhoods_2022.py,sha256=EX1-5CM3tNe05HE1F5r3YtZ-66X_NC67u_DzrmzKvTc,3952
|
82
|
+
tunned_geobr/read_og_basement.py,sha256=9fdOoMDPBUkDgwxBU_3BL0BZDANPSoIgXWhKjtQVlxk,4618
|
83
|
+
tunned_geobr/read_og_effective_geographic_basin.py,sha256=lDnVSh8R4Ic-ldkkDLN7ugUkUpScMLeaLjNpdat4iwQ,5402
|
84
|
+
tunned_geobr/read_og_ipa_direct_evidence.py,sha256=dqIVIonwujERYTR_Kz3I9F3FzBiWHIGK_cOeoM0FQyo,4799
|
85
|
+
tunned_geobr/read_og_ipa_exploratory_activity.py,sha256=BZOVfhi524zKQFOWK445y09JBFwHKS3i8JndjXgF378,4748
|
86
|
+
tunned_geobr/read_og_ipa_exploratory_intensity.py,sha256=A1Boae3YoKCH0jn7Z0sWUkVBYJ8aKl4naMpqOs3DS3I,5401
|
87
|
+
tunned_geobr/read_og_ipa_need_for_knowledge.py,sha256=_E9g6psmo0HWzg9WxSrNQtiiQv3kUIKvq-NtjyifLSA,4738
|
88
|
+
tunned_geobr/read_og_ipa_prospectiveness.py,sha256=yuY25wAeUIaPMBEePKmTT_cvpjGKpwIDq-GyM8dpDEw,4704
|
89
|
+
tunned_geobr/read_og_ipa_supply_infrastructure.py,sha256=RIze4M4K5DpUISZ3MlYRKWaiki-XOTdh_kUg5MPtn0s,4760
|
90
|
+
tunned_geobr/read_og_legal_pre_salt_polygon.py,sha256=2NSqvlqqCu_PjRMKyIjzbOrA1s390LGeuyDpcoE4Pu4,4734
|
91
|
+
tunned_geobr/read_og_predominant_fluid_type.py,sha256=tYAZeHYKHT8qN1f_Iko3GIVCKZxx27T_d_G0rtGwcr0,5397
|
92
|
+
tunned_geobr/read_og_probabilistic_effective_basin.py,sha256=5VZixVU5wDclBhiXYQHPs5azK_3KJkr-N5vndeujcTg,5442
|
93
|
+
tunned_geobr/read_og_total_ipa.py,sha256=HWFI6-HcEvhvhBK4eWVTsZcqx2UC8b7zOjjtQxxNT_4,5245
|
94
|
+
tunned_geobr/read_og_unconventional_resources.py,sha256=E2Kkv6N3V2aMhViyrJWmGxgC6kLhshdRzP4oJnBmKU8,5389
|
95
|
+
tunned_geobr/read_oil_and_derivatives_terminal.py,sha256=7l6vBVX23JEMH06sjn5E8vHiW0R-ws3rzBav_G50pNA,5330
|
96
|
+
tunned_geobr/read_pan_strategic_areas 2.py,sha256=alORMUQbnW_ER3_uOzqTbUaSyr-Y3Mg_bsoykxiGDMA,2654
|
54
97
|
tunned_geobr/read_pan_strategic_areas.py,sha256=EP-Qtx_q4lE3lsNNIUaoQc5j-9aKBkxY2BizTwWY3ZY,3375
|
55
98
|
tunned_geobr/read_pedology.py,sha256=xk_yOxIOVTHip4kj2y1xgO4fHKn8e1dv2cNOayXCtKk,2783
|
99
|
+
tunned_geobr/read_pio_ducts.py,sha256=gNfClvKh3x0gckWe4GNqcil9WwOMoPffU7V_LXDzmqI,5128
|
100
|
+
tunned_geobr/read_pio_terminals.py,sha256=NduuiA1AOc7vvMnwJlqc9V4QeiXlWtFaylS3prKjG14,5191
|
101
|
+
tunned_geobr/read_planned_biomass_ute.py,sha256=AEPmAuhBZyicYA_nATsMhhHEmJ6xnUNQZtRXkE67cLk,7557
|
102
|
+
tunned_geobr/read_planned_cgh.py,sha256=Tms3Ed9tYnXKqua7fHAd8PTxhm7MUv88Mq_ZU9ny5go,7458
|
103
|
+
tunned_geobr/read_planned_eolic.py,sha256=WOaWY1bKHFBysaZNzDT7VyT4tEpL_TcnRdrCGy2ZVgs,7345
|
104
|
+
tunned_geobr/read_planned_fossile_ute.py,sha256=B0c6cI-gIwmRnx4fOegWhtdg_34YBTcGVsKb3l7wwlg,7553
|
105
|
+
tunned_geobr/read_planned_nuclear_ute.py,sha256=JiZUakYvHlflVsG8HkYbwdsuZ_Wf9uSjr16mGX--i5Y,7505
|
106
|
+
tunned_geobr/read_planned_pch.py,sha256=hTz0fH5_0_OMagem0ZwwoWfD90Q9kV3kqp4fXVYwfJA,7465
|
107
|
+
tunned_geobr/read_planned_solar.py,sha256=An69HvVYdzN_QMaFzLiB1TMiMdPOP-H4fbZ6FSg2n8M,7341
|
108
|
+
tunned_geobr/read_planned_substations.py,sha256=xUwUhRC5qMxricukn708r-nvuo0Q1lWAIjOzpOk21bA,7356
|
109
|
+
tunned_geobr/read_planned_transmission_lines.py,sha256=UwcEd5bWWMKQs94tudF6UFj8jcKwm2LH6KL9af4pinQ,7390
|
110
|
+
tunned_geobr/read_planned_uhe.py,sha256=Podxyzscn8xrvgBkwwtJ6QJIoNh0FrGLRpblB_MEzxY,7465
|
56
111
|
tunned_geobr/read_pop_arrangements.py,sha256=x3Q1uDrqLoMuqAaTW3gUyJdq6-e9ve79pg6qbV0xp0U,1385
|
57
112
|
tunned_geobr/read_ports.py,sha256=dOFOhQ2kim-_VJ_bC1ZiABqD9-FCOelkrTAaLD_yAmY,2848
|
58
113
|
tunned_geobr/read_private_aerodromes.py,sha256=Il9sfvBxDM-Xv6fkvOXYfaFLfjOaHlIw-tTGhUJ_TpM,2918
|
114
|
+
tunned_geobr/read_processing_facilities.py,sha256=BABgyK2FBlHyVSBBzuYN5kRyq9H6LzinPbVOcVsgvgg,5294
|
59
115
|
tunned_geobr/read_public_aerodromes.py,sha256=nq3b9HF5_e-yeNcSfQ5ktdAGHKbSfDD_imj-tOhjKJA,2909
|
60
|
-
tunned_geobr/read_quilombola_areas.py,sha256=
|
61
|
-
tunned_geobr/read_quilombola_areas_temp.py,sha256=iY-r4YDRjaGyO-iPRBm1kWDkN_-axjYxMAQyAjIfG68,4288
|
116
|
+
tunned_geobr/read_quilombola_areas.py,sha256=iY-r4YDRjaGyO-iPRBm1kWDkN_-axjYxMAQyAjIfG68,4288
|
62
117
|
tunned_geobr/read_railways.py,sha256=J6eM0yr049CaOL95PMd4sGc7JJHiEinJhqf0ThCOClg,2763
|
63
118
|
tunned_geobr/read_region.py,sha256=qHbmj3uS-W2Vk6Z1d4vVUA9d03gqGqoujIWPqWk-L8Y,955
|
64
119
|
tunned_geobr/read_rppn.py,sha256=nXDzclIiqhutkYWvxlIH_mYSNGdfRVSUzSzi-15X-3w,3963
|
65
120
|
tunned_geobr/read_schools.py,sha256=kxaRwuKmZDPgSuhCUd_Ltxo-6_z3b3jXY9Qo0MY_b-A,1364
|
121
|
+
tunned_geobr/read_sedimentary_basins.py,sha256=HsL-QHpEVrzUyEJ9qW8xZOkhoJw4LRxCPoeI7G7GByI,4634
|
66
122
|
tunned_geobr/read_semiarid.py,sha256=o6WZFqO4d-x_A7fsZD3NotFlraasuiy_LmwrNG_SjoA,1357
|
67
123
|
tunned_geobr/read_settlements.py,sha256=C47Wj4DhSDa-pSFfYK4uGDwtu4sUwqPMr-CuuxS95xg,3060
|
68
124
|
tunned_geobr/read_sigef_properties.py,sha256=LZ69L6ev-7JT0chINKcgHZKl1ZpH6iLk6Je_HAxDnsQ,3204
|
@@ -71,6 +127,7 @@ tunned_geobr/read_state.py,sha256=F6VKlVweo2v9K82weqoj22AhgtuLZSaGYmm7B1Y-vIY,26
|
|
71
127
|
tunned_geobr/read_state_direct.py,sha256=AA3a7XxO2NocRNBGd1FpYriTE2_l-f8sbxwOgRMf9Fw,3818
|
72
128
|
tunned_geobr/read_state_highways.py,sha256=pvRkwuensDOFh3wrcui36iTLcOtkrXoZmT50oUL8WFI,2769
|
73
129
|
tunned_geobr/read_statistical_grid.py,sha256=14fgzDrJtjDoOVzV8Qg8kkqruqiwCSwwRHVjct_w3bM,4479
|
130
|
+
tunned_geobr/read_subsystem_interconnected.py,sha256=bm4S63vLZJfph0u7ZN3qPRMYp_DKSL51K33hYq4dXzQ,7446
|
74
131
|
tunned_geobr/read_transmission_lines_ons.py,sha256=9IYGW16oFu32R4qgwfmY6aJQKooY1nf0x7RvBshoSL0,3117
|
75
132
|
tunned_geobr/read_urban_area.py,sha256=XG3DkiGrg8b_b2cZ3gcGTL3JohqCYCMgiOOLnsN5YUA,1363
|
76
133
|
tunned_geobr/read_urban_concentrations.py,sha256=HPCn9Z1Ya3vFpX6WKKT1c_VkrDrMp7vAclwbq88AMDc,1427
|
@@ -79,4 +136,4 @@ tunned_geobr/read_water_bodies_ana.py,sha256=e8wQukpQABjyFCdqSWcFXXMdD-jmguELVJa
|
|
79
136
|
tunned_geobr/read_waterways.py,sha256=mEdoVogYWr5EYZ8bE3xMCVWyLrHYU7xTL2lUE0XbDAM,2951
|
80
137
|
tunned_geobr/read_weighting_area.py,sha256=fsV9pXWOw1X7XLS9SAUHVhKy6sw97EEXF5kWEEpFaZ8,2324
|
81
138
|
tunned_geobr/utils.py,sha256=WT9PSGWvcERjj3yhfTvyWSE5ZiEjO4tYK5xIj5jJCg8,8170
|
82
|
-
tunned_geobr-0.2.
|
139
|
+
tunned_geobr-0.2.5.dist-info/RECORD,,
|
tunned_geobr/constants.py
DELETED
@@ -1,103 +0,0 @@
|
|
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
|
-
import urllib3
|
8
|
-
import time
|
9
|
-
from pathlib import Path
|
10
|
-
|
11
|
-
def read_quilombola_areas(simplified=False, local_file=None):
|
12
|
-
"""Download Quilombola Areas data from INCRA.
|
13
|
-
|
14
|
-
This function downloads and processes data about Quilombola Areas (Áreas Quilombolas)
|
15
|
-
in Brazil. These are territories recognized and titled to remaining quilombo communities.
|
16
|
-
Original source: INCRA - Instituto Nacional de Colonização e Reforma Agrária
|
17
|
-
|
18
|
-
Parameters
|
19
|
-
----------
|
20
|
-
simplified : boolean, by default False
|
21
|
-
If True, returns a simplified version of the dataset with fewer columns
|
22
|
-
local_file : string, optional
|
23
|
-
Path to a local zip file containing the data, by default None
|
24
|
-
If provided, the function will use this file instead of downloading from INCRA
|
25
|
-
|
26
|
-
Returns
|
27
|
-
-------
|
28
|
-
gpd.GeoDataFrame
|
29
|
-
Geodataframe with Quilombola Areas data
|
30
|
-
Columns:
|
31
|
-
- geometry: Geometry of the area
|
32
|
-
- nome: Area name
|
33
|
-
- municipio: Municipality
|
34
|
-
- uf: State
|
35
|
-
- area_ha: Area in hectares
|
36
|
-
- fase: Current phase in the titling process
|
37
|
-
- familias: Number of families
|
38
|
-
- portaria: Ordinance number
|
39
|
-
- decreto: Decree number
|
40
|
-
- titulo: Title number
|
41
|
-
- data_titulo: Title date
|
42
|
-
|
43
|
-
Example
|
44
|
-
-------
|
45
|
-
>>> from tunned_geobr import read_quilombola_areas
|
46
|
-
|
47
|
-
# Read Quilombola Areas data
|
48
|
-
>>> quilombos = read_quilombola_areas()
|
49
|
-
|
50
|
-
# Or use a local file that was previously downloaded
|
51
|
-
>>> quilombos = read_quilombola_areas(local_file="path/to/Áreas de Quilombolas.zip")
|
52
|
-
"""
|
53
|
-
|
54
|
-
url = "https://certificacao.incra.gov.br/csv_shp/zip/Áreas%20de%20Quilombolas.zip"
|
55
|
-
|
56
|
-
# If a local file is provided, use it instead of downloading
|
57
|
-
if local_file and os.path.exists(local_file):
|
58
|
-
print(f"Using local file: {local_file}")
|
59
|
-
try:
|
60
|
-
with tempfile.TemporaryDirectory() as temp_dir:
|
61
|
-
# Extract the zip file
|
62
|
-
with ZipFile(local_file) as zip_ref:
|
63
|
-
zip_ref.extractall(temp_dir)
|
64
|
-
|
65
|
-
# Find the shapefile
|
66
|
-
shp_files = [f for f in os.listdir(temp_dir) if f.endswith('.shp')]
|
67
|
-
if not shp_files:
|
68
|
-
raise Exception("No shapefile found in the local file")
|
69
|
-
|
70
|
-
print(f"Found shapefile: {shp_files[0]}")
|
71
|
-
|
72
|
-
# Read the shapefile
|
73
|
-
gdf = gpd.read_file(os.path.join(temp_dir, shp_files[0]))
|
74
|
-
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
75
|
-
|
76
|
-
print(f"Successfully loaded {len(gdf)} Quilombola Areas from local file")
|
77
|
-
|
78
|
-
if simplified:
|
79
|
-
# Keep only the most relevant columns
|
80
|
-
columns_to_keep = [
|
81
|
-
'geometry',
|
82
|
-
'nome', # Area name
|
83
|
-
'municipio', # Municipality
|
84
|
-
'uf', # State
|
85
|
-
'area_ha', # Area in hectares
|
86
|
-
'fase' # Current phase
|
87
|
-
]
|
88
|
-
|
89
|
-
# Filter columns that actually exist in the dataset
|
90
|
-
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
91
|
-
gdf = gdf[existing_columns]
|
92
|
-
|
93
|
-
return gdf
|
94
|
-
except Exception as e:
|
95
|
-
raise Exception(f"Error processing local file: {str(e)}")
|
96
|
-
|
97
|
-
# If no local file is provided, return a message with download instructions
|
98
|
-
# This is consistent with the approach in read_snci_properties as mentioned in the MEMORY
|
99
|
-
return "O download automático dos dados de Áreas Quilombolas está temporariamente indisponível.\nPor favor, faça o download manual através do link:\n" + url + "\n\nApós o download, você pode usar o parâmetro local_file:\nquilombos = read_quilombola_areas(local_file='caminho/para/Áreas de Quilombolas.zip')"
|
100
|
-
|
101
|
-
if __name__ == '__main__':
|
102
|
-
quilombos = read_quilombola_areas()
|
103
|
-
print(quilombos)
|
File without changes
|
File without changes
|
File without changes
|