Vector renderers

Polygon rendering

Get some polygon data

borders <- raster::getData("GADM", country = "LUX", level = 2)

# add data
library(qgisremote)

iface.newProject()
## NULL
l <- iface.addVectorLayer(borders)

# get default renderer
r <- mapLayer.renderer(l)

# inspect renderer
as.character(r)
## [1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE xml>\n<renderer-v2 forceraster=\"0\" symbollevels=\"0\" type=\"singleSymbol\" enableorderby=\"0\">\n  <symbols>\n    <symbol alpha=\"1\" clip_to_extent=\"1\" type=\"fill\" name=\"0\">\n      <layer pass=\"0\" class=\"SimpleFill\" locked=\"0\">\n        <prop k=\"border_width_map_unit_scale\" v=\"0,0,0,0,0,0\"/>\n        <prop k=\"color\" v=\"115,186,252,255\"/>\n        <prop k=\"joinstyle\" v=\"bevel\"/>\n        <prop k=\"offset\" v=\"0,0\"/>\n        <prop k=\"offset_map_unit_scale\" v=\"0,0,0,0,0,0\"/>\n        <prop k=\"offset_unit\" v=\"MM\"/>\n        <prop k=\"outline_color\" v=\"0,0,0,255\"/>\n        <prop k=\"outline_style\" v=\"solid\"/>\n        <prop k=\"outline_width\" v=\"0.26\"/>\n        <prop k=\"outline_width_unit\" v=\"MM\"/>\n        <prop k=\"style\" v=\"solid\"/>\n      </layer>\n    </symbol>\n  </symbols>\n  <rotation/>\n  <sizescale scalemethod=\"diameter\"/>\n</renderer-v2>\n"
##           name                    attrname           value
## 1  renderer-v2                                            
## 2  renderer-v2                 forceraster               0
## 3  renderer-v2                symbollevels               0
## 4  renderer-v2                        type    singleSymbol
## 5  renderer-v2               enableorderby               0
## 6      symbols                                            
## 7       symbol                                            
## 8       symbol                       alpha               1
## 9       symbol              clip_to_extent               1
## 10      symbol                        type            fill
## 11      symbol                        name               0
## 12       layer                                            
## 13       layer                        pass               0
## 14       layer                       class      SimpleFill
## 15       layer                      locked               0
## 16       layer border_width_map_unit_scale     0,0,0,0,0,0
## 17       layer                       color 115,186,252,255
## 18       layer                   joinstyle           bevel
## 19       layer                      offset             0,0
## 20       layer       offset_map_unit_scale     0,0,0,0,0,0
## 21       layer                 offset_unit              MM
## 22       layer               outline_color       0,0,0,255
## 23       layer               outline_style           solid
## 24       layer               outline_width            0.26
## 25       layer          outline_width_unit              MM
## 26       layer                       style           solid
## 27    rotation                                            
## 28   sizescale                                            
## 29   sizescale                 scalemethod        diameter

Point (symbol) rendering

Raster renderers

Get some SRTM elevation data and add it to QGIS.

elevation <- raster::getData("alt", country = "DNK")

#iface.newProject()
l <- iface.addRasterLayer(elevation)
mapCanvas.zoomToFullExtent()
## [1] 3627760
r <- mapLayer.renderer(l)
as.character(r)
## [1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE xml>\n<QgsSingleBandGrayRenderer>\n  <rasterrenderer gradient=\"BlackToWhite\" opacity=\"1\" alphaBand=\"-1\" type=\"singlebandgray\" grayBand=\"1\">\n    <rasterTransparency/>\n    <contrastEnhancement>\n      <minValue>-0.988</minValue>\n      <maxValue>92.866</maxValue>\n      <algorithm>StretchToMinimumMaximum</algorithm>\n    </contrastEnhancement>\n  </rasterrenderer>\n</QgsSingleBandGrayRenderer>\n"
##                         name  attrname                               value
## 1  QgsSingleBandGrayRenderer           -0.98892.866StretchToMinimumMaximum
## 2             rasterrenderer           -0.98892.866StretchToMinimumMaximum
## 3             rasterrenderer  gradient                        BlackToWhite
## 4             rasterrenderer   opacity                                   1
## 5             rasterrenderer alphaBand                                  -1
## 6             rasterrenderer      type                      singlebandgray
## 7             rasterrenderer  grayBand                                   1
## 8         rasterTransparency                                              
## 9        contrastEnhancement           -0.98892.866StretchToMinimumMaximum
## 10                  minValue                                        -0.988
## 11                  maxValue                                        92.866
## 12                 algorithm                       StretchToMinimumMaximum