I'm running the OSGeo4W64 Qgis 3.2.0.
In the gui I can add a vector-layer using the same data as in the example below without any problems. Adding the layer using the python console works too.
When trying to do the same from a stand-alone script I get "ERROR 4: S57 Driver doesn't support update."
Adding other kml files works, but not S57/ENC
Looking in the code where the error is written, it looks like the difference may be the file mode used. I don't want or need to edit, so read-only/update=False is fine.
import os
from qgis.core import *
regi = QgsProviderRegistry.instance('C:\\OSGeo4W64\\apps\\qgis\\plugins')
QgsApplication.setPrefixPath(r'C:\OSGeo4W64\apps\qgis')
app = QgsApplication([],False)
app.initQgis()
l1=QgsVectorLayer(r"D:\ENC_NOAA\All_ENCs\ENC_ROOT\US1AK90M\US1AK90M.000|layername=M_COVR","COVR1","ogr")
print("Valid" if l1.isValid() else "Not Valid")
I have set CPL_DEBUG=ON and the output shows
ERROR 4: S57 Driver doesn't support update.
GDAL: GDALOpen(D:\ENC_NOAA\All_ENCs\ENC_ROOT\US1AK90M\US1AK90M.000, this=0000018CCEB33550) succeeds as S57.
GDAL: GDALClose(D:\ENC_NOAA\All_ENCs\ENC_ROOT\US1AK90M\US1AK90M.000, this=0000018CCEB33550)
Not Valid
Can I control the open mode via the uri?
Why the difference between interactive and stand-alone?
No comments:
Post a Comment