I installed PostgreSQL 9.2.4 and PostGIS 2.0.3 on my Windows 8 machine. Then I created a table using phpPgAdmin and added a geometry column using the following statement.

SELECT AddGeometryColumn('tablename', 'area', -1, 'POLYGON', 2);

That resulted in these table columns.

|Column|Type                 |Not Null|Default                           |Constraints|
|id    |integer              |NOT NULL|nextval('simple_id_seq'::regclass)|PRIMARY KEY|
|name  |character varying(50)|        |                                  |           |
|area  |geometry(Polygon)    |        |                                  |           |

After some simple text queries I tried to play with geometry data. This is the query I tried to execute.

INSERT INTO tablename (name, area)
    GeometryFromText('POLYGON((84 104, 212 48, 321 122, 243 179, 275 238, 131 240))', -1)

Unfortunately, it throws an error message.

ERROR:  function geometryfromtext(unknown, integer) does not exist
LINE 4:     GeometryFromText('POLYGON((84 104, 212 48, 321 122, 243 ...
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Since AddGeometryColumn was successful, I assume that PostGIS is set up properly. How can I insert geometry data in my table? What am I doing wrong?

2 Answers 2


You should use ST_GeomFromText.

The functions without the ST_ are the older functions, and are being phased out; They are deprecated, and shouldn't be used any more.

  • 2
    Thanks, moreover I had to close the polygon, thus add the starting point at the end again.
    – danijar
    May 5, 2013 at 17:03

It seems that the value -1 is no longer valid since version 2 of PostGIS.

You can use 0 instead.

  • Thanks for the information. Moreover there is an overloaded version of that function with allows you to don't specify the RSID at all.
    – danijar
    May 6, 2013 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.