Last active
April 14, 2020 19:02
-
-
Save nautilytics/24194b51187a35caea06d899113bc0d0 to your computer and use it in GitHub Desktop.
Retrieve a FeatureCollection of affected counties joined with wind speed data for Hurricane Sandy
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
SELECT ROW_TO_JSON(fc) AS json_out FROM ( | |
SELECT 'FeatureCollection' AS type, | |
ARRAY_TO_JSON(ARRAY_AGG(f)) AS features | |
FROM ( | |
SELECT 'Feature' AS type, | |
ST_AsGeoJSON(c.geom)::json AS geometry, | |
ROW_TO_JSON(( | |
SELECT l FROM ( | |
SELECT r.radii, | |
r.synoptime, | |
r.basin, | |
r.stormnum, | |
r.ne, | |
r.se, | |
r.sw, | |
r.nw, | |
r.gid AS id, | |
c.geoid AS fips | |
) AS l)) AS properties | |
FROM tl_2019_us_county AS c, al182012_radii AS r | |
WHERE ST_Intersects(c.geom, ST_MakeValid(r.geom)) | |
) f | |
) fc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment