Skip site navigation (1) Skip section navigation (2)

Re: contains function

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Frances Collier <fcollier(at)preparedresponse(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: contains function
Date: 2005-10-06 05:11:05
Message-ID: 20051006051105.GA88849@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Wed, Oct 05, 2005 at 01:06:37PM -0700, Frances Collier wrote:
> Are there any examples of using postgis that I can use for research?

Consider subscribing to the postgis-users mailing list if you're
using PostGIS:

http://postgis.refractions.net/support/

> Select astext(wkb_geometry), name, state
> From usroads
> Where state = 'Alabama'
> And name like '%Ross Clark%'
> And Contains(polygon('(-85.440253,31.207678),(-85.421703,31.207678),
> (-85.421703,31.226228),(-85.440253,31.226228),
>                                  (-85.440253,31.207678)'), wkb_geometry);
> 
> Here is the error I'm getting back:
> 
> ERROR:  function contains(polygon, geometry) does not exist
> HINT:  No function matches the given name and argument types. You may need
> to add explicit type casts.

You're mixing a PostgreSQL polygon type and a PostGIS geometry type;
the Contains() function takes two geometry types.  Use a constructor
like GeomFromText() or PolyFromText() to build the polygon.  See
"Using PostGIS" in the PostGIS documentation for examples:

http://postgis.refractions.net/docs/

Be sure to read "Taking Advantage of Indexes" to understand how to
speed up queries such as the above with bounding box searches.

-- 
Michael Fuhr

In response to

Responses

pgsql-novice by date

Next:From: Michael FuhrDate: 2005-10-06 06:23:40
Subject: Re: Schema handling within plpgsql
Previous:From: mikeDate: 2005-10-06 02:38:52
Subject: Re: contains function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group