[Qgis-developer] QGIS API: change layer field length
Voisard François
Francois.Voisard at ne.ch
Mon Jul 18 11:09:06 EDT 2011
Hi Romain, hi Devs,
My first post on the ML; followed it about 6 months for now... =:0)
Romain, if I've understood you right, I think your problem is not a QGIS but a Mapinfo problem: MapInfo accepts only a max. of 254 character per field [1].
So whatever the length is in your DB, a Mapinfo file will never store and display more than the 254 characters. We've got the same problem with Oracle/PostGIS data displayed using MapInfo ODBC connections.
Best regards,
François
[1] http://testdrive.mapinfo.com/techsupp/miprod.nsf/kbase_by_product/BC5DE25962BC57C285256278002FB800
*********************************************************************
François Voisard
Ingénieur en Géomatique
Administration Cantonale de Neuchâtel
SITN - Système d'Information du Territoire Neuchâtelois
Service de la Géomatique et du Registre Foncier
Rue de Tivoli 22
CH - 2000 Neuchâtel
Tél ++4132 889 4769
Fax ++4132 889 6121
*********************************************************************
Message: 2
Date: Sun, 17 Jul 2011 14:23:48 -0700 (PDT)
From: romain <romain.riviere.974 at gmail.com>
Subject: [Qgis-developer] Re: QGIS API: change layer field length
To: qgis-developer at lists.osgeo.org
Message-ID: <1310937828326-6592720.post at n2.nabble.com>
Content-Type: text/plain; charset=us-ascii
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.
------------------------------
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
End of Qgis-developer Digest, Vol 67, Issue 40
**********************************************
More information about the Qgis-developer
mailing list