[postgis-users] Creating a grid purely in SQL

Mr. Puneet Kishor punk.kish at gmail.com
Mon Mar 7 20:53:31 PST 2011


Thanks Leo, for the code fragment.

Re. storing multiple geometries in one column, I found the following caveat --

[http://lists.refractions.net/pipermail/udig-users/2009-March/000553.html]

Briefly, is it possible that programs such as QGIS/uDig, etc. would get confused about which column to draw? Does that concern still apply?


On Mar 7, 2011, at 11:50 PM, Paragon Corporation wrote:

> Puneet,
> 
> Something like this? This is a bit old.  We have some example in our book
> using Common Table Expressions (CTEs) in chapter 8.  You can download the
> code to see those as well.  http://www.postgis.us/chapter_08
> 
> http://www.bostongis.com/postgis_translate.snippet
> 
> As far as storing two geometry columns in one table.  Yes -- Just do it by
> creating another column that is geometry (or using AddGeometryColumn
> function).  We do it all the time.
> 
> Leo
> http://www.postgis.us
> 
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Mr.
> Puneet Kishor
> Sent: Monday, March 07, 2011 11:13 PM
> To: PostGIS Users Discussion
> Subject: [postgis-users] Creating a grid purely in SQL
> 
> Given a top-left starting point [ulx, uly], and a cell width 'w' and height
> 'h', is it possible to create a table entirely in SQL populated with rows
> increasing from left to right up to X and top to bottom up to Y. The table
> schema would be something like --
> 
> CREATE TABLE cells (
>  cell_id INTEGER NOT NULL,
>  xmid DOUBLE PRECISION,
>  ymid DOUBLE PRECISION,
>  the_geom GEOMETRY,
>  CONSTRAINT cells_pkey PRIMARY KEY (cell_id) );
> 
> where xmid = (xmin + xmax) / 2 and ymid = (ymin + ymax) / 2, [xmin, ymin,
> xmax, ymax] being the corners of each cell.
> 
> A bonus question -- is it possible to store two geometry columns in one
> table? For example, if I wanted to store the geometry for both the center
> points [xmin, ymid] as well as the box [xmin, ymin, xmax, ymax], would that
> be possible? Would that even be recommended (for example, to speed up
> queries/drawing, etc.).
> 
> Puneet.
> _______________________________________________
> 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




More information about the postgis-users mailing list