简体   繁体   中英

Can not read some layers with OGR?

I am trying to read features from a WFS source with python using OGR and put them in a PostgreSQL database. To start reading the features in an iteration, I get the first feature first before going to a while loop going over all features:

layer.ResetReading()
feat = layer.GetNextFeature()
if not feat:
    self.log("error", "Kon niet naar de eerste feature in %s gaan." % layer.GetName())
else:
    if feat.GetFID():
        self.sourcelist.append(feat.GetFID())
    print ("\n%s : Source feature met dit nummer toevoegen aan %s" % (str(i),uitnaam), end = '\r' )

The layer exists. I can even get ogr.layer.GetLayerDefn() from it which I use to make fields in postgresql before this piece of code is executed. This all works for most WFS services and layers , however, for some WFS layers, no feature can be read. It doesn't report an error, there are just no features. When I use my browser to make a request with the same srs and bbox, it does produce a list of features however. I really don't get why this works for most layers of most wfs services that I use, and for some it doesnt ? I have tried to achieve the same with the ogr2ogr console application. For the layer that doesnt work in my program it returns an error:

ERROR 1: srsDimension = 4 not supported

Would anyone have any idea what's going on here?

EDIT:

I found googling your error very little stuff, but could find that mostly results show that geometries have this attribute set to 2. Could perhaps be a bad geometry ? Try skipping if you can or try to correct it using requests module below before reading with ogr.

END EDIT;

can you provide one sample valid request? I could not manage to get one that works...

In this case looks as ogr cannot read wms directly, probably because of the srs error with 4 dimensions. In this case I would try to make the requests using requests module and then get the response, convert it to a form ogr understands and then put that in database.

import requests
url = 'http://geoservices.vlaamsbrabant.be/FSW/MapServer/WFSServer'
x=requests.get(url)
print(x.text)

After trying this request:

https://geoservices.vlaamsbrabant.be/FSW/MapServer/WFSServer?service=wfs&version=2.0.0&request=getfeature&typenames=dataservices_FSW:FietssnelwegenFeatureType

It seems to be a certificate problem. The certificate seems to be ok, yet the browser marks the request as "Not secure".

It may be necessary to request a certificate to be able to use this service?!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM