Skip to content

Instantly share code, notes, and snippets.

@andybega
Created June 4, 2013 18:24
Show Gist options
  • Save andybega/5708247 to your computer and use it in GitHub Desktop.
Save andybega/5708247 to your computer and use it in GitHub Desktop.
My first real SQL query in PostGIS. It subsets the geo-referenced ethnic groups (GREG) data to only groups that are present in Afghanistan (instead of including hundreds of groups for the entire world).
CREATE TABLE afg_greg AS
SELECT *
FROM greg
WHERE ( ST_contains((SELECT the_geom FROM afg_adm0), geom) OR
ST_overlaps((SELECT the_geom FROM afg_adm0), geom) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment