36

I found spatialite more useful than shapefiles as it does not have the limitations of shapefile and it is also portable. Many people here use shapefiles to exchange data and even the experts do not know about this new format.

What are the advantages of using spatialite over shapefiles?

Can it be used instead of shapefile?

Please focus only on those formats which are portable, i.e. can be exchanged using USB sticks. GML, GeoJSON, KML, CSV are not an option and they are not directly editable in GIS.

UPDATE: It has been more than 5 years and the new development is directed towards geopackage which is related to spatialite.

So now question is more like Advantages of using GEOPACKAGE over GEODATABASE?

0

5 Answers 5

27

Shapefiles are the lowest common denominator of GIS vector data file exchange: send an archive of shapefiles, and you can pretty much guarantee that someone will be able to build a basic GIS from it.

SpatiaLite's advantages include:

  • everything's in one file; none of the shp/shx/dbf/idx/prj per layer mess.
  • logic as well as data can be included, in the form of VIEWs and TRIGGERs.
  • built-in spatial indices, which allow rapid searches of large areas.
  • they are real (if slightly limited, mostly in multi-user access) database systems, with no database admin skills required.

But there are some disadvantages:

  • not everyone can use them.
  • they are still mostly limited to geometries built from nodes and straight lines; if you need splines and surfaces, look elsewhere.
1
  • 8
    Good post, but two points about spatial indexes. Shapefiles can be spatially indexed too, and second you have to explicitly join to a Spatialite spatial index which can lead to some unwieldy queries. I still prefer to move data around in a Spatialite DB, but import it into a PostGIS database to take advantage of its more robust query planner. Aug 23, 2013 at 15:33
22

Shapefiles are bound to one type of geometry, so you get a bunch of files for a single project. The field names are restricted too due to using an antiquarian database format.

In spatialite, you can hold the whole project data in one file; and name the fields how you want (well, almost).

The only disadvantage of spatialite is the fast update cycle, making it difficult to read or write data written in another (older) version.

15

In addition to scruss' answer, shapefiles has some limitations:

  • max field name length is 10 characters
  • maximum file size (.dbf / .shp) is 2GB
  • numeric attributes are stored as characters (integers/floats), causing potential problems with rounding etc
  • NULL values are interpreted differently between systems
0
4

The biggest advantage, for me, is the relational database system in a single file format. Among the many benefits is the use of spatial functions to create views. Consider a case where you were given a set of points and your methodology is to buffer the points base on an attribute, and then test coincidence of those buffers with other geographic features. Using this workflow with shapefiles usually requires that each operation is persisted as another shapefile. Now if any of your given data is updated you have to run the whole chain again. Not to mention that in some environments the input data could be changed unbeknownst to you. This is not a problem when you rely on SQL views for geometry operations. (I'm aware there are tools that address this sort of issue with shapefiles, but the question is about spatiaLite database.)

2

Everything being in one file is also a disadvantage: Much harder to fix, if something is broken. Size of the file too, seems to start from 3.7 MB, even for almost empty datasets. They also seem to support only text, integer and float fields. No date/time or Boolean fields. At least when testing in QGIS 1.8

6
  • 1
    Spatialite does has date/time types, inasmuch as it has types for anything: Date and Time Datatype.
    – scruss
    Aug 23, 2013 at 15:51
  • 2
    "SQLite does not have a storage class set aside for storing dates and/or times" quoted from the page you link to. Yes, it is possible to store anything in a text field, but it is still just text, that needs to get parsed before you can do math on it. Aug 23, 2013 at 15:54
  • No, you don't; you can do queries like select * where date < '1980-01-01' and it does the maths for you.
    – scruss
    Aug 23, 2013 at 17:03
  • which means the text gets parsed. The alternative is the date is stored as a number that is directly understood by the engine. With no risk, that you run into 31st of Apr or any other illegal values. With text it has to be translated into a number, before the < operator can be applied. Aug 23, 2013 at 17:40
  • 1
    @UffeKousgaard: In .dbf files, numerics (integers/floats) and datetimes as stored as characters, so in the case of parsing, shapefiles has no advantage here whatsoever.
    – Oyvind
    Aug 24, 2013 at 23:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.