AHN3 Python request DynamoRevit

Ik probeer een request uit te voeren waarbij ik AHN data binnen kan halen d.m.v. python binnenin Dynamo for Revit. De requests die ik heb geprobeert zijn:

url = "https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=2.0.1&Request=GetCoverage&CoverageID=ahn3_05m_dtm&BBOX=104446,485940,104746,486240&CRS=EPSG:28992outputFormat=application/json"
OUT = requests.get(url)


url = "https://geodata.nationaalgeoregister.nl/ahn3/wms?request=ahn3_05m_dtm&bbox=104446,485940,104746,486240&srs=EPSG:28992&outputFormat=application/Geotiff"
OUT= requests.get(url)


url = "https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=1.0.0&Request=GetCoverage&Coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=bbox=104446,485940,104746,486240&outputFormat=GEOTIFF "
OUT= requests.get(url)'

Ik snap alleen niet hoe ik de output moet interpreteren. Graag zou ik puntcoördinaten ontvangen maar ik krijg het onderstaande. Dit zijn vier lijsten waarvan de eerste drie lijsten 128 items bevatten met verschillende waarden en de laatste lijst heeft een afwijkende grootte. Weet iemand wat deze lijsten representeren?

[0] [0] 60
[0] [1] 63
[0] [2] 120
[0] [3] 109
[0] [4] 108
[0] [5] 32
[0] [6] 118
[0] [7] 101
[0] [8] 114
[0] [9] 115
[0] [10] 105
[0] [11] 111
[0] [12] 110
[0] [13] 61
[0] [14] 34
[0] [15] 49
[0] [16] 46
[0] [17] 48
[0] [18] 34
[0] [19] 32
[0] [20] 101
[0] [21] 110
[0] [22] 99
[0] [23] 111
[0] [24] 100
[0] [25] 105
[0] [26] 110
[0] [27] 103
[0] [28] 61
[0] [29] 34
[0] [30] 85
[0] [31] 84
[0] [32] 70
[0] [33] 45
[0] [34] 56
[0] [35] 34
[0] [36] 63
[0] [37] 62
[0] [38] 10
[0] [39] 60
[0] [40] 111
[0] [41] 119
[0] [42] 115
[0] [43] 58
[0] [44] 69
[0] [45] 120
[0] [46] 99
[0] [47] 101
[0] [48] 112
[0] [49] 116
[0] [50] 105
[0] [51] 111
[0] [52] 110
[0] [53] 82
[0] [54] 101
[0] [55] 112
[0] [56] 111
[0] [57] 114
[0] [58] 116
[0] [59] 32
[0] [60] 120
[0] [61] 109
[0] [62] 108
[0] [63] 110
[0] [64] 115
[0] [65] 58
[0] [66] 111
[0] [67] 119
[0] [68] 115
[0] [69] 61
[0] [70] 34
[0] [71] 104
[0] [72] 116
[0] [73] 116
[0] [74] 112
[0] [75] 58
[0] [76] 47
[0] [77] 47
[0] [78] 119
[0] [79] 119
[0] [80] 119
[0] [81] 46
[0] [82] 111
[0] [83] 112
[0] [84] 101
[0] [85] 110
[0] [86] 103
[0] [87] 105
[0] [88] 115
[0] [89] 46
[0] [90] 110
[0] [91] 101
[0] [92] 116
[0] [93] 47
[0] [94] 111
[0] [95] 119
[0] [96] 115
[0] [97] 47
[0] [98] 50
[0] [99] 46
[0] [100] 48
[0] [101] 34
[0] [102] 32
[0] [103] 120
[0] [104] 109
[0] [105] 108
[0] [106] 110
[0] [107] 115
[0] [108] 58
[0] [109] 120
[0] [110] 115
[0] [111] 105
[0] [112] 61
[0] [113] 34
[0] [114] 104
[0] [115] 116
[0] [116] 116
[0] [117] 112
[0] [118] 58
[0] [119] 47
[0] [120] 47
[0] [121] 119
[0] [122] 119
[0] [123] 119
[0] [124] 46
[0] [125] 119
[0] [126] 51
[0] [127] 46
[1] [0] 111
[1] [1] 114
[1] [2] 103
[1] [3] 47
[1] [4] 50
[1] [5] 48
[1] [6] 48
[1] [7] 49
[1] [8] 47
[1] [9] 88
[1] [10] 77
[1] [11] 76
[1] [12] 83
[1] [13] 99
[1] [14] 104
[1] [15] 101
[1] [16] 109
[1] [17] 97
[1] [18] 45
[1] [19] 105
[1] [20] 110
[1] [21] 115
[1] [22] 116
[1] [23] 97
[1] [24] 110
[1] [25] 99
[1] [26] 101
[1] [27] 34
[1] [28] 32
[1] [29] 118
[1] [30] 101
[1] [31] 114
[1] [32] 115
[1] [33] 105
[1] [34] 111
[1] [35] 110
[1] [36] 61
[1] [37] 34
[1] [38] 50
[1] [39] 46
[1] [40] 48
[1] [41] 46
[1] [42] 49
[1] [43] 34
[1] [44] 32
[1] [45] 120
[1] [46] 109
[1] [47] 108
[1] [48] 58
[1] [49] 108
[1] [50] 97
[1] [51] 110
[1] [52] 103
[1] [53] 61
[1] [54] 34
[1] [55] 101
[1] [56] 110
[1] [57] 45
[1] [58] 85
[1] [59] 83
[1] [60] 34
[1] [61] 32
[1] [62] 120
[1] [63] 115
[1] [64] 105
[1] [65] 58
[1] [66] 115
[1] [67] 99
[1] [68] 104
[1] [69] 101
[1] [70] 109
[1] [71] 97
[1] [72] 76
[1] [73] 111
[1] [74] 99
[1] [75] 97
[1] [76] 116
[1] [77] 105
[1] [78] 111
[1] [79] 110
[1] [80] 61
[1] [81] 34
[1] [82] 104
[1] [83] 116
[1] [84] 116
[1] [85] 112
[1] [86] 58
[1] [87] 47
[1] [88] 47
[1] [89] 119
[1] [90] 119
[1] [91] 119
[1] [92] 46
[1] [93] 111
[1] [94] 112
[1] [95] 101
[1] [96] 110
[1] [97] 103
[1] [98] 105
[1] [99] 115
[1] [100] 46
[1] [101] 110
[1] [102] 101
[1] [103] 116
[1] [104] 47
[1] [105] 111
[1] [106] 119
[1] [107] 115
[1] [108] 47
[1] [109] 50
[1] [110] 46
[1] [111] 48
[1] [112] 32
[1] [113] 104
[1] [114] 116
[1] [115] 116
[1] [116] 112
[1] [117] 115
[1] [118] 58
[1] [119] 47
[1] [120] 47
[1] [121] 103
[1] [122] 101
[1] [123] 111
[1] [124] 100
[1] [125] 97
[1] [126] 116
[1] [127] 97
[2] [0] 46
[2] [1] 110
[2] [2] 97
[2] [3] 116
[2] [4] 105
[2] [5] 111
[2] [6] 110
[2] [7] 97
[2] [8] 97
[2] [9] 108
[2] [10] 103
[2] [11] 101
[2] [12] 111
[2] [13] 114
[2] [14] 101
[2] [15] 103
[2] [16] 105
[2] [17] 115
[2] [18] 116
[2] [19] 101
[2] [20] 114
[2] [21] 46
[2] [22] 110
[2] [23] 108
[2] [24] 47
[2] [25] 111
[2] [26] 119
[2] [27] 115
[2] [28] 47
[2] [29] 50
[2] [30] 46
[2] [31] 48
[2] [32] 47
[2] [33] 111
[2] [34] 119
[2] [35] 115
[2] [36] 69
[2] [37] 120
[2] [38] 99
[2] [39] 101
[2] [40] 112
[2] [41] 116
[2] [42] 105
[2] [43] 111
[2] [44] 110
[2] [45] 82
[2] [46] 101
[2] [47] 112
[2] [48] 111
[2] [49] 114
[2] [50] 116
[2] [51] 46
[2] [52] 120
[2] [53] 115
[2] [54] 100
[2] [55] 34
[2] [56] 62
[2] [57] 10
[2] [58] 32
[2] [59] 32
[2] [60] 60
[2] [61] 111
[2] [62] 119
[2] [63] 115
[2] [64] 58
[2] [65] 69
[2] [66] 120
[2] [67] 99
[2] [68] 101
[2] [69] 112
[2] [70] 116
[2] [71] 105
[2] [72] 111
[2] [73] 110
[2] [74] 32
[2] [75] 101
[2] [76] 120
[2] [77] 99
[2] [78] 101
[2] [79] 112
[2] [80] 116
[2] [81] 105
[2] [82] 111
[2] [83] 110
[2] [84] 67
[2] [85] 111
[2] [86] 100
[2] [87] 101
[2] [88] 61
[2] [89] 34
[2] [90] 73
[2] [91] 110
[2] [92] 118
[2] [93] 97
[2] [94] 108
[2] [95] 105
[2] [96] 100
[2] [97] 80
[2] [98] 97
[2] [99] 114
[2] [100] 97
[2] [101] 109
[2] [102] 101
[2] [103] 116
[2] [104] 101
[2] [105] 114
[2] [106] 86
[2] [107] 97
[2] [108] 108
[2] [109] 117
[2] [110] 101
[2] [111] 34
[2] [112] 32
[2] [113] 108
[2] [114] 111
[2] [115] 99
[2] [116] 97
[2] [117] 116
[2] [118] 111
[2] [119] 114
[2] [120] 61
[2] [121] 34
[2] [122] 115
[2] [123] 105
[2] [124] 122
[2] [125] 101
[2] [126] 34
[2] [127] 62
[3] [0] 10
[3] [1] 32
[3] [2] 32
[3] [3] 32
[3] [4] 32
[3] [5] 60
[3] [6] 111
[3] [7] 119
[3] [8] 115
[3] [9] 58
[3] [10] 69
[3] [11] 120
[3] [12] 99
[3] [13] 101
[3] [14] 112
[3] [15] 116
[3] [16] 105
[3] [17] 111
[3] [18] 110
[3] [19] 84
[3] [20] 101
[3] [21] 120
[3] [22] 116
[3] [23] 62
[3] [24] 109
[3] [25] 115
[3] [26] 87
[3] [27] 67
[3] [28] 83
[3] [29] 71
[3] [30] 101
[3] [31] 116
[3] [32] 67
[3] [33] 111
[3] [34] 118
[3] [35] 101
[3] [36] 114
[3] [37] 97
[3] [38] 103
[3] [39] 101
[3] [40] 50
[3] [41] 48
[3] [42] 40
[3] [43] 41
[3] [44] 58
[3] [45] 32
[3] [46] 87
[3] [47] 67
[3] [48] 83
[3] [49] 32
[3] [50] 115
[3] [51] 101
[3] [52] 114
[3] [53] 118
[3] [54] 101
[3] [55] 114
[3] [56] 32
[3] [57] 101
[3] [58] 114
[3] [59] 114
[3] [60] 111
[3] [61] 114
[3] [62] 46
[3] [63] 32
[3] [64] 82
[3] [65] 97
[3] [66] 115
[3] [67] 116
[3] [68] 101
[3] [69] 114
[3] [70] 32
[3] [71] 115
[3] [72] 105
[3] [73] 122
[3] [74] 101
[3] [75] 32
[3] [76] 111
[3] [77] 117
[3] [78] 116
[3] [79] 32
[3] [80] 111
[3] [81] 102
[3] [82] 32
[3] [83] 114
[3] [84] 97
[3] [85] 110
[3] [86] 103
[3] [87] 101
[3] [88] 44
[3] [89] 32
[3] [90] 119
[3] [91] 105
[3] [92] 100
[3] [93] 116
[3] [94] 104
[3] [95] 32
[3] [96] 97
[3] [97] 110
[3] [98] 100
[3] [99] 32
[3] [100] 104
[3] [101] 101
[3] [102] 105
[3] [103] 103
[3] [104] 104
[3] [105] 116
[3] [106] 32
[3] [107] 111
[3] [108] 102
[3] [109] 32
[3] [110] 114
[3] [111] 101
[3] [112] 115
[3] [113] 117
[3] [114] 108
[3] [115] 116
[3] [116] 105
[3] [117] 110
[3] [118] 103
[3] [119] 32
[3] [120] 99
[3] [121] 111
[3] [122] 118
[3] [123] 101
[3] [124] 114
[3] [125] 97
[3] [126] 103
[3] [127] 101
[4] [0] 32
[4] [1] 109
[4] [2] 117
[4] [3] 115
[4] [4] 116
[4] [5] 32
[4] [6] 98
[4] [7] 101
[4] [8] 32
[4] [9] 110
[4] [10] 111
[4] [11] 32
[4] [12] 109
[4] [13] 111
[4] [14] 114
[4] [15] 101
[4] [16] 32
[4] [17] 116
[4] [18] 104
[4] [19] 97
[4] [20] 110
[4] [21] 32
[4] [22] 77
[4] [23] 65
[4] [24] 88
[4] [25] 83
[4] [26] 73
[4] [27] 90
[4] [28] 69
[4] [29] 61
[4] [30] 52
[4] [31] 48
[4] [32] 48
[4] [33] 48
[4] [34] 46
[4] [35] 60
[4] [36] 47
[4] [37] 111
[4] [38] 119
[4] [39] 115
[4] [40] 58
[4] [41] 69
[4] [42] 120
[4] [43] 99
[4] [44] 101
[4] [45] 112
[4] [46] 116
[4] [47] 105
[4] [48] 111
[4] [49] 110
[4] [50] 84
[4] [51] 101
[4] [52] 120
[4] [53] 116
[4] [54] 62
[4] [55] 10
[4] [56] 32
[4] [57] 32
[4] [58] 60
[4] [59] 47
[4] [60] 111
[4] [61] 119
[4] [62] 115
[4] [63] 58
[4] [64] 69
[4] [65] 120
[4] [66] 99
[4] [67] 101
[4] [68] 112
[4] [69] 116
[4] [70] 105
[4] [71] 111
[4] [72] 110
[4] [73] 62
[4] [74] 10
[4] [75] 60
[4] [76] 47
[4] [77] 111
[4] [78] 119
[4] [79] 115
[4] [80] 58
[4] [81] 69
[4] [82] 120
[4] [83] 99
[4] [84] 101
[4] [85] 112
[4] [86] 116
[4] [87] 105
[4] [88] 111
[4] [89] 110
[4] [90] 82
[4] [91] 101
[4] [92] 112
[4] [93] 111
[4] [94] 114
[4] [95] 116
[4] [96] 62
[4] [97] 10

