<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Luke -<br>
</p>
<p>Running this code in the QGIS Python console: <br>
<font face="monospace"><b><br>
vector_layer = iface.activeLayer() # Active layer _is_ from
GeoPackage<br>
field_name = 'Land Use Category' # "New_field" changed to
"field_name"<br>
<br>
new_field = QgsField(field_name, QVariant.String)<br>
vector_layer.dataProvider().addAttributes([new_field])<br>
</b></font></p>
<p>will add an extra column with the name "<b>Land Use Category</b>"
to the GeoPackage layer <br>
</p>
<pre class="moz-signature" cols="72">
Med venlig hilsen / Best regards
Bo Victor Thomsen</pre>
<div class="moz-cite-prefix">On 27/11/2024 05.48, Catania, Luke A
ERDC-RDE-GRL-VA CIV via QGIS-Developer wrote:<br>
</div>
<blockquote type="cite"
cite="mid:efb03d16423e4a67a68fa40a81eee6e5@erdc.dren.mil">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">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.<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">New_field = “Land Use Category”<br>
new_field = QgsField(field_name, QVariant.String)<br>
vector_layer.dataProvider().addAttributes([new_field])<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Field name is truncated to <b>Land_Use_C</b><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Luke Catania<o:p></o:p></p>
<p class="MsoNormal">US Army ERDC-GRL<o:p></o:p></p>
<p class="MsoNormal">JCMS Site Planning Developer<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
</body>
</html>