BAG API - Some layers give a GDAL Error

Hi,

I am calling the BAG database from R with the sf-package. There are multiple layers which I can extract

  • BAG
  • ligplaats
  • standplaats
  • pand
  • verblijfsobject
  • woonplaats

I don’t have any problems with extracting the layers standplaats and ligplaats, however if I want to extract the layer BAG or pand. I did not try verblijfsobject or woonplaats yet.

If I extract BAG, I will get the following error:

1: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
GDAL Error 1: HTTP error code : 500
2: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
GDAL Error 1: Error returned by server : HTTP error code : 500 (0)

If I extract Pand, I will get another error:

Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  : 
  attempt to set index 1244200/1244200 in SET_STRING_ELT
In addition: Warning messages:
1: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 1: HTTP error code : 502
2: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 1: Error returned by server : HTTP error code : 502 (0)

Does anyone know how to solve these errors?

Hi @susan

Which/what BAG endpoint are you using?
Do you have a example request that is generated by R?
Or maybe a time(stamp), so we can look in our logging around that moment?

I do see that yesterday around 16u-17u we had some issue with our (old) bag end-point.
With requests like: https://geodata.nationaalgeoregister.nl/bag/wfs?service=WFS&version=2.0.0&request=GetFeature&count=100&typename=bag:pand&outputformat=json&startindex=8685000
These generated at that moment a lot of HTTP 502 responses at our end.

Question: Are you trying to ‘download’ the entire BAG through the WFS?

Hi @wouter.visscher,

I am experimenting with the API. I think the code in R I am using, you always try to “download” the data, since you set a temporary connection and it stores it locally.

We might want to use some of the BAG data in our research, so we want to create a static dataset, due to scientific integrity and reproducibility of our research.

The R code that I am using is relatively simple:

#load in libraries
library(sf)

#WFS-url
url ← “https://geodata.nationaalgeoregister.nl/bag/wfs/v1_1?request=getCapabilities&service=WFS

#Check the type of layers, this code takes some time, so the results are commented in my code
#layers ← st_layers(url)
#names ← unlist(layers[1])

#the list of names is
#“bag:bag” “bag:ligplaats” “bag:pand”
#“bag:standplaats” “bag:verblijfsobject” “bag:woonplaats”

#Read in the layer pand
pand ← st_read(url, layer = ‘bag:pand’)

Since we do not yet exactly know our research area, I used the WFS-server stated on the PDOK website. Maybe I should narrow down data extract, however I have no clue how to do this exactly? This was not very clear on the PDOK website.

If you need a static dataset you could use the “inspireadressen”: https://geodata.nationaalgeoregister.nl/inspireadressen/extract/inspireadressen.zip

This download contains the complet BAG dataset of the last month. I presume you could probably import this into R.

The main difference between the bag/wfs/1_1? and this extract (other then API vs direct download) is that the download contains the original datamodel, where the bag/wfs/1_1? is a “derivative” product where the objects are simplified.