[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] grouing points on a grid
From:       Sandro Santilli <strk () keybit ! net>
Date:       2013-03-20 12:23:36
Message-ID: 20130320122336.GC16037 () gnash
[Download RAW message or body]

On Wed, Mar 20, 2013 at 12:58:08PM +0100, toni hern=E1ndez wrote:
> Hello,
> =

> I have 1 million points and I need to group them on a grid.
> I also need to know how many of thouse points are on each cell of the gri=
d.
> =

> =

> My first thought was some SQL like this one:
> =

> select count(*) as n , st_snaptogrid(geom, size)
> from myPoints group by st_snaptogrid(geom, size)
> =

> I thought as well about indexing myPoints table and even do some
> clustering (Cluster geom on myPoints)
> =

> Which is the best way to do this query?

I think the SnapToGrid way is the fastest you can currently run
to cluster your points. Index won't help as you're going to scan
the whole table anyway.

With limited performance penalty you may return something nicer
than the snapped point, for example a convex hull or the centroid
of the collection (to avoid a "griddy" look).

--strk;
_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic