Create hex grids over a layer

المشرف العام

Administrator
طاقم الإدارة
I have a shapefile that has the outlines of the United States and I want to create hex grids that over that layer.

I tried using this function that will create hexes over a layer. I created an empty table and then added a geom column and then ran the custom function as shown.

CREATE TABLE IF NOT EXISTS hex_grid (hid serial NOT NULL PRIMARY KEY) SELECT AddGeometryColumn('hex_grid', 'geom', 0, 'POLYGON', 2); SELECT gen_hexagons(.005, (SELECT geom FROM usa)); However I ran into this error that I'm not sure how to deal, I'm sure it deals with the creation of the hexes when it exceeds the US outline boundary. See below:

integer out of range CONTEXT: SQL statement "INSERT INTO hex_grid (geom) SELECT ST_Translate(geom, x_series * (2 * a + c) + xmin, y_series * (2 * (c + a)) + ymin) FROM generate_series(0, ncol::int , 1) AS x_series, generate_series(0, nrow::int, 1) AS y_series, ( SELECT polygon_string::geometry AS geom UNION SELECT ST_Translate(polygon_string::geometry, b, a + c) AS geom ) AS two_hex" PL/pgSQL function gen_hexagons(double precision,geometry) line 23 at SQL statement

أكثر...
 
أعلى