Chen, Li [Contractor] | 1 Apr 06:28 2010

ST_Buffer questions

Hi Everyone,

I am a newbie to this community and I would like to ask a question/s J.

 

Q1.

ST_Buffer(g1, range) is able to return a geometry within the range of g1.

 

So, I define two point using lon/lat (SRID=4326) and range 10km. I want to see whether they cross each other by using ST_Crosses(g1, g2).

However, I don’t know the unit of the range parameter in ST_Buffer(g1,range)  as it is not provide in the docs. So is it km or meters?

 

Q2.

I want to define many circle sectors around the earth. And I have a column to set the location of the centre and another column to set the shape of the sector (direction, diameter). Is there a function to return a geometry that represents both the location and shape of the sector? ST_Buffer only returns a full circle.

 

Thanks for the help,

 

Li

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Ben Madin | 1 Apr 07:41 2010
Picon

Re: ST_Buffer questions

G'day Li,

I can't help with Q2, but

On 01/04/2010, at 12:28 , Chen, Li [Contractor] wrote:

> Q1.
> ST_Buffer(g1, range) is able to return a geometry within the range of g1.
>  
> So, I define two point using lon/lat (SRID=4326) and range 10km. I want to see whether they cross each other
by using ST_Crosses(g1, g2).
> However, I don’t know the unit of the range parameter in ST_Buffer(g1,range)  as it is not provide in the
docs. So is it km or meters?

The same unit as your Geometry - decimal degrees. Obviously due to the change in the value of this unit at
differing latitudes, this is not useful, so a more sensible approach is either to transform your point
into a projection using metres, and then use metres

 (off the top of my head it would look like :

select st_buffer(st_transform(g1, appropriate_projection_epsg),10000);

but you should check the docs)

or use the geography type from postgis 1.5? but I haven't tried it yet?

cheers

Ben
Chen, Li [Contractor] | 1 Apr 07:47 2010

Re: ST_Buffer questions

Thanks Ben,

I will try what you suggested.

We only need to represent mobile cell tower, so geography might be too much for the application. Especially
consider there are much more functions for geometry than geography.

Happy Easter:)

-----Original Message-----
From: postgis-users-bounces <at> postgis.refractions.net
[mailto:postgis-users-bounces <at> postgis.refractions.net] On Behalf Of Ben Madin
Sent: Thursday, 1 April 2010 4:42 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] ST_Buffer questions

G'day Li,

I can't help with Q2, but

On 01/04/2010, at 12:28 , Chen, Li [Contractor] wrote:

> Q1.
> ST_Buffer(g1, range) is able to return a geometry within the range of g1.
>  
> So, I define two point using lon/lat (SRID=4326) and range 10km. I want to see whether they cross each other
by using ST_Crosses(g1, g2).
> However, I don't know the unit of the range parameter in ST_Buffer(g1,range)  as it is not provide in the
docs. So is it km or meters?

The same unit as your Geometry - decimal degrees. Obviously due to the change in the value of this unit at
differing latitudes, this is not useful, so a more sensible approach is either to transform your point
into a projection using metres, and then use metres

 (off the top of my head it would look like :

select st_buffer(st_transform(g1, appropriate_projection_epsg),10000);

but you should check the docs)

or use the geography type from postgis 1.5? but I haven't tried it yet?

cheers

Ben

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Andrea Peri | 1 Apr 08:28 2010
Picon

Re: Polygon validity

