PostGIS normalize_geometry PL/pgSQL function to remove spikes and simplify geometries with PostGIS. Documentation and examples at https://gasparesganga.com/labs/postgis-normalize-geometry/