File size: 819 Bytes
1e66e59 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from owslib.wfs import WebFeatureService
# URL of the GeoServer's WFS endpoint
#wfs_url = 'https://www.chennaifloodsdss.in/geohorr/ChennaiDSS/ows'
wfs_url = 'https://geoserver.rimes.int:8443/geoserver/ows'
# Connect to the WFS
wfs = WebFeatureService(wfs_url, version='2.0.0') # Adjust version as per your server
# Get list of available layers
layers = list(wfs.contents)
print(layers)
# Define a function to retrieve data for a specific layer
def get_layer_data(layer_name):
output = wfs.getfeature(typename=layer_name)
with open(f'tngis/{layer_name}.gml', 'wb') as file:
file.write(output.read())
# Download data for each layer
for layer in layers:
print(f"Downloading data for layer: {layer}")
get_layer_data(layer)
print(f"Downloaded {layer}.gml")
print("Data download complete.")
|