Add a new vector layer to QGIS.
iface.addVectorLayer(x, baseName = NULL, ...) # S3 method for geo_json iface.addVectorLayer(x, baseName = NULL, crs = 4326, ...) # S3 method for sf iface.addVectorLayer(x, baseName = NULL, proj4 = FALSE, ...) # S3 method for list iface.addVectorLayer(x = list(url = NULL, layers = NULL, styles = NULL, format = "image/svg", crs = "EPSG:4326"), baseName = NULL, providerKey = "wfs", ...) # S3 method for default iface.addVectorLayer(x, baseName = NULL, providerKey = "ogr", proj4 = FALSE, ...)
| x | an object of class |
|---|---|
| baseName | name for the new layer to be displayed in the QGIS layers panel (will be filled by an appropriate default if missing) |
| ... | low-level parameters (such as |
| crs | QGIS-understandable EPSG id or specification string identifying
the coordinate reference system of the data (see |
| proj4 | logical (passed on to |
| providerKey | QGIS provider key (only applicable when |
A representation of the layer just added (of list of class qgislayer()).
geo_json: If given an object of class geo_json, adds it to QGIS through a HTTP POST
request. GeoJSON does not contain information on the coordinate reference
system of the data, which must be passed explicitly using the crs
argument (defaults to EPSG 4326).
sf: If x is an object of class sf or one of sp's Spatial* classes,
converts the spatial data to GeoJSON and adds it to QGIS through a HTTP
POST request. Many other geospatial formats can be added through this
function by first converting them to sf objects using sf::st_as_sf().
list: When passed a named list, compiles a WFS service provider string based on
the named options found in the list by concatenating their entries in the
format name1=value1&name2=value2&..., then tries to add this as a vector
layer.
default: When x is a simple character string, it is assumed to be a QGIS provider
string denoting a local or external resource, and instructs QGIS to add the
resource from that provider url using the engine specified by the given
providerKey. It is the user's responsibility to make sure that the
machine on which the QGIS Network API is running is able to access and read
the resource.
qgislayer(), mapLayer(), mapLayers(), iface.addRasterLayer(), iface.addTileLayer()
botswana <- raster::getData('GADM', country = 'BWA', level = 2) iface.addVectorLayer(botswana, baseName = 'Botswana admin boundaries')#>#>#> QGIS map layer with the following properties: #> crs: CRS arguments: #> +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 #> valid: [1] TRUE #> name: [1] "Botswana admin boundaries OGRGeoJSON Polygon" #> extent: [1] 19.99953 -26.90738 29.36831 -17.78081 #> publicSource: [1] "/tmp/tmptxTYv5" #> type: [1] 0 #> id: [1] "Botswana_admin_boundaries20170831104311027" #> isEditable: [1] FALSE