tunned-geobr 1.0.16__py3-none-any.whl → 1.0.18__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 +2 -1
- tunned_geobr/read_quilombola_areas.py +43 -51
- {tunned_geobr-1.0.16.dist-info → tunned_geobr-1.0.18.dist-info}/METADATA +1 -1
- {tunned_geobr-1.0.16.dist-info → tunned_geobr-1.0.18.dist-info}/RECORD +7 -7
- {tunned_geobr-1.0.16.dist-info → tunned_geobr-1.0.18.dist-info}/WHEEL +0 -0
- {tunned_geobr-1.0.16.dist-info → tunned_geobr-1.0.18.dist-info}/entry_points.txt +0 -0
- {tunned_geobr-1.0.16.dist-info → tunned_geobr-1.0.18.dist-info}/licenses/LICENSE.txt +0 -0
tunned_geobr/__init__.py
CHANGED
@@ -135,4 +135,5 @@ from .read_sigel_wind_turbines import read_sigel_wind_turbines
|
|
135
135
|
from .read_sigel_windpower_transmission_lines import read_sigel_windpower_transmission_lines
|
136
136
|
from .read_sigel_hydroelectric_developments import read_sigel_hydroelectric_developments
|
137
137
|
from .read_sigel_windpower_polygons import read_sigel_windpower_polygons
|
138
|
-
from .read_sigel_thermoelectric_plants import read_sigel_thermoelectric_plants
|
138
|
+
from .read_sigel_thermoelectric_plants import read_sigel_thermoelectric_plants
|
139
|
+
from .read_drainage_ducts import read_drainage_ducts
|
@@ -5,13 +5,11 @@ import requests
|
|
5
5
|
from zipfile import ZipFile
|
6
6
|
from io import BytesIO
|
7
7
|
import urllib3
|
8
|
-
import time
|
9
|
-
from pathlib import Path
|
10
8
|
|
11
|
-
def read_quilombola_areas(simplified=False
|
9
|
+
def read_quilombola_areas(simplified=False):
|
12
10
|
"""Download Quilombola Areas data from INCRA.
|
13
11
|
|
14
|
-
This function downloads and processes data about Quilombola Areas (Áreas Quilombolas)
|
12
|
+
This function downloads and processes data about Quilombola Areas (Áreas Quilombolas)
|
15
13
|
in Brazil. These are territories recognized and titled to remaining quilombo communities.
|
16
14
|
Original source: INCRA - Instituto Nacional de Colonização e Reforma Agrária
|
17
15
|
|
@@ -19,9 +17,6 @@ def read_quilombola_areas(simplified=False, local_file=None):
|
|
19
17
|
----------
|
20
18
|
simplified : boolean, by default False
|
21
19
|
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
20
|
|
26
21
|
Returns
|
27
22
|
-------
|
@@ -46,57 +41,54 @@ def read_quilombola_areas(simplified=False, local_file=None):
|
|
46
41
|
|
47
42
|
# Read Quilombola Areas data
|
48
43
|
>>> 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
44
|
"""
|
53
45
|
|
54
46
|
url = "https://certificacao.incra.gov.br/csv_shp/zip/Áreas%20de%20Quilombolas.zip"
|
55
47
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
48
|
+
try:
|
49
|
+
# Download the zip file
|
50
|
+
# Disable SSL verification due to INCRA's certificate issues
|
51
|
+
response = requests.get(url, verify=False)
|
52
|
+
if response.status_code != 200:
|
53
|
+
raise Exception("Failed to download data from INCRA")
|
54
|
+
|
55
|
+
# Suppress the InsecureRequestWarning
|
56
|
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
57
|
+
|
58
|
+
# Create a temporary directory
|
59
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
60
|
+
# Extract the zip file
|
61
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
62
|
+
zip_ref.extractall(temp_dir)
|
63
|
+
|
64
|
+
# Find the shapefile
|
65
|
+
shp_files = [f for f in os.listdir(temp_dir) if f.endswith('.shp')]
|
66
|
+
if not shp_files:
|
67
|
+
raise Exception("No shapefile found in the downloaded data")
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
# Read the shapefile
|
70
|
+
gdf = gpd.read_file(os.path.join(temp_dir, shp_files[0]))
|
71
|
+
gdf = gdf.to_crs(4674) # Convert to SIRGAS 2000
|
72
|
+
|
73
|
+
if simplified:
|
74
|
+
# Keep only the most relevant columns
|
75
|
+
columns_to_keep = [
|
76
|
+
'geometry',
|
77
|
+
'nome', # Area name
|
78
|
+
'municipio', # Municipality
|
79
|
+
'uf', # State
|
80
|
+
'area_ha', # Area in hectares
|
81
|
+
'fase' # Current phase
|
82
|
+
]
|
75
83
|
|
76
|
-
|
77
|
-
|
78
|
-
|
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)}")
|
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]
|
96
87
|
|
97
|
-
|
98
|
-
|
99
|
-
|
88
|
+
except Exception as e:
|
89
|
+
raise Exception(f"Error downloading Quilombola Areas data: {str(e)}")
|
90
|
+
|
91
|
+
return gdf
|
100
92
|
|
101
93
|
if __name__ == '__main__':
|
102
94
|
quilombos = read_quilombola_areas()
|
@@ -1,8 +1,8 @@
|
|
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.18.dist-info/METADATA,sha256=0REjnixXDIlXgmgKPHUUd97T6sEfy3TfM7tV1qH1VIs,5019
|
2
|
+
tunned_geobr-1.0.18.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
tunned_geobr-1.0.18.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
tunned_geobr-1.0.18.dist-info/licenses/LICENSE.txt,sha256=mECZRcbde3HssOKe1Co4zgqBLGVN0OWpTsEy3LIbcRA,75
|
5
|
+
tunned_geobr/__init__.py,sha256=8STl_F6A8JWqePcb22E5eW-_EZ5Ln_tOnkCsjlrVOFc,8045
|
6
6
|
tunned_geobr/data/grid_state_correspondence_table.csv,sha256=FpkBuX_-lRXQ1yBrQODxQgG9oha9Fd8A8zGKfdsDAmk,2660
|
7
7
|
tunned_geobr/list_geobr.py,sha256=JXQeF8bKmXlNVOHUyNKaYgOtLZQ9e2mb2b2PSLfzIhU,18426
|
8
8
|
tunned_geobr/lookup_muni.py,sha256=ny1zU4i6OagvL4Mrc6XQWPgn2RrJa_mXlKXh81oVYsM,3462
|
@@ -118,7 +118,7 @@ tunned_geobr/read_private_aerodromes.py,sha256=Il9sfvBxDM-Xv6fkvOXYfaFLfjOaHlIw-
|
|
118
118
|
tunned_geobr/read_processing_facilities.py,sha256=8iCveDTk7MXm1bmb1pcknzen62HTGYQ3KEzvUGSdWfk,5349
|
119
119
|
tunned_geobr/read_production_fields.py,sha256=yw1g6u4kLGgiFwEbIcoj2IxvGGcT6u8sASqM2RRNk1Q,3182
|
120
120
|
tunned_geobr/read_public_aerodromes.py,sha256=nq3b9HF5_e-yeNcSfQ5ktdAGHKbSfDD_imj-tOhjKJA,2909
|
121
|
-
tunned_geobr/read_quilombola_areas.py,sha256=
|
121
|
+
tunned_geobr/read_quilombola_areas.py,sha256=hJFcj23Msh7pCaxQgAkgOefbgi228bnezrW7jZgykyY,3385
|
122
122
|
tunned_geobr/read_railways.py,sha256=J6eM0yr049CaOL95PMd4sGc7JJHiEinJhqf0ThCOClg,2763
|
123
123
|
tunned_geobr/read_region.py,sha256=X7IwsAVxwUl0apsExSuBr9kIK_7IUehPenLXAF-JFDA,2331
|
124
124
|
tunned_geobr/read_rppn.py,sha256=nXDzclIiqhutkYWvxlIH_mYSNGdfRVSUzSzi-15X-3w,3963
|
@@ -146,4 +146,4 @@ tunned_geobr/read_water_bodies_ana.py,sha256=Z-dpTPVgRHVndTeSFxx8uXn7ufMg2jm0Dlz
|
|
146
146
|
tunned_geobr/read_waterways.py,sha256=mEdoVogYWr5EYZ8bE3xMCVWyLrHYU7xTL2lUE0XbDAM,2951
|
147
147
|
tunned_geobr/read_weighting_area.py,sha256=m2X5Ua3jRqLlkqCQbIzR2jmo58pzqkyR3UYcGtgy20E,2325
|
148
148
|
tunned_geobr/utils.py,sha256=WT9PSGWvcERjj3yhfTvyWSE5ZiEjO4tYK5xIj5jJCg8,8170
|
149
|
-
tunned_geobr-1.0.
|
149
|
+
tunned_geobr-1.0.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|