WMS — Web Map Service
The WMS (Web Map Service) allows you to render styled map tiles from GeoServer layers. This guide covers all five WMS operations and their parameters.
All requests go to: https://graph.quarticle.ro/graph/layers/wms/
Authentication: Add the Authorization: YOUR_API_KEY header to all requests.
GetCapabilities
Discover available layers, styles, projections, and output formats published in GeoServer.
Purpose: Metadata discovery — understand what layers are available and what operations they support.
Required Parameters
| Parameter | Value | Example |
|---|---|---|
service | WMS | service=WMS |
version | 1.3.0 | version=1.3.0 |
request | GetCapabilities | request=GetCapabilities |
Response
Returns an XML document listing all available layers with their:
- Bounding boxes (spatial extent)
- Available projections (SRS)
- Styles
- Data types
- cURL
- JavaScript
- Python
curl -X GET "https://graph.quarticle.ro/graph/layers/wms/GetCapabilities" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WMS" \
--data-urlencode "version=1.3.0" \
--data-urlencode "request=GetCapabilities"
const apiKey = process.env.QARTA_API_KEY;
fetch('https://graph.quarticle.ro/graph/layers/wms/GetCapabilities?' +
new URLSearchParams({
service: 'WMS',
version: '1.3.0',
request: 'GetCapabilities'
}), {
headers: { 'Authorization': `${apiKey}` }
})
.then(r => r.text())
.then(xml => {
// Parse XML document
const parser = new DOMParser();
const doc = parser.parseFromString(xml, 'text/xml');
const layers = doc.querySelectorAll('Layer');
console.log(`Found ${layers.length} layers`);
});
import requests
import xml.etree.ElementTree as ET
api_key = os.getenv('QARTA_API_KEY')
response = requests.get(
'https://graph.quarticle.ro/graph/layers/wms/GetCapabilities',
params={
'service': 'WMS',
'version': '1.3.0',
'request': 'GetCapabilities'
},
headers={'Authorization': f'{api_key}'}
)
root = ET.fromstring(response.text)
layers = root.findall('.//{http://www.opengis.net/wms}Layer')
print(f'Found {len(layers)} layers')
DescribeLayer
Get metadata about a specific layer's WFS or WCS source.
Purpose: Find the corresponding WFS typeNames parameter for a WMS layer.
Required Parameters
| Parameter | Description |
|---|---|
service | WMS |
version | 1.1.1 |
request | DescribeLayer |
layers | Comma-separated layer names. Example: GRAPHRASTER:light_pollution |
Optional Parameters
| Parameter | Description |
|---|---|
exceptions | Exception format. Default: application/vnd.ogc.se_xml |
Example
- cURL
curl -X GET "https://graph.quarticle.ro/graph/layers/wms/DescribeLayer" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WMS" \
--data-urlencode "version=1.1.1" \
--data-urlencode "request=DescribeLayer" \
--data-urlencode "layers=GRAPHRASTER:light_pollution"
GetMap
Render a map tile (PNG image) for a given area, layers, and style.
Purpose: Generate styled map images for display on web maps or in applications.
Required Parameters
| Parameter | Description | Example |
|---|---|---|
service | WMS | WMS |
version | 1.3.0 | 1.3.0 |
request | GetMap | GetMap |
layers | Comma-separated layer names | GRAPHRASTER:light_pollution |
styles | Comma-separated style names (or empty for defaults) | `` (empty) or light_style |
srs / crs | Spatial Reference System (EPSG code) | EPSG:3857 (Web Mercator) |
bbox | Bounding box: minx,miny,maxx,maxy in SRS units | 975947.9771,6657970.9118,1533632.5355,7037098.5720 |
width | Width of output in pixels | 256 |
height | Height of output in pixels | 256 |
format | Output format | image/png |
Optional Parameters
| Parameter | Description | Example |
|---|---|---|
transparent | Whether background is transparent | true |
bgcolor | Background color in RRGGBB hex format | FFFFFF |
exceptions | Exception format | application/json |
time | Time value for temporal layers | 2023-01-01T00:00:00Z |
sld | URL to external SLD document | https://example.com/style.sld |
sld_body | URL-encoded SLD XML | (see examples) |
Example: Basic 256×256 Tile
- cURL
- JavaScript
- Python
curl -X GET "https://graph.quarticle.ro/graph/layers/wms/GetMap" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WMS" \
--data-urlencode "version=1.3.0" \
--data-urlencode "request=GetMap" \
--data-urlencode "layers=GRAPHRASTER:light_pollution" \
--data-urlencode "styles=" \
--data-urlencode "srs=EPSG:3857" \
--data-urlencode "bbox=975947.9771,6657970.9118,1533632.5355,7037098.5720" \
--data-urlencode "width=256" \
--data-urlencode "height=256" \
--data-urlencode "format=image/png" \
--data-urlencode "transparent=true" \
-o tile.png
const apiKey = process.env.QARTA_API_KEY;
const params = new URLSearchParams({
service: 'WMS',
version: '1.3.0',
request: 'GetMap',
layers: 'GRAPHRASTER:light_pollution',
styles: '',
srs: 'EPSG:3857',
bbox: '975947.9771,6657970.9118,1533632.5355,7037098.5720',
width: '256',
height: '256',
format: 'image/png',
transparent: 'true'
});
const url = `https://graph.quarticle.ro/graph/layers/wms/GetMap?${params}`;
const imgElement = document.querySelector('img');
imgElement.src = url;
imgElement.onload = () => console.log('Tile loaded');
import requests
api_key = os.getenv('QARTA_API_KEY')
response = requests.get(
'https://graph.quarticle.ro/graph/layers/wms/GetMap',
params={
'service': 'WMS',
'version': '1.3.0',
'request': 'GetMap',
'layers': 'GRAPHRASTER:light_pollution',
'styles': '',
'srs': 'EPSG:3857',
'bbox': '975947.9771,6657970.9118,1533632.5355,7037098.5720',
'width': '256',
'height': '256',
'format': 'image/png',
'transparent': 'true'
},
headers={'Authorization': f'{api_key}'}
)
with open('tile.png', 'wb') as f:
f.write(response.content)
Tips
- EPSG:3857: Use for web map tiles (Web Mercator projection)
- EPSG:4326: Use for reprojected data (lat/lon, rarely for tiles)
- SRS vs CRS: WMS 1.1.x uses
srs, WMS 1.3.0 usescrs(GeoServer accepts both) - format=image/png: Produces smaller, 8-bit PNG tiles
- transparent=true: Allows background to show through (useful for overlays)
- Multiple layers: Separate with commas:
layers=layer1,layer2,layer3
GetFeatureInfo
Query feature attributes at a pixel location on a rendered map.
Purpose: "Click to query" — get attribute values from a location on a map.
Required Parameters
All GetMap parameters, plus:
| Parameter | Description | Example |
|---|---|---|
query_layers | Layers to query (subset of layers) | GRAPHRASTER:light_pollution |
x | X coordinate of query point (in pixels) | 5 |
y | Y coordinate of query point (in pixels) | 5 |
Optional Parameters
| Parameter | Description |
|---|---|
info_format | Response format: text/html, application/json, text/plain |
feature_count | Max features to return. Default: 1 |
Example
- cURL
curl -X GET "https://graph.quarticle.ro/graph/layers/wms/GetFeatureInfo" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WMS" \
--data-urlencode "version=1.3.0" \
--data-urlencode "request=GetFeatureInfo" \
--data-urlencode "layers=GRAPHRASTER:light_pollution" \
--data-urlencode "query_layers=GRAPHRASTER:light_pollution" \
--data-urlencode "styles=" \
--data-urlencode "srs=EPSG:3857" \
--data-urlencode "bbox=975947.9771,6657970.9118,1533632.5355,7037098.5720" \
--data-urlencode "width=256" \
--data-urlencode "height=256" \
--data-urlencode "x=128" \
--data-urlencode "y=128" \
--data-urlencode "info_format=application/json"
GetLegendGraphic
Retrieve a rendered legend image for a layer and style.
Purpose: Display layer legend in your application.
Required Parameters
| Parameter | Description | Example |
|---|---|---|
service | WMS | WMS |
version | 1.0.0 | 1.0.0 |
request | GetLegendGraphic | GetLegendGraphic |
layer | Layer name | GRAPHRASTER:light_pollution |
styles | Style name | light_style or empty |
format | Image format | image/png |
Optional Parameters
| Parameter | Description |
|---|---|
width | Width in pixels (default: 20) |
height | Height in pixels (default: 20) |
rule | Specific rule from style (if applicable) |
scale | Standardized scale denominator |
sld | URL to external SLD document |
sld_body | URL-encoded SLD XML |
language | Language for labels |
Example
- cURL
curl -X GET "https://graph.quarticle.ro/graph/layers/wms/GetLegendGraphic" \
-H "Authorization: YOUR_API_KEY" \
--data-urlencode "service=WMS" \
--data-urlencode "version=1.0.0" \
--data-urlencode "request=GetLegendGraphic" \
--data-urlencode "layer=GRAPHRASTER:light_pollution" \
--data-urlencode "format=image/png" \
--data-urlencode "width=40" \
--data-urlencode "height=40" \
-o legend.png
Error Handling
If a GetMap or GetCapabilities request fails, the error is returned in the requested exception format:
<?xml version="1.0" encoding="UTF-8"?>
<ServiceExceptionReport version="1.3.0">
<ServiceException>
Layer 'invalid_layer' not found
</ServiceException>
</ServiceExceptionReport>
Or as JSON if exceptions=application/json:
{
"code": "InvalidLayer",
"message": "Layer 'invalid_layer' not found"
}
Common errors:
- InvalidLayer: Layer name doesn't exist. Check GetCapabilities.
- InvalidSRS: SRS/CRS code not supported. Typical:
EPSG:3857,EPSG:4326. - InvalidBBox: Bounding box format incorrect or out of range.
- Unauthorized: API key is missing or invalid.
Next Steps
- GeoServer Overview
- WFS Guide — Query raw feature data
- Map Visualization Use Case — Embed WMS in web maps