WCS - Web Coverage Service, WCS is a specification for sharing geospatial data in the form of "Coverage" on the Web as defined by the OGC. The so-called "Coverage" refers to data that can return the value of any specified point in its space-time domain, and its form is easy to input into the model for use. The WCS service realizes the sharing of raster image datasets in the form of "Coverage".
As in WMS and WFS support, WCS publishing is enabled by adding certain metadata key/value pairs to the .map
file.
MapServer targets only layers that meet the following conditions and includes them in its WCS function:
RASTER
;wcs_enable_request
must be set;wcs_label
must be set;wcs_label
, wcs_rangeset_name
, wcs-rangeset-label
;Take a look at the Mapfile used in this section:
01 MAP
02 EXTENT -180 -90 180 90
03 SIZE 600 300
04 SHAPEPATH "/gdata"
05 OUTPUTFORMAT
06 NAME "GEOTIFF_16"
07 DRIVER "GDAL/GTiff"
08 MIMETYPE "image/tiff"
09 IMAGEMODE FLOAT32
10 EXTENSION "tif"
11 END
12 WEB
13 IMAGEPATH "/owg/ms_tmp/"
14 IMAGEURL "/ms_tmp/"
15 METADATA
16 "wcs_onlineresource" "http://webgis.pub/cgi-bin/mapserv?map=/owg/mfw8.map"
17 "wcs_keywordlist" "wcs,test"
18 "wcs_enable_request" "*"
19 END
20 END
21 PROJECTION
22 "init=epsg:4326"
23 END
24 LAYER
25 METADATA
26 "wcs_keywordlist" "land, shallow, topo, world"
27 END
28 NAME "world-img"
29 DATA "land_shallow_topo_8192.tif"
30 STATUS OFF
31 TYPE RASTER
32 PROJECTION
33 "init=epsg:4326"
34 END
35 END
36 END
As in WMS and WFS, you can also use GetCapabilities
to view the capabilities of WCS:
//webgis.pub / cgi-bin/mapserv?map=/owg/mfw8.map&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCapabilities
Parse the parameters using Python:
>>> [print(x) for x in url.split('&')]
http://webgis.pub/cgi-bin/mapserv?map=/owg/mfw8.map
SERVICE=WCS
VERSION=2.0.1
REQUEST=GetCapabilities
View the output results in XML format. Only the parts related to version are shown here:
<ows:ServiceType codeSpace="OGC">OGC WCS</ows:ServiceType>
<ows:ServiceTypeVersion>2.0.1</ows:ServiceTypeVersion>
<ows:ServiceTypeVersion>1.1.1</ows:ServiceTypeVersion>
<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
<ows:Profile>http://www.opengis.net/spec/WCS/2.0/conf/core</ows:Profile>
You can see that the versions of WCS are:
The DescribeCoverage
request lists more information about a specific coverage product.
The parameters are described as follows:
>>> [print(x) for x in url.split('&')]
http://webgis.pub/cgi-bin/mapserv?map=/owg/mfw8.map
SERVICE=WCS
VERSION=2.0.1
REQUEST=DescribeCoverage
COVERAGEID=world-img
The parameters vary greatly between different versions, and the returned results are also different. You can open the link to have a look at it:
WFS 1.0.0:
//webgis.pub / cgi-bin/mapserv?map=/owg/mfw8.map&SERVICE=WCS&VERSION=1.0.0&REQUEST=DescribeCoverage&COVERAGE=world-img
Parse the URL:
>>> [print(idx, x) for idx, x in enumerate(url.split('&'))]
0 http://webgis.pub/cgi-bin/mapserv?map=/owg/mfw8.map
1 SERVICE=WCS
2 VERSION=1.0.0
3 REQUEST=DescribeCoverage
4 COVERAGE=world-img
WFS 1.1.1:
//webgis.pub / cgi-bin/mapserv?map=/owg/mfw8.map&SERVICE=WCS&VERSION=1.1.1&REQUEST=DescribeCoverage&IDENTIFIERS=world-img
Parse the URL:
>>> [print(idx, x) for idx, x in enumerate(url.split('&'))]
0 http://webgis.pub/cgi-bin/mapserv?map=/owg/mfw8.map
1 SERVICE=WCS
2 VERSION=1.1.1
3 REQUEST=DescribeCoverage
4 IDENTIFIERS=world-img
GetCoverage
returns data, which is raster data. Since the request cannot specify the name and suffix of the file at this time, the file can be downloaded and saved, and modified into a file with .tif
as the suffix. This file has geospatial information.
The parameters are decomposed as follows:
>>> [print(idx, x) for idx, x in enumerate(url.split('&'))]
0 http://webgis.pub/cgi-bin/mapserv?map=/owg/mfw8.map
1 SERVICE=WCS
2 VERSION=1.1.0
3 REQUEST=GetCoverage
4 IDENTIFIER=world-img
5 FORMAT=image/tiff
6 BOUNDINGBOX=43,33,44,34,urn:ogc:def:crs:EPSG::4326
GetCoverage
can also directly return the image, just modify format=image/png
. However, it should be noted that the returned image must be returned by a separate request in the web, and cannot be used in the web page as an <image>
object.
The following is an example, the picture in the web page, which cannot be displayed here. But by "right click" -> "view image", you can see that it is a picture.