tunned-geobr 0.2.10__py3-none-any.whl → 1.0.1__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 +4 -2
- tunned_geobr/list_geobr.py +6 -1
- tunned_geobr/read_amazon.py +1 -1
- tunned_geobr/read_ibama_embargoes.py +85 -0
- tunned_geobr/read_icmbio_embargoes.py +83 -0
- tunned_geobr/read_icmbio_infractions.py +83 -0
- tunned_geobr/read_immediate_region.py +59 -71
- tunned_geobr/read_indigenous_land.py +66 -33
- tunned_geobr/read_intermediate_region.py +67 -59
- tunned_geobr/read_meso_region.py +60 -69
- tunned_geobr/read_micro_region.py +60 -69
- tunned_geobr/read_neighborhood.py +88 -28
- tunned_geobr/read_region.py +59 -21
- {tunned_geobr-0.2.10.dist-info → tunned_geobr-1.0.1.dist-info}/METADATA +1 -1
- {tunned_geobr-0.2.10.dist-info → tunned_geobr-1.0.1.dist-info}/RECORD +18 -16
- tunned_geobr/read_neighborhoods_2022.py +0 -99
- {tunned_geobr-0.2.10.dist-info → tunned_geobr-1.0.1.dist-info}/WHEEL +0 -0
- {tunned_geobr-0.2.10.dist-info → tunned_geobr-1.0.1.dist-info}/entry_points.txt +0 -0
- {tunned_geobr-0.2.10.dist-info → tunned_geobr-1.0.1.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,13 +1,13 @@
|
|
1
|
-
tunned_geobr-0.
|
2
|
-
tunned_geobr-0.
|
3
|
-
tunned_geobr-0.
|
4
|
-
tunned_geobr-0.
|
5
|
-
tunned_geobr/__init__.py,sha256=
|
1
|
+
tunned_geobr-1.0.1.dist-info/METADATA,sha256=wE3K7FyuqHYaAkuYveEmGfbR7fP8x726haqssiyCs4M,5018
|
2
|
+
tunned_geobr-1.0.1.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
tunned_geobr-1.0.1.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
tunned_geobr-1.0.1.dist-info/licenses/LICENSE.txt,sha256=mECZRcbde3HssOKe1Co4zgqBLGVN0OWpTsEy3LIbcRA,75
|
5
|
+
tunned_geobr/__init__.py,sha256=rxOGWhc2o3F8qDORi34uF4sCGouQFK74bKpuuAXWlHY,7393
|
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=6rsdtSZUvFrS-n5KXLOSQ34P1AK_yMFAj_MVZRvvZmQ,17278
|
8
8
|
tunned_geobr/lookup_muni.py,sha256=ny1zU4i6OagvL4Mrc6XQWPgn2RrJa_mXlKXh81oVYsM,3462
|
9
9
|
tunned_geobr/read_ama_anemometric_towers.py,sha256=M3qKBTBYdqHzTuWtRrBiLA88Ymt6g0cf7sakJd5mTRo,4686
|
10
|
-
tunned_geobr/read_amazon.py,sha256=
|
10
|
+
tunned_geobr/read_amazon.py,sha256=HiwKnYebWe3nDMDRUqHpKJIO76bA4ERm4iJlCPhagQg,1286
|
11
11
|
tunned_geobr/read_amazon_ibas.py,sha256=RtOo5wPfc26S2HYJCLylNCPM5cHBOLGTP4uKEtGC3Bw,3500
|
12
12
|
tunned_geobr/read_apcb_amazon.py,sha256=IQZc_hyDcwYtRkQmdJMuQuZVcCGeuF9S5p3xeOghUgo,2834
|
13
13
|
tunned_geobr/read_apcb_caatinga.py,sha256=n1oQttcKkUyuU835VfbR709yGEydm8lnorp_uBlV-Ws,2846
|
@@ -62,13 +62,16 @@ tunned_geobr/read_health_region.py,sha256=zGkoQZ_mf-snBEy00RUd3GF_pJu6PIoqvcbS_i
|
|
62
62
|
tunned_geobr/read_heliports.py,sha256=liLQ5J7UgHcxcsx7xpkh_4oxxh4rNz7hprTwnWSViw4,2791
|
63
63
|
tunned_geobr/read_hydroelectric_feasibility_studies.py,sha256=tyCD-VyYW1paJLoN8woO_sR4aFC8NIIRj_As0jrQSLE,4770
|
64
64
|
tunned_geobr/read_hydroelectric_inventory_aai_studies.py,sha256=GWnSzsnMJSDjSpXFHyQbYL3d8xTwqh9ilxxi2r61idE,4814
|
65
|
-
tunned_geobr/
|
66
|
-
tunned_geobr/
|
67
|
-
tunned_geobr/
|
65
|
+
tunned_geobr/read_ibama_embargoes.py,sha256=hzbWiifgoCgq7TP4X3H4TWFFkLnE5Y9969KUd3aJsek,3251
|
66
|
+
tunned_geobr/read_icmbio_embargoes.py,sha256=Xn3oxt4yK8wE6sAKWsU91EyU2h0yLysIbtQk2VUuJ5A,3107
|
67
|
+
tunned_geobr/read_icmbio_infractions.py,sha256=Heolqhuxc3sUby4RhxJZ88djIBWRcXkFbubhXgkpYos,3182
|
68
|
+
tunned_geobr/read_immediate_region.py,sha256=rxPfNYTvYM1n09KNJ1QkdLdXukvO6gZ4wU9IZP-Mum0,2465
|
69
|
+
tunned_geobr/read_indigenous_land.py,sha256=0QmsWQjq1RNS6GqF_vfPzTibBv09Qrxw-Mgg0GE9yzA,2839
|
70
|
+
tunned_geobr/read_intermediate_region.py,sha256=b-Txa79C5MIcQDUwudAorah4QFARM277-bhAgcQ7jOo,2513
|
68
71
|
tunned_geobr/read_isolated_systems.py,sha256=k0dxfUNubsJXV3_5ph1CWghR_Mfpn4oe_4zLkg7c5Cs,5343
|
69
|
-
tunned_geobr/read_meso_region.py,sha256=
|
72
|
+
tunned_geobr/read_meso_region.py,sha256=siwlqiZ9Q8XMmrEf4YjS6TJiQW0fsTq0udi2oByIiL0,2396
|
70
73
|
tunned_geobr/read_metro_area.py,sha256=e18jyXrRMwQTv_ZO2hGoyC8qZsV6NlYfWXsu6DusRQM,1498
|
71
|
-
tunned_geobr/read_micro_region.py,sha256=
|
74
|
+
tunned_geobr/read_micro_region.py,sha256=hs1NhVfb_LazLLp9EmLxQCDscPlkqqG-OjTv2fIGoFw,2412
|
72
75
|
tunned_geobr/read_mining_processes.py,sha256=UmywViEDD9hx7qcDj9CMRHdPM69NQhsRB4870Y77QSs,2569
|
73
76
|
tunned_geobr/read_municipal_seat.py,sha256=9Vi-q1jzY8n086O-nNY1sVkVzV_NZbdzE5juosCcVZI,1142
|
74
77
|
tunned_geobr/read_municipality.py,sha256=dZM1BVi3U9ZvasLADV-ciKVr9R4o92dRowpEVdVkvYw,5651
|
@@ -76,8 +79,7 @@ tunned_geobr/read_municipality_direct.py,sha256=VrZR_5__DsV5IbbX-sr56WT-P4M_tVdn
|
|
76
79
|
tunned_geobr/read_natural_caves.py,sha256=-XjoRxhT_yYy0fZu87S6RRUZ-cyaWPqWqOrd9Y8ERKo,3073
|
77
80
|
tunned_geobr/read_natural_gas_delivery_points.py,sha256=nJJmqbJJ5Xx2P2wVL9yXdGLuPI0O8pCCL9zDkHQtZOs,5387
|
78
81
|
tunned_geobr/read_natural_gas_processing_hub.py,sha256=qI5o-4TmPfi3h0gYNWjeMR5GsRAq-fsXoB62llqt9RA,5367
|
79
|
-
tunned_geobr/read_neighborhood.py,sha256=
|
80
|
-
tunned_geobr/read_neighborhoods_2022.py,sha256=EX1-5CM3tNe05HE1F5r3YtZ-66X_NC67u_DzrmzKvTc,3952
|
82
|
+
tunned_geobr/read_neighborhood.py,sha256=xM2Ztl2uvaQ4fLmO9lCboa-lqGoUNlo_OM_ktVqlOn0,3946
|
81
83
|
tunned_geobr/read_og_basement.py,sha256=nwUOn-BMYC3mvvP9uTBLYly00drIw6CwU5lHJeOdi-Y,4617
|
82
84
|
tunned_geobr/read_og_effective_geographic_basin.py,sha256=Qvy--_A8oGrL-Os3mfofr14MA0qWv3s5FFdtIabBJ8E,5457
|
83
85
|
tunned_geobr/read_og_ipa_direct_evidence.py,sha256=N5nDr7AinKFqhcfgnvygVjzpdN2D1TP5VSILS8gkIgU,4738
|
@@ -114,7 +116,7 @@ tunned_geobr/read_processing_facilities.py,sha256=8iCveDTk7MXm1bmb1pcknzen62HTGY
|
|
114
116
|
tunned_geobr/read_public_aerodromes.py,sha256=nq3b9HF5_e-yeNcSfQ5ktdAGHKbSfDD_imj-tOhjKJA,2909
|
115
117
|
tunned_geobr/read_quilombola_areas.py,sha256=iY-r4YDRjaGyO-iPRBm1kWDkN_-axjYxMAQyAjIfG68,4288
|
116
118
|
tunned_geobr/read_railways.py,sha256=J6eM0yr049CaOL95PMd4sGc7JJHiEinJhqf0ThCOClg,2763
|
117
|
-
tunned_geobr/read_region.py,sha256=
|
119
|
+
tunned_geobr/read_region.py,sha256=X7IwsAVxwUl0apsExSuBr9kIK_7IUehPenLXAF-JFDA,2331
|
118
120
|
tunned_geobr/read_rppn.py,sha256=nXDzclIiqhutkYWvxlIH_mYSNGdfRVSUzSzi-15X-3w,3963
|
119
121
|
tunned_geobr/read_schools.py,sha256=kxaRwuKmZDPgSuhCUd_Ltxo-6_z3b3jXY9Qo0MY_b-A,1364
|
120
122
|
tunned_geobr/read_sedimentary_basins.py,sha256=mpCde4-WRdAAuHF-AwrODd0GpxRhzJOuP60U6Zbl9pE,4583
|
@@ -135,4 +137,4 @@ tunned_geobr/read_water_bodies_ana.py,sha256=Z-dpTPVgRHVndTeSFxx8uXn7ufMg2jm0Dlz
|
|
135
137
|
tunned_geobr/read_waterways.py,sha256=mEdoVogYWr5EYZ8bE3xMCVWyLrHYU7xTL2lUE0XbDAM,2951
|
136
138
|
tunned_geobr/read_weighting_area.py,sha256=m2X5Ua3jRqLlkqCQbIzR2jmo58pzqkyR3UYcGtgy20E,2325
|
137
139
|
tunned_geobr/utils.py,sha256=WT9PSGWvcERjj3yhfTvyWSE5ZiEjO4tYK5xIj5jJCg8,8170
|
138
|
-
tunned_geobr-0.
|
140
|
+
tunned_geobr-1.0.1.dist-info/RECORD,,
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import geopandas as gpd
|
2
|
-
import tempfile
|
3
|
-
import os
|
4
|
-
import requests
|
5
|
-
import subprocess
|
6
|
-
from io import BytesIO
|
7
|
-
|
8
|
-
def read_neighborhoods_2022(simplified=False):
|
9
|
-
"""Download Brazilian Neighborhoods data from IBGE (2022 Census).
|
10
|
-
|
11
|
-
This function downloads and processes the Brazilian Neighborhoods data
|
12
|
-
from IBGE (Brazilian Institute of Geography and Statistics) for the 2022 Census.
|
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 neighborhoods data
|
24
|
-
|
25
|
-
Example
|
26
|
-
-------
|
27
|
-
>>> from tunned_geobr import read_neighborhoods_2022
|
28
|
-
|
29
|
-
# Read neighborhoods data
|
30
|
-
>>> neighborhoods = read_neighborhoods_2022()
|
31
|
-
"""
|
32
|
-
|
33
|
-
url = "https://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_de_setores_censitarios__divisoes_intramunicipais/censo_2022/bairros/shp/BR/BR_bairros_CD2022.zip"
|
34
|
-
|
35
|
-
try:
|
36
|
-
# Create a temporary directory
|
37
|
-
with tempfile.TemporaryDirectory() as temp_dir:
|
38
|
-
# Download the zip file to the temporary directory
|
39
|
-
zip_file_path = os.path.join(temp_dir, "neighborhoods.zip")
|
40
|
-
|
41
|
-
# Download the file
|
42
|
-
response = requests.get(url)
|
43
|
-
if response.status_code != 200:
|
44
|
-
raise Exception("Failed to download neighborhoods data from IBGE")
|
45
|
-
|
46
|
-
# Save the content to a file
|
47
|
-
with open(zip_file_path, 'wb') as f:
|
48
|
-
f.write(response.content)
|
49
|
-
|
50
|
-
# Use unzip command line tool to extract the file (handles more compression methods)
|
51
|
-
try:
|
52
|
-
subprocess.run(['unzip', '-o', zip_file_path, '-d', temp_dir],
|
53
|
-
check=True,
|
54
|
-
stdout=subprocess.PIPE,
|
55
|
-
stderr=subprocess.PIPE)
|
56
|
-
except subprocess.CalledProcessError as e:
|
57
|
-
raise Exception(f"Failed to extract zip file: {e.stderr.decode()}")
|
58
|
-
|
59
|
-
# Find the shapefile
|
60
|
-
shp_files = []
|
61
|
-
for root, dirs, files in os.walk(temp_dir):
|
62
|
-
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
63
|
-
|
64
|
-
if not shp_files:
|
65
|
-
raise Exception("No shapefile found in the downloaded data")
|
66
|
-
|
67
|
-
# Read the shapefile
|
68
|
-
gdf = gpd.read_file(shp_files[0])
|
69
|
-
|
70
|
-
# Convert to SIRGAS 2000 (EPSG:4674) if not already
|
71
|
-
if gdf.crs is None or gdf.crs.to_epsg() != 4674:
|
72
|
-
gdf = gdf.to_crs(4674)
|
73
|
-
|
74
|
-
if simplified:
|
75
|
-
# Keep only the most relevant columns
|
76
|
-
# Note: Column names may need adjustment based on actual data
|
77
|
-
columns_to_keep = [
|
78
|
-
'geometry',
|
79
|
-
'CD_BAIRRO', # Neighborhood Code
|
80
|
-
'NM_BAIRRO', # Neighborhood Name
|
81
|
-
'CD_MUN', # Municipality Code
|
82
|
-
'NM_MUN', # Municipality Name
|
83
|
-
'CD_UF', # State Code
|
84
|
-
'NM_UF', # State Name
|
85
|
-
'SIGLA_UF', # State Abbreviation
|
86
|
-
'AREA_KM2' # Area in square kilometers
|
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
|
-
except Exception as e:
|
94
|
-
raise Exception(f"Error downloading neighborhoods data: {str(e)}")
|
95
|
-
|
96
|
-
return gdf
|
97
|
-
|
98
|
-
if __name__ == '__main__':
|
99
|
-
read_neighborhoods_2022()
|
File without changes
|
File without changes
|
File without changes
|