Ik kan je alleen zeggen dat het in ieder geval niet AHN xyz is. Denk dat het best lastig is om een directe link te leggen. Voor mij werkt het handiger om vooraf iets voor te bereiden en als xyz bestand weg te schrijven.

@DJVD er zijn twee zaken die je moet verifieren alvorens de response van de OGC webservice verder in je applicatie te consumeren:

  • is het request succesvol, d.w.z. krijg ik een HTTP 200 OK response terug
  • matched de Content-Type response header met hetgeen wat ik heb opgevraagd

Het probleem is namelijk dat de “oude” OGC Webservice-types (WMS, WFS, WCS, etc.) bijna altijd een HTTP 200 response teruggeven. Ook als de service geen response kan genereren als antwoord op je request. In dat geval krijg je veelal een XML document terug met de foutmelding, dan zie je in de Content-Type response header de volgende waarde (of een variatie daarop): application/vnd.ogc.se_xml

Als we gaan kijken of je requests voldoen aan beide voorwaarden (HTTP 200 OK response, Content-Type matched met gevraagd content-type) dan zie je dat geen van de requests succesvol zijn beantwoord door de service:

# request 1 - Content-Type matched niet
curl -sD - "https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=1.0.0&Request=GetCoverage&Coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=bbox=104446,485940,104746,486240&outputFormat=GEOTIFF" -o /dev/null
HTTP/1.1 200 OK
Date: Tue, 07 Feb 2023 10:19:33 GMT
Server: lighttpd/1.4.53-devel-lighttpd-1.4.53
Content-Length: 529
Content-Type: application/vnd.ogc.se_xml; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, HEAD
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers: SOAPAction,X-Requested-With,Content-Type,Origin,Authorization,Accept

