In [14]:
Copied!
import io
from datetime import date, timedelta
import geopandas as gpd
from owslib.wfs import WebFeatureService
import io
from datetime import date, timedelta
import geopandas as gpd
from owslib.wfs import WebFeatureService
In [3]:
Copied!
wfs = WebFeatureService(
#
url='https://servicos.dnit.gov.br/dnitgeo/geoserver/ows',
version='2.0.0',
)
wfs = WebFeatureService(
#
url='https://servicos.dnit.gov.br/dnitgeo/geoserver/ows',
version='2.0.0',
)
In [ ]:
Copied!
list_layers = list(wfs.contents)
list_layers.sort()
print(f"Existem {len(list_layers)} camadas disponíveis no serviço WFS.")
# Display the first 10 layers
list_layers[0:10]
list_layers = list(wfs.contents)
list_layers.sort()
print(f"Existem {len(list_layers)} camadas disponíveis no serviço WFS.")
# Display the first 10 layers
list_layers[0:10]
In [ ]:
Copied!
# Obter os dados no formato GeoJSON (ou outro formato suportado)
response = wfs.getfeature(
typename='vgeo:3faixa_de_dominio_termo_de_arrolamento',
# bbox=(173700, 440400, 178700, 441400),
# srsname='EPSG:28992'
# srsname='EPSG:4326',
srsname='EPSG:31983',
outputFormat='application/json',
)
response
# Obter os dados no formato GeoJSON (ou outro formato suportado)
response = wfs.getfeature(
typename='vgeo:3faixa_de_dominio_termo_de_arrolamento',
# bbox=(173700, 440400, 178700, 441400),
# srsname='EPSG:28992'
# srsname='EPSG:4326',
srsname='EPSG:31983',
outputFormat='application/json',
)
response
In [ ]:
Copied!
gdf = gpd.read_file(filename=io.BytesIO(response.read()))
gdf.info()
gdf.head()
gdf = gpd.read_file(filename=io.BytesIO(response.read()))
gdf.info()
gdf.head()
In [ ]:
Copied!
gdf.crs
gdf.crs
In [ ]:
Copied!
gdf.explore()
gdf.explore()
Ainda há também um mapa online, onde é possível fazer o download dos dados. Esse mapa é alimentado pelo Geoserver.
DNIT Cloud¶
Alem do GeoServer do DNIT, há também o DNIT Cloud. O sistema foi feito com auxílio do framework NextCloud, utilizado para compartilhamento de arquivos.
Mesmo que não tenhamos usuário/senha, observei que é possível obter os dados, os quais estão indexados no buscador Google. O acesso, sem login, se dá clicando aqui.
Bases de Dados de Sistema Viário Nacional (SVN)
In [20]:
Copied!
# data_mes_passado = date.today() - timedelta(days=31)
# data_mes_passado = data_mes_passado.strftime('%Y%m')
# data_mes_passado
# data_mes_passado = date.today() - timedelta(days=31)
# data_mes_passado = data_mes_passado.strftime('%Y%m')
# data_mes_passado
In [19]:
Copied!
# SNV Bases Geométricas (2013-Atual) (SHP)
gdf = gpd.read_file(
filename=f'https://servicos.dnit.gov.br/dnitcloud/index.php/s/oTpPRmYs5AAdiNr/download?path=%2FSNV%20Bases%20Geom%C3%A9tricas%20(2013-Atual)%20(SHP)&files=202507A.zip'
)
# SNV Bases Geométricas (2013-Atual) (SHP)
gdf = gpd.read_file(
filename=f'https://servicos.dnit.gov.br/dnitcloud/index.php/s/oTpPRmYs5AAdiNr/download?path=%2FSNV%20Bases%20Geom%C3%A9tricas%20(2013-Atual)%20(SHP)&files=202507A.zip'
)
In [21]:
Copied!
# Filtra
gdf = gdf[gdf['sg_uf']== 'SP']
# Resultados
gdf.info()
gdf.head(2)
# Filtra
gdf = gdf[gdf['sg_uf']== 'SP']
# Resultados
gdf.info()
gdf.head(2)
<class 'geopandas.geodataframe.GeoDataFrame'> Index: 417 entries, 382 to 7491 Data columns (total 29 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 id_trecho_ 417 non-null int64 1 vl_br 417 non-null object 2 sg_uf 417 non-null object 3 nm_tipo_tr 417 non-null object 4 sg_tipo_tr 417 non-null object 5 desc_coinc 417 non-null object 6 vl_codigo 417 non-null object 7 ds_local_i 417 non-null object 8 ds_local_f 417 non-null object 9 vl_km_inic 417 non-null float64 10 vl_km_fina 417 non-null float64 11 vl_extensa 417 non-null float64 12 ds_sup_fed 417 non-null object 13 ds_obra 0 non-null object 14 ul 99 non-null object 15 ds_coinc 417 non-null object 16 ds_tipo_ad 417 non-null object 17 ds_ato_leg 0 non-null object 18 est_coinc 288 non-null object 19 sup_est_co 288 non-null object 20 ds_jurisdi 417 non-null object 21 ds_superfi 417 non-null object 22 ds_legenda 417 non-null object 23 sg_legenda 417 non-null object 24 leg_multim 417 non-null object 25 versao_snv 417 non-null object 26 id_versao 417 non-null int64 27 marcador 417 non-null object 28 geometry 417 non-null geometry dtypes: float64(3), geometry(1), int64(2), object(23) memory usage: 97.7+ KB
Out[21]:
| id_trecho_ | vl_br | sg_uf | nm_tipo_tr | sg_tipo_tr | desc_coinc | vl_codigo | ds_local_i | ds_local_f | vl_km_inic | ... | sup_est_co | ds_jurisdi | ds_superfi | ds_legenda | sg_legenda | leg_multim | versao_snv | id_versao | marcador | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 382 | 151457 | 050 | SP | Eixo Principal | B | - | 050BSP0290 | INÍCIO PONTE S/RIO GRANDE (DIV MG/SP-DELTA) | ACESSO OESTE IGARAPAVA | 0.0 | ... | DUP | Estadual | PLA | Planejada | PLA | Duplicada | 202507A | 80 | | | LINESTRING (-47.78832 -19.98376, -47.788 -19.9... |
| 383 | 151458 | 050 | SP | Eixo Principal | B | - | 050BSP0293 | ACESSO OESTE IGARAPAVA | ROD. JOSÉ TORREZAN (ARAMINA) | 6.8 | ... | DUP | Estadual | PLA | Planejada | PLA | Duplicada | 202507A | 80 | | | LINESTRING (-47.7809 -20.04464, -47.7815 -20.0... |
2 rows × 29 columns
In [22]:
Copied!
gdf.explore(column='ds_jurisdi', tiles='Esri.WorldImagery')
gdf.explore(column='ds_jurisdi', tiles='Esri.WorldImagery')
Out[22]:
Make this Notebook Trusted to load map: File -> Trust Notebook