Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql Update Polygon Geometry using ST_removePoint

I Have a table named geofences which stores geometry of Polygon type in column named geometry. I to update the Polygon by removing only one point from the exsisting geometry. For this I Have used the query:

 UPDATE gfe_geofences
   SET geometry = ST_RemovePoint(geometry, ST_NPoints(ST_GeomFromText(
                     'POINT(23.1446787840563 96.002746420167)', 0) ) - 1)
   WHERE is_active = true
     AND ST_IsClosed(the_geom) = true;

But it gives me the error:

ERROR: lwline_deserialize: attempt to deserialize a line which is really a Invalid type

Can you please help me in updating the geometry.

Thanks In Advance.

like image 449
Satish Sharma Avatar asked Aug 29 '12 11:08

Satish Sharma


1 Answers

ST_RemovePoint will only work with linestrings ( see http://postgis.refractions.net/docs/ST_RemovePoint.html. What I would do, use ST_Boundary to get the boundary of your polygon, call ST_RemovePoint on that, then use ST_MakePolygon to construct a new polygon.

like image 141
sovemp Avatar answered Oct 21 '22 09:10

sovemp