[Qgis-user] Create new geopackage layer

Arjun Dongre adongre at west-inc.com
Thu Jul 28 08:40:18 PDT 2022


Hello,
I am having trouble utilizing the QgsVectorFileWriter.create() method. I am
not getting any errors but no layer is being created. I am trying to write
a geopackage layer. I know my QgsFields are correct because I have used
them for some other code previously. Should the driver name be "ogr" or
"gpkg"? Is there any sort of commit statement that needs to happen after
creation? Or is creation predicated upon adding features? The only example
I can find is here: https://github.com/qgis/QGIS/issues/35021.

 qgsFields = QgsFields()
        uploadLayerName = f"{self.locationTypeText}-Upload-{self.layerDate}"
        for fieldMap in self.fieldMaps:
            qgsFields.append(
                QgsField(fieldMap.location_type_param_name, fieldMap.
qvariantType))
        options = QgsVectorFileWriter.SaveVectorOptions()
        options.driverName = "ogr"
        options.layerName = uploadLayerName
        uploadWriter = QgsVectorFileWriter.create(f"{GPKG_PATH}\\{
uploadLayerName}", qgsFields, self.layerGeometry,
QgsCoordinateReferenceSystem(
            "EPSG:4326"),  TRANSFORM_CONTEXT, options)


Thank you.
-- 
*Arjun Dongre*

Western EcoSystems Technology, Inc.
Environmental & Statistical Consultants
415 W. 17th St. Suite 200
Cheyenne, WY 82001
adongre at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanying communications
are covered by the Electronic Communications Privacy Act, 18 U.S.C. §§
2510-2521, and contain information that is privileged, confidential or
otherwise protected from disclosure.  If you are not the intended recipient
or an agent responsible for delivering the communication to the intended
recipient, you are hereby notified that you have received this
communication in error.  Dissemination, distribution or copying of this
e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent responsible for delivering the message
to the intended recipient, is prohibited.  If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.  Thank you.

P Please consider the environment before printing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220728/981b8328/attachment.htm>


More information about the Qgis-user mailing list