WFS tutorial doesn't run on my machine
Closed this issue · 12 comments
This returns an empty set on my machine. @JoFAM reached out to me with a similar problem.
> library(sf)
Linking to GEOS 3.7.1, GDAL 2.4.2, PROJ 5.2.0
> library(httr)
> library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.2 ✔ purrr 0.3.4
✔ tibble 3.0.3 ✔ dplyr 1.0.2
✔ tidyr 1.1.2 ✔ stringr 1.4.0
✔ readr 1.3.1 ✔ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 4.0.2 (2020-06-22)
os Ubuntu 18.04.5 LTS
system x86_64, linux-gnu
ui X11
language nl_BE:nl
collate nl_BE.UTF-8
ctype nl_BE.UTF-8
tz Europe/Brussels
date 2020-09-21
─ Packages ───────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2)
blob 1.2.1 2020-01-20 [1] CRAN (R 4.0.0)
broom 0.7.0 2020-07-09 [1] CRAN (R 4.0.2)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.0.0)
class 7.3-17 2020-04-26 [4] CRAN (R 4.0.0)
classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.0)
dbplyr 1.4.4 2020-05-27 [1] CRAN (R 4.0.2)
dplyr * 1.0.2 2020-08-18 [1] CRAN (R 4.0.2)
e1071 1.7-3 2019-11-26 [1] CRAN (R 4.0.0)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
forcats * 0.5.0 2020-03-01 [1] CRAN (R 4.0.0)
fortunes 1.5-4 2016-12-29 [1] CRAN (R 4.0.0)
fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.0)
ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.0)
haven 2.3.1 2020-06-01 [1] CRAN (R 4.0.2)
hms 0.5.3 2020-01-08 [1] CRAN (R 4.0.0)
httr * 1.4.2 2020-07-20 [1] CRAN (R 4.0.2)
jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.2)
KernSmooth 2.23-17 2020-04-26 [4] CRAN (R 4.0.0)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
lubridate 1.7.9 2020-06-08 [1] CRAN (R 4.0.2)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
modelr 0.1.8 2020-05-19 [1] CRAN (R 4.0.2)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.0)
pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
readr * 1.3.1 2018-12-21 [1] CRAN (R 4.0.0)
readxl 1.3.1 2019-03-13 [1] CRAN (R 4.0.0)
reprex 0.3.0 2019-05-16 [1] CRAN (R 4.0.0)
rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0)
rvest 0.3.6 2020-07-25 [1] CRAN (R 4.0.2)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2)
sf * 0.9-6 2020-09-13 [1] CRAN (R 4.0.2)
stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.0.0)
tibble * 3.0.3 2020-07-10 [1] CRAN (R 4.0.2)
tidyr * 1.1.2 2020-08-27 [1] CRAN (R 4.0.2)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.0)
tidyverse * 1.3.0 2019-11-21 [1] CRAN (R 4.0.0)
units 0.6-7 2020-06-13 [1] CRAN (R 4.0.2)
vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2)
withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0)
xml2 1.3.2 2020-04-23 [1] CRAN (R 4.0.0)
[1] /home/thierry/R/x86_64-pc-linux-gnu-library/4.0
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
It works for me (on Windows). Could it be OS related? @florisvdh can you reproduce @ThierryO result on Linux?
EDIT: If you paste the request
string in a browser do you get this? My request string looks like this: https://eservices.minfin.fgov.be/arcgis/services/R2C/Regions/MapServer/WFSServer?service=wfs&version=2.0.0&request=GetFeature&typename=regions&srsName=EPSG%3A4326&outputFormat=GEOJSON
It might be an issue due the GDAL, GEOS, PROJ versions. What version do you have installed?
I get the same as @hansvancalster
> request
[1] "https://eservices.minfin.fgov.be/arcgis/services/R2C/Regions/MapServer/WFSServer?service=wfs&version=2.0.0&request=GetFeature&typename=regions&srsName=EPSG%3A4326&outputFormat=GEOJSON"
> sf::sf_extSoftVersion()
GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
"3.8.0" "3.0.4" "6.3.1" "true" "true"
Session info
─ Session info ─────────────────────────────────────────────────────────────────────────
setting value
version R version 4.0.2 (2020-06-22)
os Linux Mint 20
system x86_64, linux-gnu
ui RStudio
language nl_BE:nl
collate nl_BE.UTF-8
ctype nl_BE.UTF-8
tz Europe/Brussels
date 2020-09-21
─ Packages ─────────────────────────────────────────────────────────────────────────────
package * version date lib source
askpass 1.1 2019-01-13 [1] CRAN (R 4.0.2)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2)
blob 1.2.1 2020-01-20 [1] CRAN (R 4.0.2)
blogdown 0.20 2020-06-23 [1] CRAN (R 4.0.2)
bookdown 0.20 2020-06-23 [1] CRAN (R 4.0.2)
broom 0.7.0 2020-07-09 [1] CRAN (R 4.0.2)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.0.2)
class 7.3-17 2020-04-26 [4] CRAN (R 4.0.0)
classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.2)
cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.2)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.2)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.2)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.2)
DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.2)
dbplyr 1.4.4.9000 2020-08-17 [1] Github (florisvdh/dbplyr@f5d0df9)
digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.2)
dplyr * 1.0.2 2020-08-18 [1] CRAN (R 4.0.2)
e1071 1.7-3 2019-11-26 [1] CRAN (R 4.0.2)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.2)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.2)
forcats * 0.5.0 2020-03-01 [1] CRAN (R 4.0.2)
fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.2)
geometa * 0.6-3 2020-08-04 [1] CRAN (R 4.0.2)
ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.2)
haven 2.3.1 2020-06-01 [1] CRAN (R 4.0.2)
hms 0.5.3 2020-01-08 [1] CRAN (R 4.0.2)
htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
httr * 1.4.2 2020-07-20 [1] CRAN (R 4.0.2)
jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.2)
KernSmooth 2.23-17 2020-04-26 [4] CRAN (R 4.0.0)
knitr * 1.29 2020-06-23 [1] CRAN (R 4.0.2)
lattice 0.20-41 2020-04-02 [4] CRAN (R 4.0.0)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.2)
lubridate 1.7.9 2020-06-08 [1] CRAN (R 4.0.2)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.2)
modelr 0.1.8 2020-05-19 [1] CRAN (R 4.0.2)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.2)
openssl 1.4.2 2020-06-27 [1] CRAN (R 4.0.2)
ows4R * 0.1-5 2020-05-27 [1] CRAN (R 4.0.2)
pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.0.2)
R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.2)
Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
readr * 1.3.1 2018-12-21 [1] CRAN (R 4.0.2)
readxl 1.3.1 2019-03-13 [1] CRAN (R 4.0.2)
reprex 0.3.0 2019-05-16 [1] CRAN (R 4.0.2)
rgdal 1.5-16 2020-08-07 [1] CRAN (R 4.0.2)
rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2)
rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.2)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.2)
rvest 0.3.6 2020-07-25 [1] CRAN (R 4.0.2)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.2)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2)
sf * 0.9-5 2020-07-14 [1] CRAN (R 4.0.2)
sp 1.4-2 2020-05-20 [1] CRAN (R 4.0.2)
stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.0.2)
tibble * 3.0.3 2020-07-10 [1] CRAN (R 4.0.2)
tidyr * 1.1.2 2020-08-27 [1] CRAN (R 4.0.2)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2)
tidyverse * 1.3.0 2019-11-21 [1] CRAN (R 4.0.2)
units 0.6-7 2020-06-13 [1] CRAN (R 4.0.2)
vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2)
withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.2)
xfun 0.17 2020-09-09 [1] CRAN (R 4.0.2)
XML 3.99-0.5 2020-07-23 [1] CRAN (R 4.0.2)
xml2 1.3.2 2020-04-23 [1] CRAN (R 4.0.2)
yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.2)
[1] /home/floris/lib/R/library
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
And this is the result:
> bel_regions <- read_sf(request) #Lambert2008
> bel_regions
Simple feature collection with 3 features and 8 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 2.541327 ymin: 49.49696 xmax: 6.408098 ymax: 51.50511
geographic CRS: WGS 84
# A tibble: 3 x 9
AdReKey RecId AdCoKey NameFRE NameDUT NameGER FiscSitId LastUpdDTS
<chr> <int> <chr> <chr> <chr> <chr> <int> <chr>
1 02000 301 01000 Région… Vlaams… Flämis… 5 26/03/202…
2 03000 302 01000 Region… Waals … Wallon… 5 26/03/202…
3 04000 303 01000 Région… Brusse… Region… 5 26/03/202…
# … with 1 more variable: geometry <POLYGON [°]>
It might be an issue due the GDAL, GEOS, PROJ versions. What version do you have installed?
sf::sf_extSoftVersion()
GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
"3.8.0" "3.0.4" "6.3.1" "true" "true"
I can also test it in an environment with GDAL 2 and PROJ 4 if you like, but that might not be for today (need to reboot etc.). If read_sf(request)
would work for one and not for another GDAL/PROJ version, it may be an issue in sf
, or maybe a limitation of the WFS itself.
@ThierryO did you try rerunning the code? It could just have been temporal unavailability of the server?
Seems like I still have older versions of GDAL and co. @florisvdh how did you installed the new versions? I can't find an apt-get repo with GDAL >= 3
It seems like an error parsing the JSON
> wfs_regions <- "https://eservices.minfin.fgov.be/arcgis/services/R2C/Regions/MapServer/WFSServer"
> url <- parse_url(wfs_regions)
> url$query <- list(service = "wfs",
+ version = "2.0.0",
+ request = "GetFeature",
+ typename = "regions",
+ srsName = "EPSG:4326",
+ outputFormat = "GEOJSON")
> request <- build_url(url)
> bel_regions <- read_sf(request)
There were 36 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In CPL_read_ogr(dsn, layer, query, as.character(options), ... :
GDAL Error 1: JSON parsing error: continue (at offset 1)
2: In CPL_read_ogr(dsn, layer, query, as.character(options), ... :
GDAL Error 1: JSON parsing error: continue (at offset 3)
3: In CPL_read_ogr(dsn, layer, query, as.character(options), ... :
GDAL Error 1: JSON parsing error: unexpected character (at offset 5)
> bel_regions
Simple feature collection with 0 features and 0 fields
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
CRS: 4326
# A tibble: 0 x 1
# … with 1 variable: geometry <GEOMETRY [°]>
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
It will give you PROJ 7.0 & GDAL 3.0.4 on Bionic 😄 . Focal packages are still rather absent from this PPA, though.
But with GDAL 2 perhaps you could try another outputFormat
than GeoJSON? I'm not familiar with the possibilities, though.
I was using the stable ppa. Using the unstable ppa, upgrading GDAL, GEOS, PROJ and reinstalling rgdal, rgeos and sf solved the problem.
@JoFAM: please check if you're using a recent version of GEOS, GDAL and PROJ.
> sf::sf_extSoftVersion()
GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
"3.8.0" "3.0.4" "7.0.0" "true" "true"