I couldnt find anything wrong with your function. Just before you execute the PG_RETURN_POINTER(...), try this; elog(NOTICE,"WKT representation of your polygon is: %s\n", geometry_to_text(ppoly)); This should print out the normal "WKT" representation of your geometry. If this prints out the correct value, I have no idea whats wrong... dave