Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active January 28, 2026 22:37
Show Gist options
  • Select an option

  • Save ThomasG77/39b3a5b09c120c90095385bf53d2691f to your computer and use it in GitHub Desktop.

Select an option

Save ThomasG77/39b3a5b09c120c90095385bf53d2691f to your computer and use it in GitHub Desktop.
OGC WFS consumption URLs from a service
from owslib.wfs import WebFeatureService
url = 'https://ahocevar.com/geoserver/wfs'
wfs20 = WebFeatureService(url=url, version='2.0.0')
outputFormats = wfs20.getOperationByName('GetFeature').parameters.get('outputFormat').get('values')
for name, contentMetadata in wfs20.items():
for outputFormat in outputFormats:
print(wfs20.getGETGetFeatureRequest(name) + f'&OUTPUTFORMAT={quote(outputFormat)}', name, contentMetadata.title, contentMetadata.id, contentMetadata.abstract)
//const { WfsEndpoint } = await import("@camptocamp/ogc-client");
import { WfsEndpoint } from '@camptocamp/ogc-client';
const url = 'https://ahocevar.com/geoserver/wfs'
let endpoint = new WfsEndpoint(url);
await endpoint.isReady();
const ogc_version = endpoint.getVersion()
const getFeatureUrl = endpoint.getOperationUrl('GetFeature')
const serviceInfo = endpoint.getServiceInfo()
const outputFormats = serviceInfo.outputFormats
const layerName = 'topp:states'
const downloadUrl = endpoint.getFeatureUrl(layerName) + '&OUTPUTFORMAT=SHAPE-ZIP'
endpoint.getFeatureTypes().forEach(layer => {
for (const outputFormat of outputFormats) {
console.log([endpoint.getFeatureUrl(layer.name) + `&OUTPUTFORMAT=${outputFormat}`, layer.name, layer.title, layer.abstract])
}
})
//console.log(endpoint.getServiceInfo())
//console.log(endpoint.getFeatureTypes())
{
"name": "wfs-ogc",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "wfs-ogc",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@camptocamp/ogc-client": "^1.3.0"
}
},
"node_modules/@camptocamp/ogc-client": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@camptocamp/ogc-client/-/ogc-client-1.3.0.tgz",
"integrity": "sha512-E1g11pBbVyWRudlWMVJrHtSfwK6nvCP0bLy8+RyCWLjlEEg92BICKep1Eg/daS/0d2Gjxlpnr1/aXowvvnosMA==",
"license": "BSD-3-Clause",
"dependencies": {
"@rgrove/parse-xml": "^4.1.0",
"node-fetch": "^3.3.1"
},
"peerDependencies": {
"ol": ">5.x",
"proj4": ">2.8"
},
"peerDependenciesMeta": {
"ol": {
"optional": true
},
"proj4": {
"optional": true
}
}
},
"node_modules/@rgrove/parse-xml": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@rgrove/parse-xml/-/parse-xml-4.2.0.tgz",
"integrity": "sha512-UuBOt7BOsKVOkFXRe4Ypd/lADuNIfqJXv8GvHqtXaTYXPPKkj2nS2zPllVsrtRjcomDhIJVBnZwfmlI222WH8g==",
"license": "ISC",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
},
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"license": "MIT",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"deprecated": "Use your platform's native DOMException instead",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-fetch": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
"license": "MIT",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/web-streams-polyfill": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
"license": "MIT",
"engines": {
"node": ">= 8"
}
}
}
}
{
"name": "wfs-ogc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"dependencies": {
"@camptocamp/ogc-client": "^1.3.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment