Created
May 1, 2013 13:41
-
-
Save andrewxhill/5495331 to your computer and use it in GitHub Desktop.
Fustion Tables CSV => Postgresql => Geom fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
swap out, damage_assesment_by_fema_grants_with_shpe_files with your own table name