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'?

underdark
  • 84,148
  • 21
  • 231
  • 413
johannes
  • 1,143
  • 9
  • 18

2 Answers2

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
underdark
  • 84,148
  • 21
  • 231
  • 413
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'