first of all: sorry for my poor english ..:(

>> So a curve with 2 consecutive point like this
>> linestring (10 10, 20 20, 20 20, 30 30) is violating this definition
>I disagree. In the formal definition of Curve above, note the condition
>that x1 < x2. In any continuous parameterization f of LINESTRING(10 10,
>20 20, 20 20, 30 30), if f(x1) = pt[1] (20 20) and f(x2 = pt[2] (20 20),
>then x1 must = x2.
Oh no.

x1 and x2 report simply a sequence (or a serial of point),
for example

1 , 2 , 3
is a sequence of points.

but even
1 , 1,  1
is a sequence.

(where x1 = 1, x2 = 1 and x3 = 1)

So

x1 is always differente from x2.

x1 < x2 is needed for saying that it is a sequence, or that matemathically
there is a sequence of point where the first point come in before of the second point,
and the second point com after the first point.
the 1 and 2 prefix is a positional index in the sequence.

so:

is cannot be true that
if f(x1) = f(x2) then x1 = x2.

Andrea.


--
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
iKey | 1 Apr 11:35 2010
Picon

Postgres/Postgis query very slow


Hey,
I've set up a Postgres database with Postgis support.
Now I try to excecute the following query:

SELECT DISTINCT p.*
FROM punkte p, lines l
WHERE l.tags LIKE '%"highway"="footway"%'
    AND CONTAINS(BUFFER(l.the_geom, 500), p.the_geom)

You can download the SQL's to create the tables from my server:
http://thisisliving.info/sql.zip

It should return all datasets from the table punkte that are within a buffer
of 500m around the datasets of the lines table.
Anyway the query works fine, but it's veeeeery slow. It takes about 10
minutes to get the results (1969).
Now my question is if there is a way to speed up the query a bit.
All help is appreciated.
Thank you
Eike Lüders

--

-- 
View this message in context: http://old.nabble.com/Postgres-Postgis-query-very-slow-tp28106198p28106198.html
Sent from the PostGIS - User mailing list archive at Nabble.com.

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Marko Čubranić | 1 Apr 11:37 2010
Picon

Re: Postgres/Postgis query very slow

index your data if you havent..

2010/4/1 iKey <eike.lueders <at> gmail.com>

Hey,
I've set up a Postgres database with Postgis support.
Now I try to excecute the following query:

SELECT DISTINCT p.*
FROM punkte p, lines l
WHERE l.tags LIKE '%"highway"="footway"%'
   AND CONTAINS(BUFFER(l.the_geom, 500), p.the_geom)

You can download the SQL's to create the tables from my server:
http://thisisliving.info/sql.zip

It should return all datasets from the table punkte that are within a buffer
of 500m around the datasets of the lines table.
Anyway the query works fine, but it's veeeeery slow. It takes about 10
minutes to get the results (1969).
Now my question is if there is a way to speed up the query a bit.
All help is appreciated.
Thank you
Eike Lüders

--
View this message in context: http://old.nabble.com/Postgres-Postgis-query-very-slow-tp28106198p28106198.html
Sent from the PostGIS - User mailing list archive at Nabble.com.

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
strk | 1 Apr 11:44 2010
Picon

Re: Postgres/Postgis query very slow

On Thu, Apr 01, 2010 at 02:35:09AM -0700, iKey wrote:
> 
> Hey,
> I've set up a Postgres database with Postgis support.
> Now I try to excecute the following query:
> 
> SELECT DISTINCT p.*
> FROM punkte p, lines l
> WHERE l.tags LIKE '%"highway"="footway"%'
>     AND CONTAINS(BUFFER(l.the_geom, 500), p.the_geom)

Blind guess:

- Use ST_DFullyWithin instead of buffer (major improvement expected)
- Use equality operator and an OR for tags rather than like (minor)
- Avoid the DISTINCT if not needed (minor)

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html
Nicklas Avén | 1 Apr 12:01 2010
Picon

Re: Postgres/Postgis query very slow

Hallo

Here ST_DFulltwithin will give wrong result. It is easily done to think wrong about this function. It will cause a measuring from the point to the furthest part of the line instead of the closest. In this case it will cause a measure like the first illustration in the documentation of ST_Longestline.
http://postgis.org/documentation/manual-1.5/ST_LongestLine.html

Since one of the geometries is a point it is possible to use ST_DWithin instead. If the point is within, it is also fullywithin.

So, just use ST_DWithin indead of ST_DFullywithin in strk's suggestion. It should be much faster than the buffer solution.


/Nicklas

2010-04-01 strk wrote:

On Thu, Apr 01, 2010 at 02:35:09AM -0700, iKey wrote:
>>
>> Hey,
>> I've set up a Postgres database with Postgis support.
>> Now I try to excecute the following query:
>>
>> SELECT DISTINCT p.*
>> FROM punkte p, lines l
>> WHERE l.tags LIKE '%"highway"="footway"%'
>> AND CONTAINS(BUFFER(l.the_geom, 500), p.the_geom)
>
>Blind guess:
>
>- Use ST_DFullyWithin instead of buffer (major improvement expected)
>- Use equality operator and an OR for tags rather than like (minor)
>- Avoid the DISTINCT if not needed (minor)
>
>--strk;
>
> () Free GIS & Flash consultant/developer
> /\ http://strk.keybit.net/services.html
>_______________________________________________
>postgis-users mailing list
>postgis-users <at> postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
ibrahim saricicek | 1 Apr 14:27 2010
Picon

Re: Address Geocoding

Hi all,

I mean one of those, not one table at a time.

Or creating a function;

SELECT id, the_geom
FROM roads
WHERE
  the_geom && SetSRID('BOX3D(x+0.01 y+0.01, x-0.01 y-0.01)'::box3d, 4326)
ORDER BY
  ST_Distance(the_geom, GeomFromText('POINT(x y)', 4326))
LIMIT 1;

if this is null try the others; settlements, poi, province, etc...

Regards...

 

On Tue, Mar 30, 2010 at 4:49 AM, Oscar Zamudio <cmntlk <at> gmail.com> wrote:
When you write: "FROM (roads, settlements, poi, province, etc...)" you actually mean one table at a time? Because if you try more than one table separated by commas, there will be an error. If you are trying to use more than one table I'm afraid you will need to use a JOIN clause ...
Regards,


On Wed, Mar 24, 2010 at 6:21 AM, ibrahim saricicek <ibrahimsaricicek <at> gmail.com> wrote:
Hi;

for reverse geoceding now using this and works fine;

SELECT id, the_geom
FROM (roads, settlements, poi, province, etc...)
WHERE
  the_geom && SetSRID('BOX3D(x+0.01 y+0.01, x-0.01 y-0.01)'::box3d, 4326)
ORDER BY
  ST_Distance(the_geom, GeomFromText('POINT(x y)', 4326))
LIMIT 1;

regards...


On Fri, Mar 19, 2010 at 8:23 PM, Stephen Woodbridge <woodbri <at> swoodbridge.com> wrote:
http://www.google.com/#hl=en&source=hp&q=postgis+geocoder

Ricardo Bayley wrote:
Hi fellows,

I was wondering if any of you have a good approach to do Address Geocoding within postgis.
Any ideas, considerations, thoughts ??

thanks in advanced.


Warm regards,


Ricardo


------------------------------------------------------------------------


_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Tobias Sauerwein | 1 Apr 15:34 2010

DWithin when distance is 0

Hi,

I am having some troubles using DWithin when the passed-in distance is 0. My query should return all geometries that are within or within a given distance of a rectangle. DWithin works fine as long as the distance not equals 0. If so, no geometries are returned. If I choose a very small distance it works somehow.

select AsText(the_geom) from points where ST_DWithin(the_geom, ST_GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326), 0);
 astext
--------
(0 rows)

select AsText(the_geom) from points where ST_DWithin(the_geom, ST_GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326), 0.000000000000000000000000000000000000000000000000000001);
            astext            
-------------------------------
 POINT(56.25 32.34375)
 POINT(-45 47.8125)
 POINT(-26.71875 -54.140625)
 POINT(116.3671875 61.171875)
 POINT(131.8359375 -21.796875)
(5 rows)


I am using version 1.3.3, so according to the manual [1] and this workshop [2], ST_DWithin is just translated into a combination of ST_Expand, && and ST_Distance. But if I make a query that looks like the definition of ST_DWithin, the points are returned.

select AsText(the_geom) from points
where
  the_geom && ST_Expand(GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326), 0)
AND
  GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326) && ST_Expand(the_geom, 0)
AND
  ST_Distance(the_geom, GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326)) <= 0;
            astext            
-------------------------------
 POINT(56.25 32.34375)
 POINT(-45 47.8125)
 POINT(-26.71875 -54.140625)
 POINT(116.3671875 61.171875)
 POINT(131.8359375 -21.796875)
(5 rows)


Is this behaviour intented?

Thank you,
Tobias


[1]: http://www.postgis.org/documentation/manual-1.5/ST_DWithin.html
[2]: http://workshops.opengeo.org/postgis-spatialdbtips/click-analyze.html

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Gmane