Glad this was helpful. Below is the actual "production" version I used to test 
the theory. I quickly realized with SRID 2229 (NAD83 Feet) that the 64x128 
hexes were much too fine grained, so I multiplied the dimensions by 100. The 
output looks like a D&D board game ;) , not that I play mind you.

=====================

create table hex_grid (gid serial not null primary key, the_geom geometry not 
null);

INSERT INTO hex_grid (the_geom)
SELECT translate(the_geom, x_series, y_series)
from 
generate_series(
        (select min(st_xmin(the_geom))::int from geometrytable) - 12800, 
        (select max(st_xmax(the_geom))::int from geometrytable) + 12800, 12800
) as x_series,

generate_series(
        (select min(st_ymin(the_geom))::int from geometrytable) - 12800,
        (select max(st_ymax(the_geom))::int from geometrytable) + 12800, 25600
) as y_series,
(
        SELECT 'POLYGON((0 0,6400 6400,6400 12800,0 19200,-6400 12800,-6400 
6400,0 0))'::geometry as the_geom
        UNION SELECT translate('POLYGON((0 0,6400 6400,6400 12800,0 19200,-6400 
12800,-6400 6400,0 0))'::geometry, 6400, 12800)  as the_geom
) as one_hex




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Davis
Sent: Friday, May 30, 2008 10:12 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] hexagonal grid


This is great!  Added to the wiki at  
http://postgis.refractions.net/support/wiki/index.php?GenerateHexagonalGrid

Sufficool, Stanley wrote:
> Generate a hexagonal grid of 64x128 hexes, then follow the slice/dice 
> from bostongis at step 4.
>
> Substitute the values in generate series with your datasource min/max 
> X/Y extents.
>
> ===============================
>
> create table hex_grid (gid serial not null primary key, the_geom 
> geometry not null);
>
> INSERT INTO hex_grid (the_geom)
> SELECT translate(the_geom, x_series, y_series)
> from generate_series(0 - 128, 10000 + 128, 128) as x_series, 
> generate_series(0 - 128, 10000 + 128, 256) as y_series, (
>       SELECT 'POLYGON((0 0,64 64,64 128,0 192,-64 128,-64 64,0 0))'::geometry 
> as the_geom
>       UNION SELECT translate('POLYGON((0 0,64 64,64 128,0 192,-64 128,-64 
> 64,0 0))'::geometry, 64, 128)  as the_geom
> ) as one_hex
>
> ===============================
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Matias Massigoge
> Sent: Thursday, May 29, 2008 12:58 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] hexagonal grid
>
>
> Thanks Paul!!
>
> On Thu, May 29, 2008 at 4:42 PM, Paul Ramsey 
> <[EMAIL PROTECTED]> wrote:
>   
>> Try this:
>>
>> http://www.bostongis.com/blog/index.php?/archives/35-Map-Dicing-and-o
>> t
>> her-stuff.html
>>
>> P.
>>
>> On Thu, May 29, 2008 at 12:34 PM, Matias Massigoge
>> <[EMAIL PROTECTED]> wrote:
>>     
>>> Hi all,
>>>
>>> I'm looking for something similar but squared.
>>> This theme have been covered in the past?
>>> Sorry, I'm newby.
>>> Thanks all.
>>>
>>> Matías
>>>
>>>
>>>
>>> On Thu, May 29, 2008 at 12:42 PM, Brent Wood <[EMAIL PROTECTED]>
>>> wrote:
>>>       
>>>>> On Thu, May 29, 2008 at 7:08 AM, Randall, Eric
>>>>> <[EMAIL PROTECTED]>
>>>>>           
>>>> wrote:
>>>>         
>>>>>> Has anyone created a method for generating a hexagonal grid over
>>>>>> a polygon
>>>>>>             
>>>>> envelope using postgis? Thought I'd ask before setting out.
>>>>> Thanks.
>>>>>           
>>>> Hi Eric
>>>>
>>>> I haven't specifically done this in PostGIS, but have briefly 
>>>> looked
>>>> into something similar with a colleague who uses R extensively, and 
>>>> was looking at cellular automata modelling over a hexagonal grid. He 
>>>> was using such a dataset in R, & there were a few ways this could be 
>>>> transferred to PostGIS, including the R:gdal package, or a 
>>>> dump/parse/reformat/import script.
>>>>
>>>> Cheers,
>>>>
>>>>   Brent Wood _______________________________________________
>>>> postgis-users mailing list [email protected]
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>>
>>>>         
>>> _______________________________________________
>>> postgis-users mailing list [email protected]
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>>       
>> _______________________________________________
>> postgis-users mailing list [email protected]
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>     
> _______________________________________________
> postgis-users mailing list [email protected]
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list [email protected]
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
postgis-users mailing list [email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to