# request 2 - Content-Type matched niet
 curl -sD - "https://geodata.nationaalgeoregister.nl/ahn3/wms?request=ahn3_05m_dtm&bbox=104446,485940,104746,486240&srs=EPSG:28992&outputFormat=application/Geotiff" -o /dev/null
HTTP/1.1 200 
Date: Tue, 07 Feb 2023 10:28:21 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Content-Length: 370
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, HEAD
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers: SOAPAction,X-Requested-With,Content-Type,Origin,Authorization,Accept

# request 3 - Content-Type matched niet
curl -sD - "https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=1.0.0&Request=GetCoverage&Coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=bbox=104446,485940,104746,486240&outputFormat=GEOTIFF" -o /dev/null
HTTP/1.1 200 OK
Date: Tue, 07 Feb 2023 10:28:25 GMT
Server: lighttpd/1.4.53-devel-lighttpd-1.4.53
Content-Length: 529
Content-Type: application/vnd.ogc.se_xml; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, HEAD
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers: SOAPAction,X-Requested-With,Content-Type,Origin,Authorization,Accept

N.B. De geodata.nationaalgeoregister.nl AHN3 services gaan per 17-02-2023 uit, zie Nieuwe URL’s AHN3 en Luchtfoto labels na cloudmigratie. Er zijn vervangende services zie hiervoor het geoforum bericht.

