Thursday, 28 July 2016

pyqgis - S57/ENC QgsVectorLayer with stand-alone python script


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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...