INPE¶
In [16]:
Copied!
import io
import geopandas as gpd
from owslib.wfs import WebFeatureService
import io
import geopandas as gpd
from owslib.wfs import WebFeatureService
In [ ]:
Copied!
wfs = WebFeatureService(
#
url='https://terrabrasilis.dpi.inpe.br/geoserver/ows',
version='2.0.0',
)
wfs = WebFeatureService(
#
url='https://terrabrasilis.dpi.inpe.br/geoserver/ows',
version='2.0.0',
)
In [18]:
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]
Existem 214 camadas disponíveis no serviço WFS.
Out[18]:
['ams1:active-fire', 'ams1:biome_border', 'ams1:cs_150km_diff_view', 'ams1:cs_150km_view', 'ams1:cs_25km_diff_view', 'ams1:cs_25km_view', 'ams1:cs_5km_diff_view', 'ams1:cs_5km_view', 'ams1:deter-ams', 'ams1:last_date']
In [19]:
Copied!
set([layer.split(':')[0] for layer in list_layers])
set([layer.split(':')[0] for layer in list_layers])
Out[19]:
{'ams1',
'ams1_auth',
'ams1h',
'ams1h_auth',
'ams2',
'ams2_auth',
'deter-amz',
'deter-cerrado-nb',
'prodes-amazon-nb',
'prodes-brasil-nb',
'prodes-caatinga-nb',
'prodes-cerrado-nb',
'prodes-legal-amz',
'prodes-mata-atlantica-nb',
'prodes-pampa-nb',
'prodes-pantanal-nb',
'tcc-samples',
'vegetation-cerrado'}
In [20]:
Copied!
# Obter os dados no formato GeoJSON (ou outro formato suportado)
response = wfs.getfeature(
typename='tcc-samples:depressao_carstica_do_sao_francisco',
# bbox=(173700, 440400, 178700, 441400),
# srsname='EPSG:28992'
# srsname='EPSG:4326',
srsname='EPSG:4674',
outputFormat='application/json',
)
response
# Obter os dados no formato GeoJSON (ou outro formato suportado)
response = wfs.getfeature(
typename='tcc-samples:depressao_carstica_do_sao_francisco',
# bbox=(173700, 440400, 178700, 441400),
# srsname='EPSG:28992'
# srsname='EPSG:4326',
srsname='EPSG:4674',
outputFormat='application/json',
)
response
Out[20]:
<_io.BytesIO at 0x246b9e0fb50>
In [21]:
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()
<class 'geopandas.geodataframe.GeoDataFrame'> RangeIndex: 1 entries, 0 to 0 Data columns (total 3 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 id 1 non-null object 1 name 1 non-null object 2 geometry 1 non-null geometry dtypes: geometry(1), object(2) memory usage: 156.0+ bytes
Out[21]:
| id | name | geometry | |
|---|---|---|---|
| 0 | depressao_carstica_do_sao_francisco.11 | Depressão Cárstica do São Francisco | MULTIPOLYGON (((-43.8257 -16.383, -43.8249 -16... |
In [22]:
Copied!
gdf.crs
gdf.crs
Out[22]:
<Geographic 2D CRS: EPSG:4674> Name: SIRGAS 2000 Axis Info [ellipsoidal]: - Lat[north]: Geodetic latitude (degree) - Lon[east]: Geodetic longitude (degree) Area of Use: - name: Latin America - Central America and South America - onshore and offshore. Brazil - onshore and offshore. - bounds: (-122.19, -59.87, -25.28, 32.72) Datum: Sistema de Referencia Geocentrico para las AmericaS 2000 - Ellipsoid: GRS 1980 - Prime Meridian: Greenwich
In [23]:
Copied!
gdf.explore()
gdf.explore()
Out[23]:
Make this Notebook Trusted to load map: File -> Trust Notebook