block by andrewxhill 8440409

Moving Alaska and Hawaii in CartoDB

Full Screen

index.html

<!doctype html>
<head>
	<title>Shifted Alaska/Hawaii | CartoDB.js</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <link rel="shortcut icon" href="//cartodb.com/assets/favicon.ico" />
    <style>
      html, body, iframe {
        height: 100%;
        padding: 0;
        margin: 0;
      }
     </style>
</head>
<body>
	<iframe width='100%' height='100%' frameborder='0' src='//andrew.cartodb.com/viz/84cc0972-7e0c-11e3-a4e1-3085a9a9563c/embed_map?title=true&description=true&search=false&shareable=true&cartodb_logo=true&layer_selector=false&legends=false&scrollwheel=true&sublayer_options=1&sql=&zoom=3&center_lat=34.95799531086792&center_lon=-102.216796875'></iframe>
</body>
</html>

AlaskaHawaiiShift.sql

-- The SQL below was used to tweak a normal dataset of the USA. If you want to download the 
-- already modified version, head over to,
-- https://andrew.cartodb.com/tables/cd113_01_shift/map

--Alaska, move and rotate
UPDATE cd113_01_shift SET the_geom = ST_Transform(ST_Scale(ST_Translate(the_geom_webmercator,-13000000,-4000000),0.5,0.5),4326) WHERE statefp='02';
UPDATE cd113_01_shift SET the_geom = ST_Transform(ST_Rotate(the_geom_webmercator,pi()/8,-16500000,2800000),4326) WHERE statefp='02'

--Hawaii, shift right and scale
UPDATE cd113_01_shift SET the_geom = ST_Multi(ST_Transform(ST_Scale(ST_Translate(the_geom_webmercator,-6000000,3000000), 0.5, 0.5),4326)) WHERE statefp='15'