CETESB¶
Script que cria uma tabela que apresenta informações das Agências Ambientais da CETESB que atuam nos 645 município deo Estado de São Paulo.
In [ ]:
Copied!
import tempfile
from pathlib import Path
import open_geodata as geo
import tempfile
from pathlib import Path
import open_geodata as geo
In [ ]:
Copied!
cetesb = geo.sp.cetesb.div_admin.CETESB()
cetesb
cetesb = geo.sp.cetesb.div_admin.CETESB()
cetesb
In [ ]:
Copied!
ag = cetesb.get_agencia_ambiental(municipio='Piracicaba')
ag['agencia']
ag = cetesb.get_agencia_ambiental(municipio='Piracicaba')
ag['agencia']
Nome dos Municípios¶
Carregamos o arquivo contendo o nome dos municípios, de acordo com a grafia da CETESB.
In [ ]:
Copied!
df = geo.data.load_dataset(db='sp', name='tab.municipio_cetesb')
df.head()
df = geo.data.load_dataset(db='sp', name='tab.municipio_cetesb')
df.head()
In [ ]:
Copied!
cetesb.get_all_agencias_adjusted()
cetesb.get_all_agencias_adjusted()
In [ ]:
Copied!
cetesb.get_only_agencias()
cetesb.get_only_agencias()
In [ ]:
Copied!
gdf = cetesb.get_geodataframe()
gdf.info()
gdf.head()
gdf = cetesb.get_geodataframe()
gdf.info()
gdf.head()
In [ ]:
Copied!
temp_path = Path(tempfile.gettempdir()) / 'open_geodata'
temp_path.mkdir(exist_ok=True)
temp_path = Path(tempfile.gettempdir()) / 'open_geodata'
temp_path.mkdir(exist_ok=True)
In [ ]:
Copied!
gdf.to_file(
temp_path / 'sp_cetesb.gpkg',
layer='sp_cetesb',
driver='GPKG',
)
gdf.to_file(
temp_path / 'sp_cetesb.geojson',
driver='GeoJSON',
encoding='utf-8',
)
gdf.to_file(
temp_path / 'sp_cetesb.gpkg',
layer='sp_cetesb',
driver='GPKG',
)
gdf.to_file(
temp_path / 'sp_cetesb.geojson',
driver='GeoJSON',
encoding='utf-8',
)
In [ ]:
Copied!
gdf.explore(column='agencia')
gdf.explore(column='agencia')
In [ ]:
Copied!