get_wfs {happign}R Documentation

Download WFS layer

Description

Read simple features from IGN Web Feature Service (WFS) from location and name of layer.

Usage

get_wfs(x = NULL,
        layer = NULL,
        filename = NULL,
        spatial_filter = "bbox",
        ecql_filter = NULL,
        overwrite = FALSE,
        interactive = FALSE)

Arguments

x

Object of class sf or sfc. Needs to be located in France.

layer

character; name of the layer from get_layers_metadata("wfs") or directly from IGN website

filename

character;Either a string naming a file or a connection open for writing. (ex : "test.shp" or "~/test.shp")

spatial_filter

character; spatial predicate from ECQL language. See detail and examples for more info.

ecql_filter

character; corresponding to an ECQL query. See detail and examples for more info.

overwrite

logical; if TRUE, file is overwrite.

interactive

character; if TRUE, no need to specify layer, you'll be ask.

Details

Value

sf object from sf package or NULL if no data.

See Also

get_layers_metadata()

Examples

## Not run: 
library(sf)
library(tmap)

# Shape from the best town in France
penmarch <- read_sf(system.file("extdata/penmarch.shp", package = "happign"))

# For quick testing, use interactive = TRUE
shape <- get_wfs(x = penmarch,
                 interactive = TRUE)

## Getting borders of best town in France
metadata_table <- get_layers_metadata("wfs", "administratif")
layer <- metadata_table[32,1] # LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune

# Downloading borders
borders <- get_wfs(penmarch, layer)

# Plotting result
qtm(borders, fill = NULL, borders = "firebrick") # easy map

# Get forest_area of the best town in France
forest_area <- get_wfs(x = borders,
                       layer = "LANDCOVER.FORESTINVENTORY.V1:resu_bdv1_shape")

qtm(forest_area, fill = "nom_typn")

# Using ECQL filters to query IGN server
## First find attributes of the layer
attrs <- get_wfs_attributes(layer)

## e.g. : find all commune's name starting by "plou"
plou_borders <- get_wfs(x = NULL, # When x is NULL, all France is query
                        layer = "LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune",
                        ecql_filter = "nom_m LIKE 'PLOU%'")
qtm(plou_borders)

## Combining ecql_filters
plou_borders_inf_2000 <- get_wfs(x = NULL, # When x is NULL, all France is query
                                 layer = "LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune",
                                 ecql_filter = "nom_m LIKE 'PLOU%' AND population < 2000")
qtm(plou_borders)+ qtm(plou_borders_inf_2000, fill = "red")

## End(Not run)

[Package happign version 0.3.0 Index]