[QGIS-Developer] Field Name limited to 10 characters for a geopackage

Catania, Luke A ERDC-RDE-GRL-VA CIV Luke.A.Catania at erdc.dren.mil
Wed Nov 27 06:07:12 PST 2024


Yea, I tried it in the consol and it worked, but does not work in my plugin code.

From: Bo Victor Thomsen <bo.victor.thomsen at gmail.com>
Sent: Wednesday, November 27, 2024 6:09 AM
To: Catania, Luke A ERDC-RDE-GRL-VA CIV <Luke.A.Catania at erdc.dren.mil>; qgis-developer at lists.osgeo.org
Subject: Re: [QGIS-Developer] Field Name limited to 10 characters for a geopackage


Hi Luke -

Running this code in the QGIS Python console:

vector_layer = iface.activeLayer()  # Active layer _is_ from GeoPackage
field_name = 'Land Use Category'    # "New_field" changed to "field_name"

new_field = QgsField(field_name, QVariant.String)
vector_layer.dataProvider().addAttributes([new_field])

will add an extra column with the name "Land Use Category" to the GeoPackage layer



Med venlig hilsen / Best regards



Bo Victor Thomsen
On 27/11/2024 05.48, Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer wrote:
I am using a geopackage as a data source and when I add a new field it is limited to 10 characters. I thought that was only a limitation for ESRI shapefiles.


New_field = “Land Use Category”
new_field = QgsField(field_name, QVariant.String)
vector_layer.dataProvider().addAttributes([new_field])

Field name is truncated to Land_Use_C

Luke Catania
US Army ERDC-GRL
JCMS Site Planning Developer




_______________________________________________

QGIS-Developer mailing list

QGIS-Developer at lists.osgeo.org<mailto:QGIS-Developer at lists.osgeo.org>

List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked

Unsubscribe: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20241127/61782435/attachment.htm>


More information about the QGIS-Developer mailing list