WMS—Web地图服务
司机简称
WMS
生成依赖项
利勃曲尔
使用GDAL中的WMS格式可以访问几种不同类型的web图像服务。
驱动程序功能
Supports CreateCopy()
This driver supports the GDALDriver::CreateCopy()
operation
Supports Georeferencing
This driver supports georeferencing
Supports VirtualIO
This driver supports virtual I/O operations (/vsimem/, etc.)
XML描述文件
通过创建本地服务描述XML文件访问服务——下面是每个受支持的映像服务的示例。重要的是在 <GDAL_WMS>
元素。
<GDAL_WMS> |
|
<Service name=“WMS”> |
定义当前支持的要使用的迷你驱动程序:WMS、WorldWind、TileService、TMS、TiledWMS、VirtualEarth或AGS。(必需) |
<Version>1.1.1</Version> |
WMS版本。(可选,默认为1.1.1) |
<ServerUrl>http://host.domain.com/wms.cgi?</ServerUrl> |
WMS服务器URL。(必需) |
<SRS>EPSG:4326</SRS> |
图像投影(可选,默认为EPSG:WMS中的4326和AGS中的102100,仅限WMS版本1.1.1或更低版本和ArcGIS服务器)。对于ArcGIS服务器,可以将空间引用指定为已知的ID或 spatial reference json object |
<CRS>CRS:83 |
图像投影(可选,默认为EPSG:4326,仅限WMS 1.3.0或更高版本) |
<ImageFormat>图像/jpeg</ImageFormat> |
请求数据的格式。像image/gif这样的调色板格式将被转换为RGB。(可选,默认为图像/jpeg) |
<Transparent>FALSE</Transparent> |
设置为TRUE以在WMS GetMap请求中包含“transparent=TRUE”(可选默认值为FALSE)。请求格式和BandsCount需要支持alpha。 |
<Layers>modis%2Cglobal_mosaic</Layers> |
URL编码、逗号分隔的层字符串(必需,平铺WMS除外) |
<tiledgeroupname>Clementine</tiledgeroupname> |
以逗号分隔的层列表。(平铺WMS必需) |
<Styles></Styles> |
以逗号分隔的样式列表。(可选) |
<BBoxOrder>xyXY</BBoxOrder> |
任意重新排序bbox坐标。可能需要1.3版服务器。(可选)x-低x坐标,y-低y坐标,x-高x坐标,y-高y坐标 |
</Service> |
|
<DataWindow> |
定义数据的大小和范围。(必需,但TiledWMS和VirtualEarth除外) |
<UpperLeftX>-180.0</UpperLeftX> |
左上角的X(经度)坐标。(可选,默认为-180.0,VirtualLearth除外) |
<UpperLeftY>90.0</UpperLeftY> |
左上角的Y(纬度)坐标。(可选,默认为90.0,VirtualLearth除外) |
<LowerRightX>180.0</LowerRightX> |
右下角的X(经度)坐标。(可选,默认值为180.0,VirtualLearth除外) |
<LowerRightY>-90.0</LowerRightY> |
右下角的Y(纬度)坐标。(可选,默认为-90.0,VirtualLearth除外) |
<SizeX>2666666</SizeX> |
图像大小(像素)。 |
<SizeY>133333</SizeY> |
图像大小(像素)。 |
<TileX>0</TileX> |
以最高分辨率添加到平铺X值。(对于WMS忽略,仅平铺图像源,可选,默认为0) |
<TileY>0</TileY> |
以最高分辨率添加到平铺Y值。(对于WMS忽略,仅平铺图像源,可选,默认为0) |
<tillevel>0</tillevel> |
最高分辨率的平铺级别。(仅平铺图像源,可选,默认为0) |
<TileCountX>0</TileCountX> |
可用于定义图像大小,SizeX=TileCountX * 方块字 * 2TileLevel . (仅平铺图像源,可选,默认为0) |
<TileCountY>0</TileCountY> |
可用于定义图像大小,SizeY=TileCountY * 块状 * 2TileLevel . (仅平铺图像源,可选,默认为0) |
<YOrigin>顶部</YOrigin> |
可用于定义Y原点相对于平铺网格的位置。可能的值是“top”、“bottom”和“default”,其中默认行为是特定于微型驱动程序的。(仅限TMS迷你驱动程序,可选,默认为TMS的“底部”) |
</DataWindow> |
|
<Projection>EPSG:4326</Projection> |
图像投影(可选,默认为mini driver或EPSG报告的值:4326) |
<IdentificationTolerance>2</IdentificationTolerance> |
标识公差(可选,默认为2) |
<BandsCount>3</BandsCount> |
波段/通道数,1表示灰度数据,3表示RGB,4表示RGBA。(可选,默认为3) |
<DataType>字节</DataType> |
波段数据类型,其中之一:Byte、Int16、UInt16、Int32、UInt32、Float32、Float64等。。(可选,默认为Byte) |
<DataValues NoData=“0 0 0”min=“1 1”max=“255 255 255“/> |
定义频带的NoData和/或minimum和/或maximum值。nodata_values、min_values、max_values可以是单个值,也可以是每个频带的值,值之间用空格分隔 |
<BlockSizeX>1024</BlockSizeX> |
块大小(像素)。(可选,默认为1024,VirtualArth除外) |
<BlockSizeY>1024</BlockSizeY> |
块大小(像素)。(可选,默认为1024,VirtualArth除外) |
<OverviewCount>10</OverviewCount> |
每个分辨率较低2倍的降低分辨率层的计数。(可选,默认值在运行时计算) |
<缓存> |
Enable local disk cache. Allows for offline operation. (optional but present in the autogenerated service file, cache is disabled when not present or if it is overridden with GDAL_ENABLE_WMS_CACHE=NO) |
<Path>./gdalwmscache</Path> |
Location where to store cache files. It is safe to use same cache path for different data sources. /vsimem/ paths are supported allowing for temporary in-memory cache. (optional, defaults to ./gdalwmscache if GDAL_DEFAULT_WMS_CACHE_PATH configuration option is not specified) |
<Depth>2</Depth> |
目录层的数量。2将导致文件被写入缓存路径/A/B/ABCDEF。。。(可选,默认为2) |
<Extension>.jpg</Extension> |
附加到缓存文件。(可选,默认为无) |
<Type>文件</Type> |
Cache type. Now supported only 'file' type. In 'file' cache type files are stored in file system folders. (optional, defaults to 'file') |
<Expires>604800</Expires> |
缓存文件将保持有效的时间(秒)。如果缓存文件过期,则在达到最大缓存大小时将其删除。过期的文件也可以被来自web的新文件覆盖。默认值为7天(604800)。 |
<MaxSize>67108864</MaxSize> |
缓存最大大小(字节)。如果缓存达到最大大小,则将删除过期的缓存文件。默认值为64 Mb(67108864字节)。 |
<CleanTimeout>120</CleanTimeout> |
清除线程运行超时(秒)。运行clean线程的频率,该线程查找并删除过期的缓存文件。默认值为120s。使用值0禁用干净线程(实际上是无限缓存大小)。如果要使用非常大的缓存大小,则可能需要禁用缓存清除或使用更长的超时,因为扫描缓存文件以查找过期的缓存文件所需的时间可能很长。(“禁用”是GDAL<=2.2的唯一选项;“120s”是GDAL<=3.1的唯一选项)。 |
<Unique>True</Unique> |
如果设置为true,则路径将附加ServerURL的md5散列。默认值为true。 |
</Cache> |
|
<MaxConnections>2</MaxConnections> |
同时连接的最大数目。(可选,默认为2)。也可以用 |
<Timeout>300</Timeout> |
连接超时(秒)。(可选,默认为300) |
<OfflineMode>true</OfflineMode> |
不要下载任何新图像,只使用缓存中的内容。仅在启用缓存时才有用。(可选,默认为false) |
<AdviseRead>true</AdviseRead> |
启用AdviseRead API调用-将图像下载到缓存中。(可选,默认为false) |
<VerifyAdviseRead>true</VerifyAdviseRead> |
打开每个下载的图像并在写入缓存之前执行一些基本检查。如果信任服务器总是返回正确的映像,则禁用可以节省一些CPU周期。(可选,默认为true) |
<ClampRequests>false</ClampRequests> |
如果请求被剪裁,否则将部分超出定义的数据窗口,从而导致小于块大小的请求。(可选,默认为true) |
<UserAgent>GDAL WMS驱动程序(http://www.GDAL.org/frmt_WMS.html)</UserAgent> |
HTTP用户代理字符串。一些服务器可能需要一个众所周知的用户代理,比如“Mozilla/5.0”(可选,默认为“GDAL WMS driver”)(http://www.gdal.org/frmtu wms.html)"). 当与某些服务器(如OpenStreetMap)一起使用时,强烈建议放置自定义用户代理,以避免在必须阻止默认用户代理时被阻止。 |
<Accept>mimetype>/Accept> |
HTTP Accept header to specify the MIME type of the expected output of the server. Empty by default |
<UserPwd>用户:密码 |
用于HTTP身份验证的用户和密码(可选)。 |
<UnsafeSSL>true</UnsafeSSL> |
跳过SSL证书验证。如果服务器使用自签名证书(可选,默认为false),则可能需要。 |
<Referer>http://example.foo/</Referer> |
HTTP引用字符串。有些服务器可能需要它(可选)。 |
<zeroblockhttpcode>204404</zeroblockhttpcode> |
以逗号分隔的HTTP响应代码列表,这些代码将被解释为0填充的图像(即3个频段为黑色,4个频段为透明),而不是中止请求。(可选,默认为204) |
<ZeroBlockOnServerException>true</ZeroBlockOnServerException> |
是否将服务器返回的服务异常视为0填充的映像,而不是中止请求。(可选,默认为false) |
</GDAL_WMS> |
|
从gdal2.3开始,可以通过将GDALuhttpuheaderu FILE配置选项设置为指向带有“key:value”HTTP头的文本文件的文件名来发送额外的HTTP头。
小型司机
GDAL WMS驱动程序支持多个内部“微型驱动程序”,允许访问不同的web映射服务。这些服务中的每一个都可以支持服务块中的不同选项集。
WMS
与OGC WMS服务器的通信。支持平铺请求和未平铺请求。
可以使用gdallocationinfo实用程序或对band对象的GetMetadataItem(“PixeliColiLine”,“LocationInfo”)调用(通过GetFeatureInfo请求)查询WMS层。
gdallocationinfo "WMS:http://demo.opengeo.org/geoserver/gwc/service/wms?SERVICE=WMS&VERSION=1.1.1&
REQUEST=GetMap&LAYERS=og%3Abugsites&SRS=EPSG:900913&
BBOX=-1.15841845090625E7,5479006.186718751,-1.1505912992109375E7,5557277.703671876&
FORMAT=image/png&TILESIZE=256&OVERVIEWCOUNT=25&MINRESOLUTION=0.0046653459640220&TILED=true"
-geoloc -11547071.455 5528616 -xml -b 1
输出:
Report pixel="248595" line="191985">
<BandReport band="1">
<LocationInfo>
<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:og="http://opengeo.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=og%3Abugsites http://www.opengis.net/wfs http://demo.opengeo.org/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd">
<gml:boundedBy>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#26713">
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">601228,4917635 601228,4917635</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<og:bugsites fid="bugsites.40946">
<gml:boundedBy>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#26713">
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">601228,4917635 601228,4917635</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<og:cat>86</og:cat>
<og:str1>Beetle site</og:str1>
<og:the_geom>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#26713">
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">601228,4917635</gml:coordinates>
</gml:Point>
</og:the_geom>
</og:bugsites>
</gml:featureMember>
</wfs:FeatureCollection>
</LocationInfo>
<Value>255</Value>
</BandReport>
</Report>
TileService
支持与世界之风对话的服务 TileService . 访问始终基于平铺。
WorldWind
访问基于web的WorldWind tile服务。访问始终基于平铺。
TMS
TMS微型驱动程序的设计主要是为了支持 TMS Specification . 此服务仅支持通过磁贴进行访问。
由于TMS类似于web上许多其他“x/y/z”风格的服务,因此该服务也可以用于访问这些服务。要以这种方式使用它,可以使用${x}、${y}等格式的替换变量。
支持的变量(名称区分大小写)为:
${x}——磁贴的x位置
${y}——平铺的y位置。这可以从tileset的顶部或底部进行,具体取决于YOrigin参数设置为true还是false。
${z}——磁贴的z位置——缩放级别
${version}——版本参数,在配置文件中设置。默认为1.0.0。
${format}——格式参数,在配置文件中设置。默认为“jpg”。
${layer}——层参数,在配置文件中设置。默认为“无”。
http://tilecache.osgeo.org/wms-c/Basic.py/${version}/${layer}/${z}/${x}/${y}.${format}
TMS服务有3个不同于其他服务的XML配置元素: Format
默认为 jpg
, Layer
没有违约,而且 Version
默认为 1.0.0
.
此外,TMS服务在数据窗口级别上还考虑一个附加参数,即YOrigin元素。这个元素应该是 bottom
(TMS中的默认值)或 top
,它与OpenStreetMap和许多其他流行的平铺服务相匹配。
下面的示例中包括使用TMS服务的两个示例。
欧内斯瓷砖WMS
The OnEarth Tiled WMS minidriver supports the Tiled WMS specification implemented for the JPL OnEarth driver per the specification at http://web.archive.org/web/20130511182803/http://onearth.jpl.nasa.gov/tiled.html.
Only the ServerUrl and the TiledGroupName are required, most of the required information is automatically fetched from the remote server using the GetTileService method at open time.
典型的OnEarth平铺WMS配置文件可能如下所示:
<GDAL_WMS>
<Service name="TiledWMS">
<ServerUrl>https://gibs.earthdata.nasa.gov/twms/epsg4326/best/twms.cgi?</ServerUrl>
<TiledGroupName>MODIS Terra CorrectedReflectance TrueColor tileset</TiledGroupName>
<Change key="${time}">2020-02-02</Change>
</Service>
</GDAL_WMS>
The TiledWMS minidriver can use the following open options :
TiledGroupName -- The value is a string that identifies one of the tiled services available on the server
Change -- A <Key>:<Value> pair, which will be passed to the server. The key has to match a change key that the server declares for the respective tiled group. This option can be used multiple times, for different keys. Example: - Change=time:2020-02-02
These open options are only accepted if the corresponding XML element is not present in the configuration file.
VirtualEarth
访问基于web的虚拟地砖服务。访问始终基于平铺。
必须在ServerUrl元素中找到${quadkey}变量。
DataWindow元素可能被忽略。默认值为:
左上角X=-20037508.34
左上=20037508.34
下限X=20037508.34
下限=-20037508.34
TileLevel = 21
OverviewCount = 20
SRS = EPSG:3857
方块字=256
块大小=256
REST API
访问ArcGIS REST map service resource (未标记的请求)。
AGS层可以是 queried (通过GetFeatureInfo请求)使用gdallocationinfo实用程序,或使用对band对象的GetMetadataItem(“像素图标”、“位置信息”)调用。
gdallocationinfo -wgs84 "<GDAL_WMS><Service name=\"AGS\"><ServerUrl>http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer</ServerUrl><BBoxOrder>xyXY</BBoxOrder><SRS>3857</SRS></Service><DataWindow><UpperLeftX>-20037508.34</UpperLeftX><UpperLeftY>20037508.34</UpperLeftY><LowerRightX>20037508.34</LowerRightX><LowerRightY>-20037508.34</LowerRightY><SizeX>512</SizeX><SizeY>512</SizeY></DataWindow></GDAL_WMS>" -75.704 39.75
互联网成像协议(IIP)(GDAL 2.1及更高版本)
访问通过 IIP protocol . 服务器必须支持IIP协议的JTL(作为完整的JFIF映像检索磁贴)扩展。
如果使用XML语法,那么ServerURL必须包含FIF参数。
否则,也可以使用“IIP:http://foo.com/FIF=image_name”语法作为连接字符串,从服务器检索有关完整分辨率维度和分辨率数量的信息。
然后可以使用“gdal_translate IIP:http://foo.com/FIF=image_name out.XML-of WMS”生成XML定义
实例
- onearth_global_mosaic.xml - Landsat mosaic from a OnEarth WMS server
gdal_translate -of JPEG -outsize 500 250 onearth_global_mosaic.xml onearth_global_mosaic.jpg
gdal_translate -of JPEG -projwin -10 55 30 35 -outsize 500 250 onearth_global_mosaic.xml onearth_global_mosaic2.jpg
注意:此特定服务器不再接受常规WMS查询。
metacarta_wmsc.xml - It is possible to configure a WMS Service conforming to a WMS-C cache by specifying a number of overviews and specifying the 'block size' as the tile size of the cache. The following example is a sample set up for a 19-level "Global Profile" WMS-C cache.
gdal_translate -of PNG -outsize 500 250 metacarta_wmsc.xml metacarta_wmsc.png
- tileservice_bmng.xml - TileService, Blue Marble NG (January)
gdal_translate -of JPEG -outsize 500 250 tileservice_bmng.xml tileservice_bmng.jpg
- tileservice_nysdop2004.xml - TileService, NYSDOP 2004
gdal_translate -of JPEG -projwin -73.687030 41.262680 -73.686359 41.262345 -outsize 500 250 tileservice_nysdop2004.xml tileservice_nysdop2004.jpg
- OpenStreetMap TMS Service Example: Connect to OpenStreetMap tile service. Note that this file takes advantage of the tile cache; more information about configuring the tile cache settings is available above. Please also change the <UserAgent>, to avoid the default one being used, and potentially blocked by OSM servers in case a too big usage of it would be seen.
gdal_translate -of PNG -outsize 512 512 frmt_wms_openstreetmap_tms.xml openstreetmap.png
- MetaCarta TMS Layer Example, accessing the default MetaCarta TMS layer.
gdal_translate -of PNG -outsize 512 256 frmt_wms_metacarta_tms.xml metacarta.png
BlueMarble Amazon S3 Example accessed with the TMS minidriver.
Google Maps accessed with the TMS minidriver.
ArcGIS MapServer Tiles accessed with the TMS minidriver.
OnEarth Tiled WMS Clementine, daily, and srtm examples.
VirtualEarth Aerial Layer accessed with the VirtualEarth minidriver.
ArcGIS online sample server layer accessed with the ArcGIS Server REST API minidriver.
IIP online sample server layer accessed with the IIP minidriver.
开放语法
WMS驱动程序可以打开:
本地服务描述XML文件:
gdalinfo description_file.xml
作为文件名提供的描述XML文件的内容:
gdalinfo "<GDAL_WMS><Service name=\"TiledWMS\"><ServerUrl>https://gibs.earthdata.nasa.gov/twms/epsg4326/best/twms.cgi?</ServerUrl><TiledGroupName>MODIS Terra CorrectedReflectance Bands367 tileset</TiledGroupName></Service></GDAL_WMS>"
WMS服务的基本URL,前缀为 WMS: :
gdalinfo "WMS:http://wms.geobase.ca/wms-bin/cubeserv.cgi"
将返回子数据集的列表,这是对该服务器上的GetCapabilities请求进行分析后得到的结果。
例如,由前一个伪数据集返回的getsub请求语法:
gdalinfo "WMS:http://wms.geobase.ca/wms-bin/cubeserv.cgi?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=DNEC_250K%3AELEVATION%2FELEVATION&SRS=EPSG:42304&BBOX=-3000000,-1500000,6000000,4500000"
平铺WMS服务的基本URL,前缀为 WMS: 并使用request=GetTileService作为GET参数:
gdalinfo "WMS:https://gibs.earthdata.nasa.gov/twms/epsg4326/best/twms.cgi?request=GetTileService"
将返回子数据集的列表,这是对该服务器上的GetTileService请求进行分析的结果。
ArcGIS MapServer的REST定义的URL:
gdalinfo "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true"
(GDAL>=2.1.0)IIP图像的URL:
gdalinfo "IIP:http://merovingio.c2rmf.cnrs.fr/fcgi-bin/iipsrv.fcgi?FIF=globe.256x256.tif"
WMS服务描述XML文件的生成
仅当源数据集本身是WMS数据集时,才能手动生成WMS服务描述XML文件,或将其创建为WMS驱动程序的CreateCopy()操作的输出。否则,可以将gdal_translate与“Open syntax”中提到的任何上述语法一起用作源数据集,并作为XML文件的输出。例如:
gdal_translate "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json" wms.xml -of WMS
生成的文件将带有您可能需要编辑的默认值。