16

I have a sqlite database with a table that has a column for longitude and one for latitude. Is there a way to make this data base 'spatial'?

2 Answers 2

18

I've described the process of installing and spatially enabling an sqlite db here: SpatiaLite Quick Start. Basically, you need to get init_spatialite-2.3.sql and run it on your db.

You can then create point geometries using this function:

MakePoint( x Double precision , y Double precision , [ , SRID Integer] ) : Geometry
1
  • thanks, that worked well in combination with Gene's suggestions.
    – johannes
    Jan 16, 2011 at 15:41
9

first, you need to enable spatialite in your sqlite database

sqlite> .load 'libspatialite.so,dll or dylib'   

or

SELECT load_extension(libspatialite.so,dll ou dylib)

`

After that you need to initialize your database with init_spatialite-2.3.sql

sqlite> .read '~/init_spatialite-2.3.sql'
1
  • 2
    Note that the init_spatialite-2.3.sql step is not applicable for spatialite 3.0 or later.
    – BradHards
    Aug 11, 2012 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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