Nu is de vraag waarom falen deze requests? Hieronder per request een antwoord.

Request 1

  • https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=2.0.1&Request=GetCoverage&CoverageID=ahn3_05m_dtm&BBOX=104446,485940,104746,486240&CRS=EPSG:28992outputFormat=application/json

Je vraag outputFormat application/json op maar dat is geen outputFormat wat de WCS service aan biedt. Zie het capabilities document voor een lijst van outputformats:

N.B. Dit is het capabilities document voor WCS versie 2.0. De WCS service ondersteunt meerdere WCS versies. De 1.0.0 versie bevat geen lijst met outputFormats in het capabilities document, om deze op te halen dien je een describeCoverage request te doen (bij versie 1.0.0)

Request 2

https://geodata.nationaalgeoregister.nl/ahn3/wms?request=ahn3_05m_dtm&bbox=104446,485940,104746,486240&srs=EPSG:28992&outputFormat=application/Geotiff

De WMS service biedt geen outputFormat GeoTiff aan, zie wederom het capabilities document. Daarbij dient in de request parameter een request type te worden ingevuld wat de service ondersteunt, zie de capabilities voor de lijst van request types (dus GetCapabilities, GetFeatureInfo, GetMap:

Request 3

https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=1.0.0&Request=GetCoverage&Coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=bbox=104446,485940,104746,486240&outputFormat=GEOTIFF

De BBOX query parameter is niet geldig, want bevat nog eens bbox=. Daarnaast ontbreek een resx en resy parameter voor de WCS service om te bepalen met welke resolutie die het raster moet uitserveren. Verder matched het outputFormat niet met wat wordt aangeboden voor deze “coverage” (WCS service staat voor Web Coverage Service en serveert dus “coverages” uit), zie hiervoor het describeCoverage request

Bij deze nog een werkend request: https://geodata.nationaalgeoregister.nl/ahn3/wcs?Service=WCS&Version=1.0.0&Request=GetCoverage&Coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=104446,485940,104746,486240&format=GEOTIFF_FLOAT32&resx=1&resy=1.

Zie ook eerder draadjes over WCS bevraging op het forum, bijv.:

1 like

Heel erg bedankt voor de response! het is mij inmiddels gelukt de requests werkend te krijgen en ook beter te snappen hoe het werkt.

1 like