I have the following problem according to different sources it should be able to read WFS layer in R using rgdal
.
dsn<-"WFS:http://geomap.reteunitaria.piemonte.it/ws/gsareprot/rp-01/areeprotwfs/wfs_gsareprot_1?service=WFS&request=getCapabilities"
ogrListLayers(dsn)
readOGR(dsn,"SIC")
The result of that code should be 1) to list the available WFS layer and 2) to read a specific Layer (SIC) into R as a Spatial(Points)DataFrame.
I tried several other WFS server but it does not work. I always get the warning:
Cannot open data source
Checking for the WFS driver i get the following result:
> "WFS" %in% ogrDrivers()$name
[1] FALSE
Well it looks like the WFS driver is not implemented in rgdal (anymore?) Or why are there so many examples "claiming" the opposite?
I also tried the gdalUtils
package and well it works but It gives out the whole console message of ogrinfo.exe and not only the available layers.(I guess it "just" calls the ogrinfo.exe and sends the result back to R like using the r shell
or system
command).
Well does anyone know what I´m making wrong, or if something like that is even possible with rgdal
or any similar package?
You can combine the two packages to accomplish your task.
First, convert the layer you need into a local shapefile using
gdalUtils
. Then, usergdal
as normal. NOTE: you'll see a warning message after theogr2ogr
call but it performed the conversion fine for me. Also,ogr2ogr
won't overwrite local files without theoverwrite
parameter beingTRUE
(there are other parameters that may be of use as well).