r.in.wms
Downloads and imports data from OGC WMS and OGC WMTS web mapping servers.
r.in.wms [-cob] url=string output=name layers=string [,string,...] [styles=string [,string,...]] [format=string] [srs=integer] [driver=string] [wms_version=string] [maxcols=integer] [maxrows=integer] [urlparams=string] [username=string] [password=string] [method=string] [gdal_createopt=string [,string,...]] [region=string] [bgcolor=string] [proxy=string] [proxy_user_pw=string] [capfile=name] [capfile_output=name] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
r.in.wms url=string output=name layers=string
grass.script.run_command("r.in.wms", url, output, layers, styles=None, format="png", srs=4326, driver="WMS_GRASS", wms_version="1.1.1", maxcols=512, maxrows=512, urlparams=None, username=None, password=None, method="nearest", gdal_createopt=None, region=None, bgcolor=None, proxy=None, proxy_user_pw=None, capfile=None, capfile_output=None, flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("r.in.wms", url="string", output="name", layers="string")
Parameters
url=string [required]
Typically starts with "http://"
output=name [required]
Name for output raster map
layers=string [,string,...] [required]
Layer(s) to request from the map server
styles=string [,string,...]
Layer style(s) to request from the map server
format=string
Image format requested from the server
Allowed values: geotiff, tiff, jpeg, gif, png, png8
Default: png
srs=integer
EPSG code of requested source projection
Default: 4326
driver=string
Driver used for communication with the server
Allowed values: WMS_GDAL, WMS_GRASS, WMTS_GRASS, OnEarth_GRASS
Default: WMS_GRASS
WMS_GDAL: Download data using GDAL WMS driver
WMS_GRASS: Download data using native GRASS-WMS driver
WMTS_GRASS: Download data using native GRASS-WMTS driver
OnEarth_GRASS: Download data using native GRASS-OnEarth driver
wms_version=string
WMS standard version
Allowed values: 1.1.0, 1.1.1, 1.3.0
Default: 1.1.1
maxcols=integer
Maximum columns to request at a time
Default: 512
maxrows=integer
Maximum rows to request at a time
Default: 512
urlparams=string
Additional query parameters to pass to the server
username=string
Username for server connection
password=string
Password for server connection
method=string
Interpolation method to use in reprojection
Allowed values: nearest, linear, cubic, cubicspline
Default: nearest
gdal_createopt=string [,string,...]
GDAL creation option(s) to pass to the output format driver
In the form of "NAME=VALUE", separate multiple entries with a comma
region=string
Request data for this named region instead of the current region bounds
bgcolor=string
Background color
Format: 0xRRGGBB
proxy=string
HTTP proxy only GDAL driver (GDAL_HTTP_PROXY)
HTTP proxy
proxy_user_pw=string
User and password for HTTP proxy only for GDAL driver (GDAL_HTTP_PROXYUSERPWD). Must be in the form of [user name]:[password].
User and password for HTTP proxy
capfile=name
Capabilities file to parse (input). It is relevant for WMTS_GRASS and OnEarth_GRASS drivers
capfile_output=name
File where the server capabilities will be saved ('c' flag)
-c
Get the server capabilities, print them out, then exit
-o
Do not request transparent data
-b
Keep original bands (default: create composite)
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
url : str, required
Typically starts with "http://"
output : str, required
Name for output raster map
Used as: output, raster, name
layers : str | list[str], required
Layer(s) to request from the map server
styles : str | list[str], optional
Layer style(s) to request from the map server
format : str, optional
Image format requested from the server
Allowed values: geotiff, tiff, jpeg, gif, png, png8
Default: png
srs : int, optional
EPSG code of requested source projection
Default: 4326
driver : str, optional
Driver used for communication with the server
Allowed values: WMS_GDAL, WMS_GRASS, WMTS_GRASS, OnEarth_GRASS
WMS_GDAL: Download data using GDAL WMS driver
WMS_GRASS: Download data using native GRASS-WMS driver
WMTS_GRASS: Download data using native GRASS-WMTS driver
OnEarth_GRASS: Download data using native GRASS-OnEarth driver
Default: WMS_GRASS
wms_version : str, optional
WMS standard version
Allowed values: 1.1.0, 1.1.1, 1.3.0
Default: 1.1.1
maxcols : int, optional
Maximum columns to request at a time
Default: 512
maxrows : int, optional
Maximum rows to request at a time
Default: 512
urlparams : str, optional
Additional query parameters to pass to the server
username : str, optional
Username for server connection
password : str, optional
Password for server connection
method : str, optional
Interpolation method to use in reprojection
Allowed values: nearest, linear, cubic, cubicspline
Default: nearest
gdal_createopt : str | list[str], optional
GDAL creation option(s) to pass to the output format driver
In the form of "NAME=VALUE", separate multiple entries with a comma
region : str, optional
Request data for this named region instead of the current region bounds
bgcolor : str, optional
Background color
Format: 0xRRGGBB
proxy : str, optional
HTTP proxy only GDAL driver (GDAL_HTTP_PROXY)
HTTP proxy
proxy_user_pw : str, optional
User and password for HTTP proxy only for GDAL driver (GDAL_HTTP_PROXYUSERPWD). Must be in the form of [user name]:[password].
User and password for HTTP proxy
capfile : str, optional
Capabilities file to parse (input). It is relevant for WMTS_GRASS and OnEarth_GRASS drivers
Used as: input, file, name
capfile_output : str, optional
File where the server capabilities will be saved ('c' flag)
Used as: output, file, name
flags : str, optional
Allowed values: c, o, b
c
Get the server capabilities, print them out, then exit
o
Do not request transparent data
b
Keep original bands (default: create composite)
overwrite: bool, optional
Allow output files to overwrite existing files
Default: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
r.in.wms handles all of downloading and importing raster data from OGC WMS and OGC WMTS web mapping servers. It only needs be told the desired data to collect (bounds and resolution) via a region, the server to get the data from, and the layer or layers to get. It downloads the data in tiles, reprojects it, imports it, and patches it back together.
NOTES
To understand the data you are getting it is necessary to look at the capabilities of the WMS server. This should be available via a capabilities request (see examples)
If possible, the EPSG code of the current project should be used with the srs option to avoid unnecessary reprojection.
When using GDAL WMS driver (driver=WMS_GDAL), the GDAL library needs to be built with WMS support, see GDAL WMS manual page for details.
Tiled WMS
Into the parameter layers the name of the TiledGroup need to be
inserted from Tile Service file. Time variable can be specified in
urlparams parameter, e.g: urlparams='time=2012-1-1'
.
EXAMPLES
General Get Capabilities Request
# Topographic WMS with OpenStreetMap by mundialis
r.in.wms -c url="https://ows.mundialis.de/services/service?"
r.in.wms -c url="https://ows.mundialis.de/services/service?" | grep Name
# Czech WMS
r.in.wms -c url="https://wms.cuzk.cz/wms.asp"
Download raster data from WMS server (GetMap request)
Open Street Map
# OSM, using WMS_GRASS driver
g.region n=90 s=-90 w=-180 e=180 res=0:10:00 -p
r.in.wms url="http://watzmann-geog.urz.uni-heidelberg.de/cached/osm" layers=osm_auto:all output=osm format=png
r.info osm
# OSM Overlay WMS (can be used as an overlay for other maps)
r.in.wms url="http://ows.mundialis.de/services/service?" layer=OSM-Overlay-WMS output=osm_overlay format=png
# TOPO-OSM-WMS
r.in.wms url="http://ows.mundialis.de/services/service?" layer=TOPO-OSM-WMS output=topo_osm format=png
r.info topo_osm
# TOPO-WMS
r.in.wms url="http://ows.mundialis.de/services/service?" layer=TOPO-WMS output=topo format=png
r.info topo
More OSM WMS servers can be found online, e.g. on the OSM wiki in a OSM WMS Servers list and on the WORLD_OSM_WMS page.
Countries and coastlines
# using WMS_GRASS driver
r.in.wms url="http://www2.demis.nl/WMS/wms.asp" layers=Countries,Borders,Coastline output=countries srs=4326 format=png
r.info countries
Sentinel-2 satellite cloud free global coverage
# North Carolina sample data
g.region raster=elevation -p
# using WMS_GRASS driver
r.in.wms url="https://tiles.maps.eox.at/wms?" layers=s2cloudless output=sentinel2 format=png
r.info sentinel2
Figure: Raleigh (NC, USA) seen by Sentinel-2 (10m resolution; image
courtesy: EOX)
OGC WMTS Example
# using WMTS_GRASS driver
r.in.wms url="http://gpp3-wxs.ign.fr/yourAPIkey/geoportail/wmts" layers=ORTHOIMAGERY.ORTHOPHOTOS \
output=orthophoto srs=3857 format=jpeg driver=WMTS_GRASS style=normal password="*" username="*"
r.info orthophoto
Note: username, password and API key can be obtained from IGN API website
Data covering the Czech Republic
# using WMS_GRASS driver
r.in.wms url="http://wms.cuzk.cz/wms.asp" layers=prehledka_kraju-linie srs=4326 output=kn format=png
# using WMTS_GRASS driver
r.in.wms url="http://geoportal.cuzk.cz/WMTS_ORTOFOTO/WMTService.aspx" layers=orto output=orthophoto \
srs=3857 format=jpeg driver=WMTS_GRASS style=default
r.info orthophoto
Note: data are provided by Czech office for surveying, mapping and cadastre.
Satellite data covering Europe
Copernicus Core003 View Services - Optical VHR2 coverage over EU 2011-2013 (provided by JRC; usage is restricted to non-commercial activities):
# get WMS layer list
r.in.wms -c url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?"
r.in.wms -c url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?" | grep Name
# spatial subset of Europe
# enlarging maxcols and maxrows in order to minimize impact of copyright notice in map
g.region n=56 s=47 w=5 e=16 res=0:00:10 -pa
# using WMS_GRASS driver
r.in.wms url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?" \
layer="OI.Mosaic.NaturalColor.Feathering" output="jrc_copernicus_core003_mosaik" \
maxcols=3400 maxrows=3400
r.info jrc_copernicus_core003_mosaik
# Alternatively, using WMS_GDAL driver with BIGTIFF and compression enabled
r.in.wms url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?" \
layer="OI.Mosaic.NaturalColor.Feathering" output="jrc_copernicus_core003_mosaik2" \
maxcols=3400 maxrows=3400 driver=WMS_GDAL gdal_createopt="BIGTIFF=YES,COMPRESS=DEFLATE"
r.info jrc_copernicus_core003_mosaik2
REQUIREMENTS
r.in.wms requires the gdalwarp utility from the GDAL/OGR library.
REFERENCES
SEE ALSO
r.in.gdal, r.patch, r.colors, r.composite, v.in.wfs
See also WMS support in wxGUI.
AUTHOR
Stepan Turek, Czech Technical University in Prague, Czech Republic
(bachelor's final project 2012, mentor: Martin Landa)
SOURCE CODE
Available at: r.in.wms source code
(history)
Latest change: Wednesday Feb 26 11:41:42 2025 in commit 8c9ef64