-
-
Save dlebauer/5863664 to your computer and use it in GitHub Desktop.
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
### this works | |
SELECT cartodb_id, ST_GeomFromText(replace(replace(replace(replace(replace(geometry, '<Polygon><outerBoundaryIs><LinearRing><coordinates>', 'Linestring('), '</coordinates></LinearRing></outerBoundaryIs></Polygon>', ')'), ',', '$'), ' ', ','), '$', ' '),4326) geom FROM test_yield_county | |
### the official query | |
delete FROM test_yield_county where geometry = '' | |
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 test_yield_county order by geometry desc) | |
update test_yield_county 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