Hi Puneet,<div><br></div><div>I used Python to create a list of centroid coordinates based on the specified size of each cell, then i used the ST_Envelope to create the walls of each grid cell.</div><div>Like this:</div><div>
UPDATE priogrid SET cell=geometry(ST_MakeEnvelope(xcoord-"+str(xhalf)+", ycoord-"+str(yhalf)+", xcoord+"+str(xhalf)+", ycoord+"+str(yhalf)+", 4326));<br><br><div class="gmail_quote">
2011/3/8 Paragon Corporation <span dir="ltr"><<a href="mailto:lr@pcorp.us">lr@pcorp.us</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I think uDig still has that problem last we checked, but I don't think QGIS<br>
does. QGIS lets you pick the column.<br>
<div class="im"><br>
-----Original Message-----<br>
From: <a href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a><br>
[mailto:<a href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a>] On Behalf Of Mr.<br>
Puneet Kishor<br>
</div><div class="im">Sent: Monday, March 07, 2011 11:54 PM<br>
To: PostGIS Users Discussion<br>
</div><div><div></div><div class="h5">Subject: Re: [postgis-users] Creating a grid purely in SQL<br>
<br>
Thanks Leo, for the code fragment.<br>
<br>
Re. storing multiple geometries in one column, I found the following caveat<br>
--<br>
<br>
[<a href="http://lists.refractions.net/pipermail/udig-users/2009-March/000553.html" target="_blank">http://lists.refractions.net/pipermail/udig-users/2009-March/000553.html</a>]<br>
<br>
Briefly, is it possible that programs such as QGIS/uDig, etc. would get<br>
confused about which column to draw? Does that concern still apply?<br>
<br>
<br>
On Mar 7, 2011, at 11:50 PM, Paragon Corporation wrote:<br>
<br>
> Puneet,<br>
><br>
> Something like this? This is a bit old. We have some example in our<br>
> book using Common Table Expressions (CTEs) in chapter 8. You can<br>
> download the code to see those as well.<br>
> <a href="http://www.postgis.us/chapter_08" target="_blank">http://www.postgis.us/chapter_08</a><br>
><br>
> <a href="http://www.bostongis.com/postgis_translate.snippet" target="_blank">http://www.bostongis.com/postgis_translate.snippet</a><br>
><br>
> As far as storing two geometry columns in one table. Yes -- Just do<br>
> it by creating another column that is geometry (or using<br>
> AddGeometryColumn function). We do it all the time.<br>
><br>
> Leo<br>
> <a href="http://www.postgis.us" target="_blank">http://www.postgis.us</a><br>
><br>
><br>
><br>
> -----Original Message-----<br>
> From: <a href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a><br>
> [mailto:<a href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a>] On Behalf Of Mr.<br>
> Puneet Kishor<br>
> Sent: Monday, March 07, 2011 11:13 PM<br>
> To: PostGIS Users Discussion<br>
> Subject: [postgis-users] Creating a grid purely in SQL<br>
><br>
> Given a top-left starting point [ulx, uly], and a cell width 'w' and<br>
> height 'h', is it possible to create a table entirely in SQL populated<br>
> with rows increasing from left to right up to X and top to bottom up<br>
> to Y. The table schema would be something like --<br>
><br>
> CREATE TABLE cells (<br>
> cell_id INTEGER NOT NULL,<br>
> xmid DOUBLE PRECISION,<br>
> ymid DOUBLE PRECISION,<br>
> the_geom GEOMETRY,<br>
> CONSTRAINT cells_pkey PRIMARY KEY (cell_id) );<br>
><br>
> where xmid = (xmin + xmax) / 2 and ymid = (ymin + ymax) / 2, [xmin,<br>
> ymin, xmax, ymax] being the corners of each cell.<br>
><br>
> A bonus question -- is it possible to store two geometry columns in<br>
> one table? For example, if I wanted to store the geometry for both the<br>
> center points [xmin, ymid] as well as the box [xmin, ymin, xmax,<br>
> ymax], would that be possible? Would that even be recommended (for<br>
> example, to speed up queries/drawing, etc.).<br>
><br>
> Puneet.<br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
><br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div>