I am using the popular QSpatiaLite plugin for QGIS. Since I am creating and modifying SpatiaLite tables directly with Python (using pyspatialite), I wonder whether I can automate tasks such as converting from a Shapefile to SpatiaLite directly from the Python code (similar to the plugin's "Import OGR files").

Thus, does the plugin provide some sort of an API to do that kind of stuff? Or can I do this from within pyspatialite without using any QGIS-related API?

I know there is a QGIS Python API but I have never dealt with it, that's why I am kind of confused here.

You can definitely do that sort of conversion (shp -> spatialite) in a range of command-line and script ways. Do you have a full list of the required conversions, or some specific requirements?
–
BradHardsApr 4 '13 at 20:02

Hi Brad, the only thing I actually need to do is convert an existing SHP in SRID:4326 to a SpatiaLite polygon table, also of SRID:4326, and yes, I would like to do this inside a Python script.
–
wnstnsmthApr 4 '13 at 20:10

1 Answer
1

If you use Python, you can perfectly use one of the modules that can read shapefiles like ogr, Fiona or Pyshp to extract the geometries and the attributes of a shapefile and insert them into SQLite/SpatiaLite with pyspatialite without QGIS and QSpatiaLite.