I am trying to create a geometry column from bytea.

I imported OSM data using ogr2ogr using the command

ogr2ogr -f PostgreSQL -nln bahamas_multipolygon PG:"dbname=openstreetmap user=postgres password=xxx" bahamas-latest.osm.pbf multipolygons

The output is when running the select query is fine

select wkb_geometry, osm_id, ogc_fid, "natural"
from public.bahamas_multipolygon as sd
where sd.natural = 'water';

Now I want to convert wkb_geometry to a WKT string representation (or) geometry column.

I tried with ST_GeomFromWKB, ST_GeomFromEWKB and tried explicit casting the column to ::geometry but all resulted in the same error.

HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

I looked at various similar answers but none of them helped. What is it with bytea that I am missing to help me convert to geometry?

  • 2
    Please run SELECT PostGIS_Full_Version(); - if that function does not exist, you either do not have the extension installed, or it is installed in a schema not listed in your search_path.
    – geozelot
    May 31 at 7:22
  • Oh God! Yes, I forgot to install extension. It worked once I installed the extension. Thanks :) May 31 at 7:25

1 Answer 1


Verify that you have the PostGIS extension installed, or if the containing schema is added to your search_path!


SELECT PostGIS_Full_Version();

to verify the installation - if that function does not exist, the extension is not installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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