Find file
6c74e4e Jan 12, 2017
@blazek @wonder-sk @m-kuhn @3nids
81 lines (44 sloc) 3.09 KB
Example: url=
WCS URI is composed of key=value pairs separated by '&'. It is the same format like query string in URL, encoded the same way. QgsDataSourceUri should be used to construct the URI to ensure that special characters are encoded properly.
* url (required) : WCS Server URL. Do not use VERSION in URL, because each version of WCS is using different parameter name for GetCapabilities version, see param version.
* identifier (required) : Coverage name
* time (optional) : time position or time period (beginPosition/endPosition[/timeResolution])
* format (optional) : Supported format name. Default is the first supported format with tif in name or the first supported format.
* crs (optional) : CRS in form AUTHORITY:ID, e.g. EPSG:4326. Default is EPSG:4326 if supported or the first supported CRS.
* username (optional) : Username for basic authentication.
* password (optional) : Password for basic authentication.
* IgnoreGetMapUrl (optional,hack) : If specified (set to 1), ignore GetCoverage URL advertised by GetCapabilities. May be necessary if a server is not configured properly.
* InvertAxisOrientation (optional,hack) : If specified (set to 1), switch axis in GetCoverage request. May be necessary for geographic CRS if a server is using wrong axis order.
* IgnoreAxisOrientation (optional,hack) : If specified (set to 1), do not invert axis orientation according to WCS standard for geographic CRS.
* cache (optional) : cache load control, as described in QNetworkRequest::CacheLoadControl, but request is resend as PreferCache if failed with AlwaysCache. Allowed values: AlwaysCache, PreferCache, PreferNetwork, AlwaysNetwork. Default is AlwaysCache.
Python console example, adds new layer to map canvas:
from PyQt4.QtCore import QString
uri = QgsDataSourceUri()
uri.setParam ("url", "" )
uri.setParam ( "identifier", "band1_int16_noct_epsg4326" )
layer = QgsRasterLayer( QString(uri.encodedUri()), "WCS test", "wcs" )
another standalone script, downloads WCS layer to local file:
import sys
from qgis.core import *
from PyQt4.QtCore import QString
QgsApplication.setPrefixPath("/path/to/qgis/installation/", True)
app = QgsApplication(sys.argv,False) # important for QgsNetworkAccessManager
srcUri = QgsDataSourceUri()
srcUri.setParam ("url", "" )
srcUri.setParam ( "identifier", "band1_int16_noct_epsg4326" )
srcProvider = QgsProviderRegistry.instance().provider( "wcs", QString( srcUri.encodedUri()) )
if not srcProvider or not srcProvider.isValid():
print "Cannot create provider"
sys.exit ( 1 )
pipe = QgsRasterPipe()
if not pipe.set( srcProvider ):
print "Cannot set provider on pipe")
destUri = "/tmp/test.tif"
fileWriter = QgsRasterFileWriter ( destUri )
fileWriter.writeRaster( pipe, srcProvider.xSize(), srcProvider.ySize(), srcProvider.extent(), )