Created
May 17, 2017 22:37
-
-
Save dlebauer/f586e380fa4cfadc25551cd1df487b7d to your computer and use it in GitHub Desktop.
Split plots into east and west. Required some find/replace and sorting in google spreadsheet to generate insert statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with foo as | |
(WITH season1 AS (select id, sitename, geometry as geom from sites where sitename like '%Season 1%' and geometry is not null) | |
SELECT | |
sitename, | |
geom, | |
blade | |
FROM | |
season1 | |
CROSS JOIN LATERAL ( | |
SELECT | |
ST_xMin (geom) + ( | |
ST_xMax (geom) - ST_xMin (geom) | |
) / 2 | |
) AS axis (x) | |
CROSS JOIN LATERAL ST_MakeLine ( | |
ST_MakePoint (axis.x, ST_yMin(geom), 353), | |
ST_MakePoint (axis.x, ST_yMax(geom), 353) | |
) AS blade | |
) SELECT | |
/* ST_AsText (ST_SetSRID(geom, 4326)), | |
ST_AsText (ST_SetSRID(blade, 4326)), */ | |
sitename, | |
ST_DUMP(ST_Split(ST_SetSRID(geom, 4326), st_setsrid(blade, 4326))) as g | |
FROM | |
foo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Further cleanup and parsing to insert statements are here: https://docs.google.com/spreadsheets/d/1s-kQc3K0h4-hfwMzKOU_zpRXN5loByIpKW8Rvw76mh0/edit?usp=sharing
Based on https://gis.stackexchange.com/q/239801/1239