Skip to content

Instantly share code, notes, and snippets.

@makella
Last active May 23, 2026 00:00
Show Gist options
  • Select an option

  • Save makella/a3fb1786688232cd1e45 to your computer and use it in GitHub Desktop.

Select an option

Save makella/a3fb1786688232cd1e45 to your computer and use it in GitHub Desktop.
projections

Projections in CartoDB!

Every CartoDB account comes with a default set of projections. To see which projections are available, type the following into any SQL tray:

SELECT * FROM spatial_ref_sys

This brings up a list of the projections that are available by default:

projection1

Don't see the projection you want to use? No problem! You can add any projection using its SQL (PostGIS) definition.
For example, to add the World Robinson projection, add the INSERT statement to your SQL tray and hit Apply Query:

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 54030, 'ESRI', 54030, '+proj=robin +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs ',         'PROJCS["World_Robinson",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Robinson"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",0],UNIT["Meter",1],AUTHORITY["EPSG","54030"]]');

projection2

The definition for the projection is now added to your list of available projections.

Now that you have the projection added, you can project any data that you have in your account. This example uses the ne_50m_land layer available in CartoDB's Data Library.

In your layer's SQL tray, add the following ST_Transform statement:

SELECT 
    ST_Transform(the_geom, 54030) 
AS        
    the_geom_webmercator
FROM 
    ne_50m_land 

projection3

And you now have your data projected in World Robinson!

mamataakella:https://mamataakella.cartodb.com/api/v2/viz/8e58c752-6eb8-11e5-a5bf-0e98b61680bf/viz.json

To project multiple layers in your map, add the same ST_Transform SQL to each one.

mamataakella:https://mamataakella.cartodb.com/api/v2/viz/acdfddde-693e-11e5-b305-0e674067d321/viz.json  

Other Projections

Albers Equal Area Conic

PostGIS INSERT text found here

SELECT 
    ST_Transform(the_geom, 102008) 
AS        
    the_geom_webmercator
FROM 
    ne_50m_land   

mamatablog:https://mamatablog.cartodb.com/api/v2/viz/b251ee9e-6d33-11e5-9f65-0ecfd53eb7d3/viz.json  

Mollweide

PostGIS INSERT text found here

SELECT 
    ST_Transform(the_geom, 54009) 
AS        
    the_geom_webmercator
FROM 
    ne_50m_land

mamatablog:https://mamatablog.cartodb.com/api/v2/viz/4f043192-6d35-11e5-9ce2-0e787de82d45/viz.json

Eckert IV

PostGIS INSERT text found here

SELECT 
    ST_Transform(the_geom, 54012) 
AS        
    the_geom_webmercator
FROM 
    ne_50m_land

mamatablog:https://mamatablog.cartodb.com/api/v2/viz/ebf25da2-6d2c-11e5-874d-0e3ff518bd15/viz.json

Behrmann Equal Area Cylindrical

PostGIS INSERT text found here

SELECT 
    ST_Transform(the_geom, 54017) 
AS        
    the_geom_webmercator
FROM 
    ne_50m_land

mamatablog:https://mamatablog.cartodb.com/api/v2/viz/f41b38f8-6d2e-11e5-920b-0ea31932ec1d/viz.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment