Skip to content

Instantly share code, notes, and snippets.

@auremoser
Last active October 12, 2015 03:18
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 auremoser/3963197 to your computer and use it in GitHub Desktop.
Save auremoser/3963197 to your computer and use it in GitHub Desktop.
SQL tipsheet
SET GEOM FOR NYC
================
UPDATE name_of_db SET the_geom = ST_Transform(ST_SetSRID(ST_MakePoint(x_coordinate, y_coordinate),2263),4326)
//Order of Operations nested commands
//ST_MakePoint(x,y) turns any x, y value into a geometry.
(If this was latitude and longitude, that is the same as saying ST_MakePoint(longitude, latitude); backwards (x,y)->(long,lat)
//ST_SetSRID(our_new_geom, 2263)
//wrap in ST_Transform to 4326 - standard projection for geom column always - lat/long
CHANGE PROJECTION
=================
SELECT ST_Transform(the_geom_webmercator,26935) AS the_geom_webmercator FROM table_name
SEE ALL PROJECTIONS
===================
SELECT * FROM spatial_ref_sys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment