0

Inside a plugin i'm trying to load a wms layer, with python in QGIS. Everything works but the size doesn't match: is downloading the entire wms layer not the extent of the window i'm using in QGIS (cropped size). What i'm missing? Here is a sample of the request:

e = self.iface.mapCanvas().extent()
bbox = str(e.xMinimum())+","+str(e.yMinimum())+","+str(e.xMaximum())+","+str(e.yMaximum())
url = "http://myserver.com:8080/geoserver/ows"
serviceType = "wms"
urlWithParams = f"crs=EPSG:{epsg}&format=image/png&layers={layer_name}&styles&url={url}&bbox={bbox}"
QgsRasterLayer(urlWithParams, temp_layer_name , 'wms')
3
  • in the extent in the proper crs? – Al rl Jan 26 at 23:59
  • I would guess that your epsg code is degrees based like 4326, but your bbox is using some other unit. If you pass a bbox with values greater than +/-180 you'll get the whole globe – nmtoken Jan 27 at 8:32
  • 1
    Can you give an example of the generated GetMap request sent – nmtoken Jan 27 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.