Hallo,
Ik ben bezig met het 3D printen van de 3DBAG dataset van mijn straat. Nu zou ik graag de tile nummers opvragen op basis van coordinaten. Ik geloof dat het met WFS kan, door het aangeven van de bounding box?
Ik doe alles in Python, heeft iemand hier ervaring mee?
Ik ken OWSLib niet echt, maar naar de code kijkend: Je krijgt een BytesIO object terug. Dat kan je met een response.read() uit lezen om daar iets van te maken dat dan ook een string is doe je response.read().decode().
Als je die xml wil parsen met lxml:
from lxml import etree
etree.fromstring(response.read())
Dank Roel,
ter referentie: het is gelukt met de RD coordinaten:
response = wfs.getfeature(typename['BAG3D_v2:bag_tiles_3k'],
bbox=bbox,
srsname='EPSG:28992',
propertyname='*')
a = etree.fromstring(response.read())
Vind alle Tiles die bij de bounding box horen:
def findTileID(child):
datadict = []
for item in child:
d = {}
for elem in item:
d[elem.tag]=elem.text
datadict.append(d)
try:
# find tile ID
tileID = datadict[0]['{bag3d_v2}tile_id']
return tileID
except:
pass
tileIDs = [findTileID(child) for child in a[1:]]
Ik zal in het Engels reageren omdat mijn Nederlands niet zo goed is.
The bbox you are specifying is not in the right coordinate system. In the response parameters you specify `EPSG:28992’ which is right for the Netherlands but the bbox is in different crs (I believe it’s in WGS84) so you will get an empty response.
I have run your script with this random bbox=[91902.67009757613, 437579.7636220927, 92302.67009757613, 437979.7636220927] and it works fine!
To be able to use the response you can use the library geopandas which is very straight forward. So basically your script would look like this:
The result will be a geo-dataframe which is basically a table with a geometry column. You can see the content with: response_buildings.head().
You can plot the response with: response_buildings.plot()