Changes between Initial Version and Version 1 of UsersWikiGenerateHexagonalGrid


Ignore:
Timestamp:
04/14/09 11:02:13 (16 years ago)
Author:
pierre
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiGenerateHexagonalGrid

    v1 v1  
     1= Generate Hexagonal Grid =
     2
     3
     4The following SQL generates a table containing a set of polygons forming
     5a grid of hexagonal cells.
     6
     7Substitute the values in the generate_series calls with the desired min/max X/Y extents.
     8
     9 
     10{{{
     11CREATE TABLE hex_grid (gid serial not null primary key, the_geom geometry not null);
     12
     13 INSERT INTO hex_grid (the_geom)
     14 SELECT translate(the_geom, x_series, y_series)
     15 from generate_series(0 - 128, 10000 + 128, 128) as x_series,
     16 generate_series(0 - 128, 10000 + 128, 256) as y_series,
     17 (
     18   SELECT 'POLYGON((0 0,64 64,64 128,0 192,-64 128,-64 64,0 0))'::geometry as the_geom
     19   UNION
     20   SELECT translate('POLYGON((0 0,64 64,64 128,0 192,-64 128,-64 64,0  0))'::geometry, 64, 128)  as the_geom
     21 ) as one_hex
     22
     23}}}