3

I am using QGis 2.0.1 and have tried to create a new GIS feature file (SQLite, Spatialite, and Shapefile) of a subset of the data. I am then saving a copy of the style of this layer and applying it to the new layer. Also, I am starting with a Spatialite database.

All three have different issues:

SQLite - The data is copied, but the fields loose their edit widget type (If you go in to the properties of the layer, then the Fields menu on the left; it is the Edit widget drop down.)

Shapefile - The file has no features in the table, but everything else is fine.

Spatialite - QGis locks up.

Shapefile code:

    writer = QgsVectorFileWriter(layer_path,
                                 'CP1250',
                                 fields,
                                 QGis.WKBPoint,
                                 crs,
                                 'ESRI Shapefile')

    if writer.hasError() != QgsVectorFileWriter.NoError:
        raise IOError('Can\'t create the file: {0}\n'.format(layer_path))

    for feature in features:
        writer.addFeature(feature)

    del writer

SQLite code:

    writer = QgsVectorFileWriter(layer_path,
                                 'CP1250',
                                 fields,
                                 QGis.WKBPoint,
                                 crs,
                                 'SQLite')

    if writer.hasError() != QgsVectorFileWriter.NoError:
        raise IOError('Can\'t create the file: {0}\n'.format(layer_path))

    for feature in features:
        writer.addFeature(feature)

    del writer

Spatialite code:

    spatialite = ["SPATIALITE=YES"]

    writer = QgsVectorFileWriter(layer_path,
                                 'CP1250',
                                 fields,
                                 QGis.WKBPoint,
                                 crs,
                                 'SQLite', spatialite)

    if writer.hasError() != QgsVectorFileWriter.NoError:
        raise IOError('Can\'t create the file: {0}\n'.format(layer_path))

    for feature in features:
        writer.addFeature(feature)

    del writer

I have also tried spatialite = ["SPATIALITE=YES", ]

I just want to know if there is anything else that I can do to get this to work the way I want.

closed as too broad by BradHards, PolyGeo, Simbamangu, Fezter, underdark Apr 26 '14 at 22:44

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Could you elaborate on the edit widget issue? Are you using custom settings there? How are you trying to copy those settings? – underdark Mar 28 '14 at 19:10
  • I noticed that I am getting a multipoint error on the Shapefile. I changed the QGis.WKBPoint to QGis.WKBMultiPoint. That fixed the Shapefile issue, but how do you create a Spatialite database as I like that format much better as I have had too many corrupted Shapefiles in the past. – jfftck.work Mar 28 '14 at 19:32
  • Please edit your question and narrow it down to what you really want to know. – underdark Mar 28 '14 at 19:59
  • It might help if you can say where the "empty" spatialite came from? Are you possibly trying to use a newer file format with QGIS compiled against an older spatialite library? – BradHards Mar 28 '14 at 23:39