Skip to content

Instantly share code, notes, and snippets.

@ramiroaznar
Created July 21, 2017 08:48
Show Gist options
  • Save ramiroaznar/7a1ff6dbf64087767ef422bf8bfe55fa to your computer and use it in GitHub Desktop.
Save ramiroaznar/7a1ff6dbf64087767ef422bf8bfe55fa to your computer and use it in GitHub Desktop.
Buffer radious based on earthquake magnitude
select
cartodb_id,
'minor' as type,
ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom,
ST_Transform(ST_Buffer(the_geom::geography, 100000)::geometry, 3857) AS the_geom_webmercator
from
all_day
where
mag <= 2.9
UNION ALL
select
cartodb_id,
'light' as type,
ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom,
ST_Transform(ST_Buffer(the_geom::geography, 300000)::geometry, 3857) AS the_geom_webmercator
from
all_day
where
mag > 2.9 and mag <= 3.9
UNION ALL
select
cartodb_id,
'moderate' as type,
ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom,
ST_Transform(ST_Buffer(the_geom::geography, 500000)::geometry, 3857) AS the_geom_webmercator
from
all_day
where
mag > 3.9 and mag <= 4.9
UNION ALL
select
cartodb_id,
'strong' as type,
ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom,
ST_Transform(ST_Buffer(the_geom::geography, 700000)::geometry, 3857) AS the_geom_webmercator
from
all_day
where
mag > 4.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment