[GIS] Adding Geometry column in PostGIS

postgis

While I'm adding a geometry column in PostGIS by using AddGeometryColumn then the error is

no function matches the given name and argument types. you might need
to add explicit type casts

Best Answer

First, as others have said, make sure you have PostGIS installed. Run this command to ensure that you have PostGIS installed,

SELECT postgis_version();

If you don't have postgis_version() then you need to install PostGIS on the database. If it's not installed, you can try this when connected to the specific database you want to install PostGIS on,

CREATE EXTENSION postgis;

If that fails than you need to install or build PostGIS which then becomes a question of what operating system you're using. If you've got the extension downloaded and installed, run this in psql

\dfS AddGeometryColumn

If that works, then you have the function installed too but you're providing it the wrong types. We need the actual function call. Provide us what you're calling AddGeometryColumn() with. Also, if your version of PostGIS is newer than 2.0, do not use AddGeometryColumn(). It is not needed. Instead use the ALTER TABLE ADD COLUMN with the subtype. Here is an example to add a geometry point in srs 4326.

ALTER TABLE some_table ADD COLUMN geom geometry(Point,4326);
Related Question