Skip to content

Instantly share code, notes, and snippets.

@mtravis
Created November 17, 2016 14:50
Show Gist options
  • Save mtravis/ee372b42f0db5a8292b1bc8206133447 to your computer and use it in GitHub Desktop.
Save mtravis/ee372b42f0db5a8292b1bc8206133447 to your computer and use it in GitHub Desktop.
Creates a SQL statement that will output the total area of each layer in a PostGIS database
Select 'Select ''' || quote_ident(f_table_name) || ''' as name, Sum((ST_Area(' || quote_ident(f_geometry_column) || ')) from '
|| quote_ident(f_table_schema) || '.' || quote_ident(f_table_name) || ' UNION'
FROM geometry_columns
order by f_table_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment