Skip to content

Instantly share code, notes, and snippets.

@adam-acosta
Created March 4, 2014 17:39
Show Gist options
  • Save adam-acosta/9351648 to your computer and use it in GitHub Desktop.
Save adam-acosta/9351648 to your computer and use it in GitHub Desktop.
CartoDB PostGIS SQL Intersect. fucking cartodb temp solution to more than one row returned error, see distinctLimitIntersect.sql. not sure if the distinct and limit are both needed, i think at least limit is needed. it won't work with distinct alone.
UPDATE table
SET city_end = (
SELECT DISTINCT cityname
FROM cities
WHERE ST_Intersects(the_geom, table.the_geom)
LIMIT 1
)
UPDATE gps_end
SET city = (
SELECT cityname
FROM cities
WHERE ST_Intersects(the_geom, gps_end.the_geom)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment