tunned-geobr 0.2.6__tar.gz → 0.2.7__tar.gz
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-0.2.6 → tunned_geobr-0.2.7}/PKG-INFO +1 -1
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/pyproject.toml +1 -1
- tunned_geobr-0.2.7/tunned_geobr/read_municipality.py +127 -0
- tunned_geobr-0.2.7/tunned_geobr/read_state.py +103 -0
- tunned_geobr-0.2.6/tunned_geobr/read_municipality.py +0 -83
- tunned_geobr-0.2.6/tunned_geobr/read_state.py +0 -88
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/LICENSE.txt +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/README.md +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/__init__.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/read_state.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_list_geobr.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_lookup_muni.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_amazon.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_biomes.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_census_tract.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_comparable_areas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_conservation_units.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_country.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_disaster_risk_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_health_facilities.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_health_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_immediate_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_indigenous_land.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_intermediate_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_meso_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_metro_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_micro_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_municipal_seat.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_municipality.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_neighborhood.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_pop_arrangements.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_schools.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_semiarid.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_state.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_statistical_grid.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_urban_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_urban_concentrations.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_read_weighting_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tests/test_utils.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/__init__.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/data/grid_state_correspondence_table.csv +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/list_geobr.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/lookup_muni.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_ama_anemometric_towers.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_amazon.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_amazon_ibas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_apcb_amazon.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_apcb_caatinga.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_apcb_cerrado_pantanal.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_apcb_mata_atlantica.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_apcb_pampa.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_apcb_zcm.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_archaeological_sites.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_areas_under_contract.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_atlantic_forest_ibas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_atlantic_forest_law_limits.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_baze_sites.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_biodiesel_plants.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_biomes.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_biomethane_plants.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_biosphere_reserves.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_cave_potential.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_census_tract.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_climate_aggressiveness.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_comparable_areas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_compression_stations.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_conservation_units.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_country.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_disaster_risk_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_drainage_ducts.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_ebas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_etanol_plants.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_biomass_ute.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_cgh.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_eolic.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_fossile_ute.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_nuclear_ute.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_pch.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_solar.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_substations.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_transmission_lines.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_existent_uhe.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_exploration_production_environment.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_federal_highways.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_federal_union_areas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_fossil_occurrences.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_fuel_bases.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_gas_distribution_pipelines.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_gas_transport_pipelines.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_geographic_regions.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_geology.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_geomorphology.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_glp_bases.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_gnl_terminals.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_health_facilities.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_health_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_heliports.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_hydroelectric_feasibility_studies.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_hydroelectric_inventory_aai_studies.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_immediate_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_indigenous_land.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_intermediate_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_isolated_systems.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_meso_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_metro_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_micro_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_mining_processes.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_municipal_seat.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_municipality_direct.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_natural_caves.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_natural_gas_delivery_points.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_natural_gas_processing_hub.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_neighborhood.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_neighborhoods_2022.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_basement.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_effective_geographic_basin.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_ipa_direct_evidence.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_ipa_exploratory_activity.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_ipa_exploratory_intensity.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_ipa_need_for_knowledge.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_ipa_prospectiveness.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_ipa_supply_infrastructure.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_legal_pre_salt_polygon.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_predominant_fluid_type.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_probabilistic_effective_basin.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_total_ipa.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_unconventional_resources.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_oil_and_derivatives_terminal.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_pan_strategic_areas 2.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_pan_strategic_areas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_pedology.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_pio_ducts.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_pio_terminals.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_biomass_ute.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_cgh.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_eolic.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_fossile_ute.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_nuclear_ute.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_pch.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_solar.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_substations.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_transmission_lines.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_planned_uhe.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_pop_arrangements.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_ports.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_private_aerodromes.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_processing_facilities.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_public_aerodromes.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_quilombola_areas.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_railways.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_region.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_rppn.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_schools.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_sedimentary_basins.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_semiarid.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_settlements.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_sigef_properties.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_snci_properties.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_state_direct.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_state_highways.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_statistical_grid.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_subsystem_interconnected.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_transmission_lines_ons.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_urban_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_urban_concentrations.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_vegetation.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_water_bodies_ana.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_waterways.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_weighting_area.py +0 -0
- {tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/utils.py +0 -0
@@ -0,0 +1,127 @@
|
|
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_municipality(code_muni="all", simplified=False):
|
9
|
+
"""Download shapefiles of Brazilian municipalities as geopandas objects.
|
10
|
+
|
11
|
+
This function downloads and processes municipality data directly from IBGE (Brazilian Institute of Geography and Statistics).
|
12
|
+
Data uses Geodetic reference system "SIRGAS2000" and CRS(4674).
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
code_muni : str, optional
|
17
|
+
The 7-digit code of a municipality. If the two-digit code or a two-letter uppercase abbreviation of
|
18
|
+
a state is passed, (e.g. 33 or "RJ") the function will load all municipalities of that state.
|
19
|
+
If code_muni="all", all municipalities of the country will be loaded (Default).
|
20
|
+
simplified : boolean, by default True
|
21
|
+
If True, returns a simplified version of the dataset with fewer columns
|
22
|
+
|
23
|
+
Returns
|
24
|
+
-------
|
25
|
+
gpd.GeoDataFrame
|
26
|
+
Geodataframe with municipality boundaries
|
27
|
+
|
28
|
+
Example
|
29
|
+
-------
|
30
|
+
>>> from tunned_geobr import read_municipality
|
31
|
+
|
32
|
+
# Read all municipalities
|
33
|
+
>>> municipalities = read_municipality()
|
34
|
+
|
35
|
+
# Read all municipalities in a state by code
|
36
|
+
>>> state_municipalities = read_municipality(code_muni=33)
|
37
|
+
|
38
|
+
# Read all municipalities in a state by abbreviation
|
39
|
+
>>> state_municipalities = read_municipality(code_muni="RJ")
|
40
|
+
|
41
|
+
# Read specific municipality by code
|
42
|
+
>>> municipality = read_municipality(code_muni=3304557)
|
43
|
+
"""
|
44
|
+
|
45
|
+
url = "https://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2023/Brasil/BR_Municipios_2023.zip"
|
46
|
+
|
47
|
+
try:
|
48
|
+
# Download the zip file
|
49
|
+
response = requests.get(url)
|
50
|
+
if response.status_code != 200:
|
51
|
+
raise Exception("Failed to download municipality data from IBGE")
|
52
|
+
|
53
|
+
# Create a temporary directory
|
54
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
55
|
+
# Extract the zip file
|
56
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
57
|
+
zip_ref.extractall(temp_dir)
|
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
|
+
# Filter by code_muni if not "all"
|
75
|
+
if code_muni != "all":
|
76
|
+
if isinstance(code_muni, int) or code_muni.isdigit():
|
77
|
+
if len(str(code_muni)) == 7:
|
78
|
+
# Filter by municipality code
|
79
|
+
gdf = gdf[gdf['CD_MUN'] == str(code_muni)]
|
80
|
+
elif len(str(code_muni)) == 2:
|
81
|
+
# Filter by state code
|
82
|
+
gdf = gdf[gdf['CD_MUN'].str.startswith(str(code_muni).zfill(2))]
|
83
|
+
elif isinstance(code_muni, str) and len(code_muni) == 2:
|
84
|
+
# Filter by state abbreviation - need to get state code first
|
85
|
+
state_url = "https://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2023/Brasil/BR_UF_2023.zip"
|
86
|
+
state_response = requests.get(state_url)
|
87
|
+
|
88
|
+
if state_response.status_code == 200:
|
89
|
+
with tempfile.TemporaryDirectory() as state_temp_dir:
|
90
|
+
with ZipFile(BytesIO(state_response.content)) as zip_ref:
|
91
|
+
zip_ref.extractall(state_temp_dir)
|
92
|
+
|
93
|
+
state_shp_files = []
|
94
|
+
for root, dirs, files in os.walk(state_temp_dir):
|
95
|
+
state_shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
96
|
+
|
97
|
+
if state_shp_files:
|
98
|
+
state_gdf = gpd.read_file(state_shp_files[0])
|
99
|
+
state_code = state_gdf[state_gdf['SIGLA_UF'] == code_muni.upper()]['CD_UF'].values
|
100
|
+
|
101
|
+
if len(state_code) > 0:
|
102
|
+
gdf = gdf[gdf['CD_MUN'].str.startswith(state_code[0])]
|
103
|
+
|
104
|
+
if len(gdf) == 0:
|
105
|
+
raise Exception(f"No data found for code_muni={code_muni}")
|
106
|
+
|
107
|
+
if simplified:
|
108
|
+
# Keep only the most relevant columns
|
109
|
+
columns_to_keep = [
|
110
|
+
'geometry',
|
111
|
+
'CD_MUN', # Municipality code
|
112
|
+
'NM_MUN', # Municipality name
|
113
|
+
'SIGLA_UF', # State abbreviation
|
114
|
+
'AREA_KM2' # Area in square kilometers
|
115
|
+
]
|
116
|
+
|
117
|
+
# Filter columns that actually exist in the dataset
|
118
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
119
|
+
gdf = gdf[existing_columns]
|
120
|
+
|
121
|
+
except Exception as e:
|
122
|
+
raise Exception(f"Error downloading municipality data: {str(e)}")
|
123
|
+
|
124
|
+
return gdf
|
125
|
+
|
126
|
+
if __name__ == '__main__':
|
127
|
+
read_municipality()
|
@@ -0,0 +1,103 @@
|
|
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_state(code_state="all", simplified=False):
|
9
|
+
"""Download shapefiles of Brazilian states as geopandas objects.
|
10
|
+
|
11
|
+
This function downloads and processes state data directly from IBGE (Brazilian Institute of Geography and Statistics).
|
12
|
+
Data uses Geodetic reference system "SIRGAS2000" and CRS(4674).
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
code_state : str, optional
|
17
|
+
The two-digit code of a state or a two-letter uppercase abbreviation
|
18
|
+
(e.g. 33 or "RJ"). If code_state="all", all states will be loaded (Default).
|
19
|
+
simplified : boolean, by default True
|
20
|
+
If True, returns a simplified version of the dataset with fewer columns
|
21
|
+
|
22
|
+
Returns
|
23
|
+
-------
|
24
|
+
gpd.GeoDataFrame
|
25
|
+
Geodataframe with state boundaries
|
26
|
+
|
27
|
+
Example
|
28
|
+
-------
|
29
|
+
>>> from tunned_geobr import read_state
|
30
|
+
|
31
|
+
# Read all states
|
32
|
+
>>> states = read_state()
|
33
|
+
|
34
|
+
# Read specific state by code
|
35
|
+
>>> state = read_state(code_state=33)
|
36
|
+
|
37
|
+
# Read specific state by abbreviation
|
38
|
+
>>> state = read_state(code_state="RJ")
|
39
|
+
"""
|
40
|
+
|
41
|
+
url = "https://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2023/Brasil/BR_UF_2023.zip"
|
42
|
+
|
43
|
+
try:
|
44
|
+
# Download the zip file
|
45
|
+
response = requests.get(url)
|
46
|
+
if response.status_code != 200:
|
47
|
+
raise Exception("Failed to download state data from IBGE")
|
48
|
+
|
49
|
+
# Create a temporary directory
|
50
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
51
|
+
# Extract the zip file
|
52
|
+
with ZipFile(BytesIO(response.content)) as zip_ref:
|
53
|
+
zip_ref.extractall(temp_dir)
|
54
|
+
|
55
|
+
# Find the shapefile
|
56
|
+
shp_files = []
|
57
|
+
for root, dirs, files in os.walk(temp_dir):
|
58
|
+
shp_files.extend([os.path.join(root, f) for f in files if f.endswith('.shp')])
|
59
|
+
|
60
|
+
if not shp_files:
|
61
|
+
raise Exception("No shapefile found in the downloaded data")
|
62
|
+
|
63
|
+
# Read the shapefile
|
64
|
+
gdf = gpd.read_file(shp_files[0])
|
65
|
+
|
66
|
+
# Convert to SIRGAS 2000 (EPSG:4674) if not already
|
67
|
+
if gdf.crs is None or gdf.crs.to_epsg() != 4674:
|
68
|
+
gdf = gdf.to_crs(4674)
|
69
|
+
|
70
|
+
# Filter by code_state if not "all"
|
71
|
+
if code_state != "all":
|
72
|
+
if isinstance(code_state, int) or code_state.isdigit():
|
73
|
+
# Filter by numeric code
|
74
|
+
code = str(code_state).zfill(2)
|
75
|
+
gdf = gdf[gdf['CD_UF'] == code]
|
76
|
+
elif isinstance(code_state, str) and len(code_state) == 2:
|
77
|
+
# Filter by state abbreviation
|
78
|
+
gdf = gdf[gdf['SIGLA_UF'] == code_state.upper()]
|
79
|
+
|
80
|
+
if len(gdf) == 0:
|
81
|
+
raise Exception(f"No data found for code_state={code_state}")
|
82
|
+
|
83
|
+
if simplified:
|
84
|
+
# Keep only the most relevant columns
|
85
|
+
columns_to_keep = [
|
86
|
+
'geometry',
|
87
|
+
'CD_UF', # State code
|
88
|
+
'SIGLA_UF', # State abbreviation
|
89
|
+
'NM_UF', # State name
|
90
|
+
'AREA_KM2' # Area in square kilometers
|
91
|
+
]
|
92
|
+
|
93
|
+
# Filter columns that actually exist in the dataset
|
94
|
+
existing_columns = ['geometry'] + [col for col in columns_to_keep[1:] if col in gdf.columns]
|
95
|
+
gdf = gdf[existing_columns]
|
96
|
+
|
97
|
+
except Exception as e:
|
98
|
+
raise Exception(f"Error downloading state data: {str(e)}")
|
99
|
+
|
100
|
+
return gdf
|
101
|
+
|
102
|
+
if __name__ == '__main__':
|
103
|
+
read_state()
|
@@ -1,83 +0,0 @@
|
|
1
|
-
from geobr.utils import select_metadata, download_gpkg
|
2
|
-
|
3
|
-
|
4
|
-
def read_municipality(code_muni="all", year=2010, simplified=False, verbose=False):
|
5
|
-
"""Download shape files of Brazilian municipalities as sf objects.
|
6
|
-
|
7
|
-
Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
|
8
|
-
|
9
|
-
Parameters
|
10
|
-
----------
|
11
|
-
code_muni:
|
12
|
-
The 7-digit code of a municipality. If the two-digit code or a two-letter uppercase abbreviation of
|
13
|
-
a state is passed, (e.g. 33 or "RJ") the function will load all municipalities of that state.
|
14
|
-
If code_muni="all", all municipalities of the country will be loaded.
|
15
|
-
year : int, optional
|
16
|
-
Year of the data, by default 2010
|
17
|
-
simplified: boolean, by default True
|
18
|
-
Data 'type', indicating whether the function returns the 'original' dataset
|
19
|
-
with high resolution or a dataset with 'simplified' borders (Default)
|
20
|
-
verbose : bool, optional
|
21
|
-
by default False
|
22
|
-
|
23
|
-
Returns
|
24
|
-
-------
|
25
|
-
gpd.GeoDataFrame
|
26
|
-
Metadata and geopackage of selected states
|
27
|
-
|
28
|
-
Raises
|
29
|
-
------
|
30
|
-
Exception
|
31
|
-
If parameters are not found or not well defined
|
32
|
-
|
33
|
-
Example
|
34
|
-
-------
|
35
|
-
>>> from geobr import read_municipality
|
36
|
-
|
37
|
-
# Read specific meso region at a given year
|
38
|
-
>>> df = read_municipality(code_muni=1200179, year=2018)
|
39
|
-
|
40
|
-
# Read all meso regions of a state at a given year
|
41
|
-
>>> df = read_municipality(code_muni=12, year=2017)
|
42
|
-
>>> df = read_municipality(code_muni="AM", year=2000)
|
43
|
-
|
44
|
-
# Read all meso regions of the country at a given year
|
45
|
-
>>> df = read_municipality(code_muni="all", year=2010)
|
46
|
-
"""
|
47
|
-
|
48
|
-
metadata = select_metadata("municipality", year=year, simplified=simplified)
|
49
|
-
|
50
|
-
if year < 1992:
|
51
|
-
|
52
|
-
return download_gpkg(metadata)
|
53
|
-
|
54
|
-
if code_muni == "all":
|
55
|
-
|
56
|
-
if verbose:
|
57
|
-
print("Loading data for the whole country. This might take a few minutes.")
|
58
|
-
|
59
|
-
return download_gpkg(metadata)
|
60
|
-
|
61
|
-
metadata = metadata[
|
62
|
-
metadata[["code", "code_abbrev"]].apply(
|
63
|
-
lambda x: str(code_muni)[:2] in str(x["code"])
|
64
|
-
or str(code_muni)[:2] # if number e.g. 12
|
65
|
-
in str(x["code_abbrev"]), # if UF e.g. RO
|
66
|
-
1,
|
67
|
-
)
|
68
|
-
]
|
69
|
-
|
70
|
-
if not len(metadata):
|
71
|
-
raise Exception("Invalid Value to argument code_muni.")
|
72
|
-
|
73
|
-
gdf = download_gpkg(metadata)
|
74
|
-
|
75
|
-
if len(str(code_muni)) == 2:
|
76
|
-
return gdf
|
77
|
-
|
78
|
-
elif code_muni in gdf["code_muni"].tolist():
|
79
|
-
return gdf.query(f"code_muni == {code_muni}")
|
80
|
-
|
81
|
-
else:
|
82
|
-
raise Exception("Invalid Value to argument code_muni.")
|
83
|
-
return gdf
|
@@ -1,88 +0,0 @@
|
|
1
|
-
import geopandas as gpd
|
2
|
-
|
3
|
-
from geobr.utils import select_metadata, download_gpkg
|
4
|
-
|
5
|
-
|
6
|
-
def read_state(code_state="all", year=2010, simplified=False, verbose=False):
|
7
|
-
"""Download shapefiles of Brazilian states as geopandas objects.
|
8
|
-
|
9
|
-
Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
|
10
|
-
|
11
|
-
Parameters
|
12
|
-
----------
|
13
|
-
code_state : str, optional
|
14
|
-
The two-digit code of a state or a two-letter uppercase abbreviation
|
15
|
-
(e.g. 33 or "RJ"). If code_state="all", all states will be loaded (Default).
|
16
|
-
year : int, optional
|
17
|
-
Year of the data, by default 2010
|
18
|
-
simplified: boolean, by default True
|
19
|
-
Data 'type', indicating whether the function returns the 'original' dataset
|
20
|
-
with high resolution or a dataset with 'simplified' borders (Default)
|
21
|
-
verbose : bool, optional
|
22
|
-
by default False
|
23
|
-
|
24
|
-
Returns
|
25
|
-
-------
|
26
|
-
gpd.GeoDataFrame
|
27
|
-
Metadata and geopackage of selected states
|
28
|
-
|
29
|
-
Raises
|
30
|
-
------
|
31
|
-
Exception
|
32
|
-
If parameters are not found or not well defined
|
33
|
-
|
34
|
-
Example
|
35
|
-
-------
|
36
|
-
>>> from geobr import read_state
|
37
|
-
|
38
|
-
# Read specific state at a given year
|
39
|
-
>>> uf = read_state(code_state=12, year=2017)
|
40
|
-
|
41
|
-
# Read specific state at a given year with normal geopackages
|
42
|
-
>>> uf = read_state(code_state="SC", year=2000, tp='normal')
|
43
|
-
|
44
|
-
# Read all states at a given year
|
45
|
-
>>> ufs = read_state(code_state="all", year=2010)
|
46
|
-
"""
|
47
|
-
|
48
|
-
metadata = select_metadata("state", year=year, simplified=simplified)
|
49
|
-
|
50
|
-
if code_state is None:
|
51
|
-
raise Exception("Value to argument 'code_state' cannot be None")
|
52
|
-
|
53
|
-
# From 1872 to 1991 and all
|
54
|
-
if (year < 1992) or (code_state == "all"):
|
55
|
-
|
56
|
-
if verbose:
|
57
|
-
print("Loading data for the whole country\n")
|
58
|
-
|
59
|
-
return download_gpkg(metadata)
|
60
|
-
|
61
|
-
# From 2000 onwards
|
62
|
-
else:
|
63
|
-
|
64
|
-
if (
|
65
|
-
str(code_state)[0:2] not in metadata["code"].unique()
|
66
|
-
and str(code_state)[0:2] not in metadata["code_abbrev"].unique()
|
67
|
-
):
|
68
|
-
|
69
|
-
raise Exception("Error: Invalid Value to argument code_state.")
|
70
|
-
|
71
|
-
else:
|
72
|
-
|
73
|
-
if isinstance(code_state, int):
|
74
|
-
metadata = metadata.query(f'code == "{str(code_state)[0:2]}"')
|
75
|
-
|
76
|
-
if isinstance(code_state, str):
|
77
|
-
metadata = metadata.query(f'code_abbrev == "{code_state[0:2]}"')
|
78
|
-
|
79
|
-
gdf = download_gpkg(metadata)
|
80
|
-
|
81
|
-
if len(str(code_state)) == 2:
|
82
|
-
return gdf
|
83
|
-
|
84
|
-
elif code_state in list(gdf["code_state"]):
|
85
|
-
return gdf.query('code_state == "code_state"')
|
86
|
-
|
87
|
-
else:
|
88
|
-
raise Exception("Error: Invalid Value to argument code_state.")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/data/grid_state_correspondence_table.csv
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_exploration_production_environment.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_hydroelectric_feasibility_studies.py
RENAMED
File without changes
|
{tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_hydroelectric_inventory_aai_studies.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_effective_geographic_basin.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{tunned_geobr-0.2.6 → tunned_geobr-0.2.7}/tunned_geobr/read_og_probabilistic_effective_basin.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|