Repository navigation
Exporting to PostgreSQL PostGIS
Mario Martin Basa edited this page Jan 24, 2024
·
4 revisions
While different spatial analytics can be achieved with QGIS, there might be instances when using the full functionalities of PostGIS in a PostgreSQL database will be beneficial. This might also be useful when there is a need to link other tables, such as credit or pre-paid card information, into the Location History and again do spatial analytics.
Below are the steps done to transfer the Excavator created tables in SQLite into a PostgreSQL database. This assumes that both PostgreSQL and PostGIS have already been installed in the host machine.
- Creating a dump file of the Excavator created SQLite database
sqlite3 ichnion.db .dump > ichnion.sql- Create a PostgreSQL database
createdb ichnion- Import the tables from the SQLite dump file into the PostgreSQL database
psql -f ichnion.sql ichnion- Add the PostGIS extension into the created database
ichnion=# create extension postgis;- Create a Geometry Column to the imported
google_location_historytable
alter table google_location_history add column geom geometry('POINT',4326);- Add the Points data contained in the
lat,lngcolumns into the created Geometry column
update google_location_history set geom = st_makepoint(lng,lat);- Create a Geometry Column to the imported
google_location_history_updatedtable
alter table google_location_history_updated add column geom geometry('POINT',4326);- Add the Points data contained in the
lat,lngcolumns into the created Geometry column
update google_location_history_updated set geom = st_makepoint(lng,lat);- Create a Geometry Column to the imported
google_location_activitytable
alter table google_location_activity add column geom geometry('POINT',4326);- Add the Points data contained in the
lat,lngcolumns into the created Geometry column
update google_location_activity set geom = st_makepoint(lng,lat);- Create a Geometry Column to the imported
google_location_placevisittable
alter table google_location_placevisit add column geom geometry('POINT',4326);- Add the Points data contained in the
lat,lngcolumns into the created Geometry column
update google_location_placevisit set geom = st_makepoint(lng,lat);- Create a Geometry Column to the imported
google_location_activitysegmenttable
alter table google_location_activitysegment add column geom geometry('Linestring',4326);- Add the Linestring data contained in the
wktcolumn into the created Geometry column
update google_location_activitysegment set geom = st_geomfromtext(wkt);