Skip to content

Instantly share code, notes, and snippets.

@kgjenkins
Last active November 25, 2015 22:20
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 kgjenkins/7547a74bb40f32644905 to your computer and use it in GitHub Desktop.
Save kgjenkins/7547a74bb40f32644905 to your computer and use it in GitHub Desktop.
Create CartoDB dataset of US states with inset Alaska, Hawaii, and Puerto Rico (EPSG:3857)

Intended to be displayed as epsg:3857 or epsg:4326

SELECT
ST_Transform((CASE stusps
  WHEN 'AK' THEN
    ST_TransScale(ST_Rotate(ST_Transform(the_geom, 2163),0.51),-600000,-6400000,0.35,0.35)
  WHEN 'HI' THEN
    ST_TransScale(ST_Rotate(ST_Transform(the_geom, 2163),0.51),4000000,1830000,1.2,1.2)
  WHEN 'PR' THEN
    ST_TransScale(ST_Rotate(ST_Transform(the_geom, 2163),-0.1),-1400000,1600000,1.2,1.2)
  ELSE
    ST_Transform(the_geom, 2163)
END), 3857) AS the_geom_webmercator,
name,
geoid,
statefp,
stusps
FROM cb_2014_us_state_20m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment