Skip to content

Instantly share code, notes, and snippets.

@kgjenkins
Last active November 25, 2015 22:27
Show Gist options
  • Save kgjenkins/3ce08a7a70ab2167525d to your computer and use it in GitHub Desktop.
Save kgjenkins/3ce08a7a70ab2167525d to your computer and use it in GitHub Desktop.
Create CartoDB dataset of US counties with inset Alaska, Hawaii, and Puerto Rico (EPSG:2163)

Intended to be displayed as epsg:2163 (National Atlas Equal Area)
(if displayed as epsg:4326 or epsg:3857, PR will be tilted)

SELECT
(CASE statefp
  WHEN '02' THEN
    ST_TransScale(ST_Rotate(ST_Transform(the_geom, 2163),0.51),-600000,-6400000,0.35,0.35)
  WHEN '15' THEN
    ST_TransScale(ST_Rotate(ST_Transform(the_geom, 2163),0.51),4000000,1850000,1.2,1.2)
  WHEN '72' THEN
    ST_TransScale(ST_Rotate(ST_Transform(the_geom, 2163),-0.37),-1350000,2750000,2,2)
  ELSE
    ST_Transform(the_geom, 2163)
END) AS the_geom,
name,
geoid,
statefp,
countyfp
FROM cb_2014_us_county_20m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment