[postgis-users] typecast from point to geometry for distance_sphere

Stephen Woodbridge woodbri at swoodbridge.com
Sat Jan 14 08:31:48 PST 2006


Assad Jarrahian wrote:
>  I am using postgis 1.1.0 and am trying to test out the
> distance_sphere() function.
> 
> SELECT distance_sphere((point(12,23)), point(12,24));
> 
> ERROR:  function distance_sphere(point, point) does not exist
> HINT:  No function matches the given name and argument types. You may
> need to add explicit type casts.
> 
> So I guess I need a type cast (how do I do that?) or maybe I am doing
> something wrong (I noticed all the methods that take any spatial
> argument are of type geometry).
> I thought that point was of geometry type, I guess I maybe wrong.

point() is not a postgis geometry function. You need to use 
makepoint(x,y) to get a geometry object.

select distance_sphere(makepoint(12, 33), makepoint(12,24));

should work and will return approximate 69 miles in meters because it 
expects points in decimal degrees makepoint(longitude,latitude). On 
degree is a little more the 69 miles at the equator.

-Steve



More information about the postgis-users mailing list