Re: [postgis-users] Calculate variance of a multipoint

2011-08-21 Thread Aren Cambre
Just wanted to again say thanks for this help from last May.

It turns out that my problem was that I was inadvertently geocoding some
state highway mile markers to US highways and vice versa. The dataset that
identified the events didn't well-distinguish between them...until I found a
field named "str1" (what a descriptive name!!) that provided the highway
designation more clearly.

After getting that fixed, the upper end of the variance on my geocoding
dropped sharply.

Aren

On Sat, May 28, 2011 at 8:09 AM, Aren Cambre  wrote:

> Thank you!
>
>
> On Fri, May 27, 2011 at 9:33 PM, Stephen Woodbridge <
> wood...@swoodbridge.com> wrote:
>
>> Aren,
>>
>> Your purposed approach sounds reasonable to me. You can do it all in one
>> query like:
>>
>> select c.gid, sum(c.dist*c.dist)/count(*) as variance
>>  from (
>>select b.gid, b.cent, st_distance(b.geom, b.cent) as dist
>>  from (
>>select a.gid, (st_dump(a.the_geom)).geom as geom,
>> centroid(a.the_geom) as cent
>>  from (
>>select 99 as gid, 'MULTIPOINT(1 2,2 3,3 4,4 5)'::geometry as
>> the_geom
>>union all
>>select 88 as gid, 'MULTIPOINT(1 2,2 3,3 4,4 5,3 5,9
>> 9)'::geometry as the_geom
>>) as a
>>) as b
>>) as c
>>  group by gid order by variance desc;
>>
>> You should be able to replace the select...union all select ... with your
>> table of multipoints.
>>
>> -Steve W
>>
>>
>> On 5/27/2011 6:19 PM, Aren Cambre wrote:
>>
>>> Did anyone have thoughts on this? :-)
>>>
>>> Aren
>>>
>>> On Wed, May 4, 2011 at 2:12 PM, Aren Cambre >> > wrote:
>>>
>>>The more I think about it, is this a job for R? I know I need to
>>>start using R at some point, just haven't begun yet.
>>>
>>>Aren
>>>
>>>
>>>On Wed, May 4, 2011 at 1:42 PM, Aren Cambre >>> wrote:
>>>
>>>Suppose you have a geometry type with a multipoint. How would
>>>you calculate the variance of the points in that multipoint?
>>>
>>>I looked through the PostGIS 1.5 function reference and am not
>>>coming up with any easy way.
>>>
>>>A hard way seems to be using st_centroid(multipoint) to find the
>>>multipoint's  center. From there, I can calculate the distance
>>>of each point from its center, and use that towards calculating
>>>the variance (each distance is squared, all squared distances
>>>are added together, then divide by number of points).
>>>
>>>I guess my ultimate need is to measure relative dispersion of
>>>multipoints. The multipoints that have the most dispersion are
>>>suspect, but I need a way of identifying which ones are like this.
>>>
>>>Aren
>>>
>>>
>>>
>>>
>>>
>>> ___
>>> postgis-users mailing list
>>> postgis-users@postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>
>> ___
>> postgis-users mailing list
>> postgis-users@postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>
>
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Nearest line from a point

2011-08-21 Thread Stephen Woodbridge

On 8/21/2011 1:07 AM, Jaime Casanova wrote:

On Sat, Aug 20, 2011 at 2:58 PM, Stephen Woodbridge
  wrote:

On 8/20/2011 3:34 PM, Jaime Casanova wrote:


On Sat, Aug 20, 2011 at 7:36 AM, Charles Galpinwrote:


I assume you mean it takes a long time? The key is to create a buffer
around the point that is as big as you feel necessary to make a
match, and then in your where clause only match lines that intersect
this. That way the index is used to limit the number of
candidates to get the distance for.  Something like

where line&&st_expand(myPoint, bufferSizeInYourProjectionUnits)



st_dwithin() doesn't do this automatically?
but i should admit it wasn't useful for me... it still require a seq
scan on the whole table



Have you create a gist (not a btree) index on your geometry column?



Yes, I have... Here was posted my problem
(http://postgis.refractions.net/pipermail/postgis-users/2011-August/030559.html)
and this is the EXPLAIN ANALYZE using st_dwithin() in the query
(http://explain.depesz.com/s/rbX)

the table has a GiST index on the table transmitter_mv



I don't use st_dwithin() that much although it is supposed to be faster 
than using:


where line&&st_expand(myPoint, bufferSizeInYourProjectionUnits)

But what I did find interesting is that in your explain it seemed to be 
using ::geography casts instead of ::geometry, not that that explains 
anything to me. Is your spatial column defined as geography or geometry?


-Steve
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users