Skip to content

Instantly share code, notes, and snippets.

@andrewxhill
Created May 1, 2013 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewxhill/5495331 to your computer and use it in GitHub Desktop.
Save andrewxhill/5495331 to your computer and use it in GitHub Desktop.
Fustion Tables CSV => Postgresql => Geom fix
with f as (SELECT cartodb_id, ST_GeomFromText(replace(replace(replace(replace(replace(geometry, '<Polygon><outerBoundaryIs><LinearRing><coordinates>', 'Linestring('), '</coordinates></LinearRing></outerBoundaryIs></Polygon>', ')'), ',', '$'), ' ', ','), '$', ' '),4326) geom FROM damage_assesment_by_fema_grants_with_shpe_files where geometry != '' order by geometry desc)
update damage_assesment_by_fema_grants_with_shpe_files d
set the_geom = (
SELECT ST_MakePolygon(ST_AddPoint(f.geom, ST_StartPoint(f.geom))) from f WHERE cartodb_id = d.cartodb_id LIMIT 1
)
@andrewxhill
Copy link
Author

swap out, damage_assesment_by_fema_grants_with_shpe_files with your own table name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment