Обсуждение: contains function

Поиск
Список
Период
Сортировка

contains function

От
"Frances Collier"
Дата:

Are there any examples of using postgis that I can use for research?

 

My current problem is the use of the Contains function.  Here’s my statement:

 

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.

 

I’ve tried numerous ways to fix this but I haven’t had any luck. I’d really appreciate any help I can get.

 

Thank you,

Frances

 

Re: contains function

От
mike
Дата:
I don't believe postgresql recognizes "Contains".  Try SELECT ... AND
wkb_geometry IN (....)

Mike
On Wed, 2005-10-05 at 13:06 -0700, Frances Collier wrote:
> Are there any examples of using postgis that I can use for research?
>
>
>
> My current problem is the use of the Contains function.  Here’s my
> statement:
>
>
>
> 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.
>
>
>
> I’ve tried numerous ways to fix this but I haven’t had any luck. I’d
> really appreciate any help I can get.
>
>
>
> Thank you,
>
> Frances
>
>
>
>

Re: contains function

От
Michael Fuhr
Дата:
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

Re: contains function

От
"Frances Collier"
Дата:
Thank you very much. I just subscribed to the postgis-users mailing list
yesterday and will take another look at the postgis documentation. Knowing
the difference between the polygon and the geometry is definitely going to
help. Thank you.

Frances Collier


-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Michael Fuhr
Sent: Wednesday, October 05, 2005 10:11 PM
To: Frances Collier
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] contains function

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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq