Re: [Qgis-developer] QGIS QgsVectorFileWriter

2013-07-31 Thread Minoru Akagi
Hi,

I guess that the 3rd argument (fields) should be a QgsFields object.
You can create it like this.

fields = QgsFields()
fields.append( QgsField( id, QVariant.Int ) )
fields.append( QgsField( desc, QVariant.String ) )

Cheers,
Minoru

2013/7/31 Bjorn Nyberg bjorn.burr.nyb...@gmail.com:
 I have a list of Linestrings [(x,y),(x,y)] pairs that i've created as

 shapelist.append(([QgsPoint(x1,y1),QgsPoint(x2,y2)]))


 shapelist[:5]
 [[(4.11658e+06,5.18318e+06), (4.11717e+06,5.18218e+06)],
 [(4.11847e+06,5.18323e+06), (4.11771e+06,5.18223e+06)],
 [(4.1064e+06,5.17508e+06), (4.10647e+06,5.17408e+06)],
 [(4.10755e+06,5.1749e+06), (4.10693e+06,5.1739e+06)],
 [(4.11138e+06,5.15935e+06), (4.112e+06,5.15835e+06)]]


 MultiPolyLine = QgsGeometry.fromMultiPolyline(shapelist)

 However when I attempt to apply the writer by

 writer = QgsVectorFileWriter(out, CP1250, fields, QGis.WKBMultiLineString,
 layer.crs(), ESRI Shapefile)

 I receive the following traceback:

 Traceback (most recent call last):
   File input, line 1, in module
 TypeError: arguments did not match any overloaded call:
   QgsVectorFileWriter(QString, QString, QgsFields, QGis.WkbType,
 QgsCoordinateReferenceSystem, QString driverName=ESRI Shapefile,
 QStringList datasourceOptions=QStringList(), QStringList
 layerOptions=QStringList(), QString newFilename=None): argument 3 has
 unexpected type 'dict'
   QgsVectorFileWriter(QgsVectorFileWriter): argument 1 has unexpected type
 'str'


 What does a Qstring imply here? Do I need to apply
 PyQt4.QtCore.QString(out)?

 Cheers,
 Bjorn

 ___
 Qgis-developer mailing list
 Qgis-developer@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-developer

___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] QGIS QgsVectorFileWriter

2013-07-30 Thread Bjorn Nyberg
I have a list of Linestrings [(x,y),(x,y)] pairs that i've created as

shapelist.append(([QgsPoint(x1,y1),QgsPoint(x2,y2)]))


shapelist[:5]
[[(4.11658e+06,5.18318e+06), (4.11717e+06,5.18218e+06)], 
[(4.11847e+06,5.18323e+06), (4.11771e+06,5.18223e+06)], 
[(4.1064e+06,5.17508e+06), (4.10647e+06,5.17408e+06)], 
[(4.10755e+06,5.1749e+06), (4.10693e+06,5.1739e+06)], 
[(4.11138e+06,5.15935e+06), (4.112e+06,5.15835e+06)]]


MultiPolyLine = QgsGeometry.fromMultiPolyline(shapelist)

However when I attempt to apply the writer by 

writer = QgsVectorFileWriter(out, CP1250, fields, QGis.WKBMultiLineString, 
layer.crs(), ESRI Shapefile)

I receive the following traceback:

Traceback (most recent call last):
  File input, line 1, in module
TypeError: arguments did not match any overloaded call:
  QgsVectorFileWriter(QString, QString, QgsFields, QGis.WkbType, 
QgsCoordinateReferenceSystem, QString driverName=ESRI Shapefile, QStringList 
datasourceOptions=QStringList(), QStringList layerOptions=QStringList(), 
QString newFilename=None): argument 3 has unexpected type 'dict'
  QgsVectorFileWriter(QgsVectorFileWriter): argument 1 has unexpected type 'str'


What does a Qstring imply here? Do I need to apply PyQt4.QtCore.QString(out)? 

Cheers,
Bjorn ___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer