Skip to content

Instantly share code, notes, and snippets.

@jgomezdans
Created July 1, 2010 13:14
Show Gist options
  • Save jgomezdans/459943 to your computer and use it in GitHub Desktop.
Save jgomezdans/459943 to your computer and use it in GitHub Desktop.
Importing the geonames DB into Spatialite
CREATE TABLE geonames ( geoname_id int, name text, asciiname text, alternatenames text, latitude real, longitude real, feature_class text, feature_code text, country_code text, cc2 text, admin1 text, admin2 text, admin3 text, admin4 text, population integer, elevation integer, gtopo30 integer, timezone integer, modification_date text) ;
.separator \t
.import allCountries.txt geonames
ALTER TABLE geonames ADD COLUMN geom blob ;
UPDATE geonames SET geom = PointFromText ( 'POINT(' || longitude || ' ' || latitude || ')', 4326 ) ;
SELECT RecoverGeometryColumn ( "geonames", "geom", 4326, "POINT", 2) ;
SELECT CreateSpatialIndex ( "geonames", "geom") ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment