Skip to content

Instantly share code, notes, and snippets.

@Rodolfocartas
Forked from jgomezdans/import_geonames.sql
Last active October 5, 2017 16:59
Show Gist options
  • Save Rodolfocartas/4e70fbe110f111e3ba321418408cc2b5 to your computer and use it in GitHub Desktop.
Save Rodolfocartas/4e70fbe110f111e3ba321418408cc2b5 to your computer and use it in GitHub Desktop.
Importar archivo de localidades de inegi a spatialite
PRAGMA encoding="UTF-8";
CREATE TABLE localidades ( clave_entidad text, entidad text, clave_mpo text, municipio text, clave_loc text, localidad text, ambito text, latitude real, longitude real) ;
.separator ,
.import localidades.csv localidades
ALTER TABLE localidades ADD COLUMN geom blob ;
UPDATE localidades SET geom = PointFromText ( 'POINT(' || longitude || ' ' || latitude || ')', 4326 ) ;
SELECT RecoverGeometryColumn ( "localidades", "geom", 4326, "POINT", 2) ;
SELECT CreateSpatialIndex ( "localidades", "geom") ;
select InitSpatialMetaData("1");
CREATE TABLE localidades ( clave_entidad text, entidad text, clave_mpo text, municipio text, clave_loc text, localidad text, ambito text, latitude real, longitude real) ;
.separator ,
.import localidades.csv localidades
ALTER TABLE localidades ADD COLUMN geom blob ;
UPDATE localidades SET geom = PointFromText ( 'POINT(' || longitude || ' ' || latitude || ')', 4326 ) ;
SELECT RecoverGeometryColumn ( "localidades", "geom", 4326, "POINT", 2) ;
SELECT CreateSpatialIndex ( "localidades", "geom") ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment