Skip to content

Instantly share code, notes, and snippets.

@rustyb
Last active August 29, 2015 14:01
Show Gist options
  • Save rustyb/0f29c35fcc979c05904e to your computer and use it in GitHub Desktop.
Save rustyb/0f29c35fcc979c05904e to your computer and use it in GitHub Desktop.
This gist contains the queries used to make the vizualisations used in my blog post on natura 2000 sites within 5-10km of a wind turbine in Ireland.

Below you will find the queries I ran in order to make the buffers around the wind turbine points and also to show the sites within these buffers.

make 10km buffers around windturbines

SELECT cartodb_id, ST_Transform(ST_Buffer(the_geom::geography,10000)::geometry, 3857) as the_geom_webmercator FROM ie_windfarms_osm

make 5km buffers around windturbines

SELECT cartodb_id, ST_Transform(ST_Buffer(the_geom::geography,5000)::geometry, 3857) as the_geom_webmercator FROM ie_windfarms_osm

Count number of sites within 10km

SELECT count(*)
FROM wind_10km 
JOIN natura_ie
ON ST_Intersects(ST_Transform(natura_ie.the_geom, 3857), ST_Transform(wind_10km.the_geom, 3857))

Count number of sites within 5km

SELECT count(*)
FROM wind_5km 
JOIN natura_ie
ON ST_Intersects(ST_Transform(natura_ie.the_geom, 3857), ST_Transform(wind_5km.the_geom, 3857))

To create the Viz layer showing only the sites within 5km

SELECT
natura.site_name, natura.the_geom_webmercator, natura.cartodb_id
FROM wind_5km 
JOIN natura_ie AS natura
ON ST_Intersects(ST_Transform(natura.the_geom, 3857), ST_Transform(wind_5km.the_geom, 3857))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment