<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Jeff,<br><br>I tend to use a vector based solution for this sort of analysis. I am not up to speed with the raster capability of Postgis, but this sort of operation can certainly be done with vectors.<br><br> I do this pretty often for gridded analyses of commercial fishing data from start/finish positions, eg: <br>
<a href="http://www.deepwater.co.nz/f2111,103784/103784_22_Baird_Wood_2009_BEN2006-01.pdf">http://www.deepwater.co.nz/f2111,103778/103778_20_Baird_et_al_2011_AEBR_73.pdf</a><br>
<br>
Appendix F has some of the maps, with pixels analysed by species. From a FOSS 
perspective, if anyone is interested, the data were managed in Postgis, 
analysed in Postgis & R, previewed in Quantum GIS, with many of the 
maps generated automatically from the data using GMT. Excel & Arcmap
 were also used, but it was very much a FOSS based project. <br><br><br>Back on topic :-)<br><br>A raster is a set of cells. Create a table with the cells as (indexed) polygons squares)  & do a normal Postgis vector intersection query.<br><br>There are a few examples of how to create such a grid, such as:<br><a href="http://gis.stackexchange.com/questions/16374/how-to-create-a-regular-polygon-grid-in-postgis">http://gis.stackexchange.com/questions/16374/how-to-create-a-regular-polygon-grid-in-postgis</a><br><br>Then:<br><br>create table hits as<br>select cell_id, line_id from cells, lines where intersects(lines.geom, cells.geom); <br><br>You can then query the values in the hits table, joined to the lines to do all sorts of summary stats around the lines/cell values.<br><br>An alternative approach, which gives very similar results, perhaps more robustly in some ways, is to use the points as you mentioned, but return lines which intersect a
 buffer of the point, using something like:<br><br>create table hits as <br>select point_id, line_id from point, line <br>where intersects(line.geom, ST_Buffer(point.geom, N));<br><br>So rather than gridding your data, you are identifying the points that each line was with distance (N) of. Subtly different result, because the distance between the centre of the cell is not the same to all points on the cell boundary, & the buffered circles will either overlap, or leave gaps in the "grid" to intersect with the lines. So N could be 1/2 the diagonal or perpendicular distance between neighbouring points... <br><br><br>& to get a cell where the diagonal distance issue is reduced (all cell boundary vertices are equidistant from the cell centroid), you can use hexagonal cells instead of square. Lots of refinements possible with vectors that are not easy with rasters!<br><br><br><br>HTH,<br><br>  Brent Wood <br><br><br>--- On <b>Sun, 12/23/12, Jeff
 Adams - NOAA Affiliate <i><jeff.adams@noaa.gov></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Jeff Adams - NOAA Affiliate <jeff.adams@noaa.gov><br>Subject: [postgis-users] Simple Line Density<br>To: postgis-users@lists.osgeo.org<br>Date: Sunday, December 23, 2012, 9:07 AM<br><br><div id="yiv1967798387">Hi,<br><br>I was wondering if anybody knew of a way to create a very 
simple line density raster. I am not interested in interpolation or 
clustering, simply how many line features pass through each pixel in the
 raster. I know how to do this with points, but am having difficulty 
figuring out how to do it with lines. Any help would be greatly 
appreciated...<br clear="all"><br>J
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>postgis-users mailing list<br><a ymailto="mailto:postgis-users@lists.osgeo.org" href="/mc/compose?to=postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></table>