Convert regular Postgres database to PostGis database

I have a regular postgres database with lots of geocoded data. These are just two columns, like latitude and longitude.

I want to convert this database to PostGIs database. Can someone suggest me a way to convert a database? I do not want to create a new database based on postgis tempalte, and then move all the data one by one.

+8
database postgresql postgis
source share
2 answers

Install PostGIS 2.x on your system first. Here is the workflow from psql or pgAdmin III:

-- Spatially enable the database CREATE EXTENSION postgis; -- Spatially enable each table with a geometry column -- [ also consider using "geog geography(Point,4326)" ] ALTER TABLE mytable ADD COLUMN geom geometry(Point,4326); UPDATE mytable SET geom = ST_SetSRID(ST_MakePoint(long, lat), 4326); 
+7
source share

I know this is older ... but I would add something to solve the previous problem:

@Cerin, make sure you apt-get install postgresql-xx-postgis-2.1, not just apt-get install postgis. I used to have this question

+2
source share

All Articles