Skip to main content

WFS — Web Feature Service

The WFS (Web Feature Service) allows you to retrieve raw geographic features from GeoServer layers. Use WFS to download features as GeoJSON, filter by spatial or attribute criteria, and integrate feature data into your applications.

All requests go to: https://graph.quarticle.ro/graph/layers/wfs/

Authentication: Add the Authorization: YOUR_API_KEY header to all requests.


GetFeature

Retrieve geographic features from a WFS layer.

Required Parameters

ParameterDescriptionExample
serviceWFSWFS
versionWFS version2.0.0
requestGetFeatureGetFeature
typeNamesLayer name(s)GRAPHRASTER:light_pollution

Optional Parameters

Filtering

ParameterDescriptionExample
featureIDReturn only features with specific IDnamespace:layername.id
bboxSpatial filter: minx,miny,maxx,maxy,SRS2554219.59,5763351.78,2554220.89,5763352.09,EPSG:3857
cql_filterGeoServer CQL filter expressionpopulation > 1000000
filterOGC Filter XML(see examples below)

Output Control

ParameterDescriptionExample
outputFormatResponse formatapplication/json (GeoJSON)
srsNameOutput coordinate systemEPSG:4326
propertyNameComma-separated properties to returnname,population,area

Pagination

ParameterDescriptionExample
count (WFS 2.0.0)Max features to return100
maxFeatures (WFS 1.1.0)Max features to return100
startIndexPagination offset200

Sorting

ParameterDescriptionExample
sortBySort results by fieldpopulation D (descending) or population A (ascending)

Examples

Basic Feature Query

curl -X GET "https://graph.quarticle.ro/graph/layers/wfs/GetFeature" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WFS" \
--data-urlencode "version=2.0.0" \
--data-urlencode "request=GetFeature" \
--data-urlencode "typeNames=GRAPHRASTER:light_pollution" \
--data-urlencode "outputFormat=application/json"

Spatial Filter (BBox)

Query features within a bounding box:

curl -X GET "https://graph.quarticle.ro/graph/layers/wfs/GetFeature" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WFS" \
--data-urlencode "version=2.0.0" \
--data-urlencode "request=GetFeature" \
--data-urlencode "typeNames=GRAPHRASTER:cities" \
--data-urlencode "bbox=-74.1,40.6,-73.9,40.8,EPSG:4326" \
--data-urlencode "outputFormat=application/json"

CQL Filter (Attribute Query)

Filter features by attributes using CQL (Common Query Language):

# Get cities with population > 1 million
cql_filter=population > 1000000

Property Selection & Pagination

Retrieve specific properties and paginate through large result sets:

curl -X GET "https://graph.quarticle.ro/graph/layers/wfs/GetFeature" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WFS" \
--data-urlencode "version=2.0.0" \
--data-urlencode "request=GetFeature" \
--data-urlencode "typeNames=GRAPHRASTER:cities" \
--data-urlencode "propertyName=name,population,country" \
--data-urlencode "count=100" \
--data-urlencode "startIndex=0" \
--data-urlencode "sortBy=population D" \
--data-urlencode "outputFormat=application/json"

Output Formats

WFS can return features in multiple formats:

FormatMIME TypeUse Case
GeoJSONapplication/jsonRecommended for web apps
GML 3text/xml or application/gml+xmlOGC standard, GIS desktop apps
CSVtext/csvData analysis, Excel export

Example:

outputFormat=application/json    # GeoJSON
outputFormat=application/gml+xml # GML
outputFormat=text/csv # CSV

Response Structure (GeoJSON)

A typical WFS response in GeoJSON format:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "cities.1",
"geometry": {
"type": "Point",
"coordinates": [-74.0060, 40.7128]
},
"properties": {
"name": "New York",
"population": 8335897,
"country": "USA"
}
},
{
"type": "Feature",
"id": "cities.2",
"geometry": {
"type": "Point",
"coordinates": [-87.6298, 41.8857]
},
"properties": {
"name": "Chicago",
"population": 2693976,
"country": "USA"
}
}
]
}

Error Handling

If a GetFeature request fails, the error is returned as XML by default:

<?xml version="1.0" encoding="UTF-8"?>
<ExceptionReport version="2.0.0">
<Exception exceptionCode="InvalidParameterValue">
<ExceptionText>
Unknown typename: invalid_layer
</ExceptionText>
</Exception>
</ExceptionReport>

Or as JSON if you add &outputFormat=application/json:

{
"code": "InvalidParameterValue",
"message": "Unknown typename: invalid_layer"
}

Common errors:

  • InvalidParameterValue: Wrong typeNames, srsName, or outputFormat
  • NoApplicableCode: CQL filter syntax error or invalid property name
  • Unauthorized: API key is missing or invalid
  • ServiceException: General GeoServer error (check parameters)

Tips & Best Practices

  1. Use JSON for web apps: outputFormat=application/json is easiest to parse in JavaScript
  2. Filter early: Use bbox or cql_filter to reduce payload instead of downloading all features
  3. Select properties: Only request the fields you need with propertyName=field1,field2
  4. Paginate large sets: Use count and startIndex to avoid timeouts
  5. Coordinate system: Data in EPSG:4326 (lat/lon) is standard; use srsName to transform if needed
  6. Cache results: For frequently-accessed datasets, consider caching feature data locally

Next Steps