Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pramsey
Created October 26, 2017 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pramsey/38e09e64a951599bc708ba9ce51a0262 to your computer and use it in GitHub Desktop.
Save pramsey/38e09e64a951599bc708ba9ce51a0262 to your computer and use it in GitHub Desktop.
--
-- Polygons in contained in a 10000x10000
-- square, with just enough size/density to mostly
-- cover the whole area.
--
DROP TABLE IF EXISTS polygon_table_10000;
CREATE TABLE polygon_table_10000 AS
SELECT ST_Buffer(
ST_SetSRID(
ST_MakePoint(random() * 10000, random() * 10000),
26910),
100,32)::geometry(polygon, 26910) AS geom,
generate_series(0, 9999) as id;
--
-- Lines in the 10000x10000 square, we need
-- more of them to generate load because they
-- are much smaller than the polygons.
--
DROP TABLE IF EXISTS line_table_100000;
CREATE TABLE line_table_100000 AS
SELECT id, ST_SetSRID(ST_MakeLine(
ST_MakePoint(x1, y1),
ST_MakePoint(x1+(0.5-random())*200, y1+(0.5-random())*200)
),26910) AS geom
FROM
(SELECT random() * 10000 AS x1, random() * 10000 AS y1, generate_series(0, 99999) as id) a;
--
-- Points in the 10000x10000 square, we need
-- even more of them to generate load because they
-- are much smaller than the lines.
--
DROP TABLE IF EXISTS pt_table_1000000;
CREATE TABLE pt_table_1000000 AS
SELECT id, ST_SetSRID(ST_MakePoint(x1, y1),26910) AS geom
FROM
(SELECT random() * 10000 AS x1, random() * 10000 AS y1, generate_series(0, 999999) as id) a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment