[Qgis-developer] Re: QGIS API: change layer field length

romain romain.riviere.974 at gmail.com
Sun Jul 17 17:23:48 EDT 2011


Sorry, I think i haven't explained well what I want.

I know how to get my fields' lengths from SpatiaLite.

Here is what I've already done:
1/ create QgsvectorLayer from spatiaLite table : vlayer
2/ strore field's length in a python list: lengths

One of my text fields (FIELD1) have 300 characters....


What my problem is when i want to save the layer as mapinfo file with :

QgsVectorFileWritter.writteAsFromat(vlayer,........,mapinfo)

-> The mapinfo File is created but all the fields are truncated at 254
char.... So, I lost informations on FIELD1...

I've tried to set fields lengths for my layer, in order to avoid truncature,
but, it doesn't change anything:

fields=vlayer.dataProvider().fields()
for field in fields:
      fields[field].setLength(301)


Any hints ?

The only thing I need is to pass an option to Qgsvectorfilewritter to change
fields maximum characters...
Does anybody know how to do this directly with OGR ? (within python, of
course)

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/QGIS-API-change-layer-field-length-tp6560245p6592720.html
Sent from the qgis-developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list