You must have a GDAL version that is compiled with a SpatiaLite version that is compiled with LWGEOM features. At least OSGeo4W delivers such GDAL.
A simple test with a self-intersecting geometry and GDAL version
GDAL 2.3.2, released 2018/09/21
POLYGON (( 8 21, 15 21, 8 13, 15 13, 8 21 ))
I stored the polygon into OpenJUMP JML format.
First test with ogrinfo
ogrinfo -dialect sqlite -sql "select ST_MakeValid(geometry) from self_intersection" self_intersection.jml
Had to open data source read-only.
INFO: Open of `self_intersection.jml'
using driver `JML' successful.
Layer name: SELECT
Geometry: Unknown (any)
Feature Count: 1
Extent: (8.000000, 13.000000) - (15.000000, 21.000000)
Layer SRS WKT:
(unknown)
Geometry Column = ST_MakeValid(geometry)
OGRFeature(SELECT):0
MULTIPOLYGON (((11.5 17.0,15 13,8 13,11.5 17.0)),((8 21,15 21,11.5 17.0,8 21)))
Self-intersecting polygon was fixed into a multipolygon. Next test with ogr2ogr and -explodecollections.
ogr2ogr -f jml -dialect sqlite -sql "select ST_MakeValid(geometry) from self_intersection" split_to_polygons.jml self_intersection.jml -explodecollections
Check the result with ogrinfo
ogrinfo split_to_polygons.jml -al
INFO: Open of `split_to_polygons.jml'
using driver `JML' successful.
Layer name: split_to_polygons
Geometry: Unknown (any)
Feature Count: 2
Extent: (8.000000, 13.000000) - (15.000000, 21.000000)
Layer SRS WKT:
(unknown)
R_G_B: String (0.0)
OGRFeature(split_to_polygons):0
R_G_B (String) = (null)
POLYGON ((11.5 17.0,15 13,8 13,11.5 17.0))
OGRFeature(split_to_polygons):1
R_G_B (String) = (null)
POLYGON ((8 21,15 21,11.5 17.0,8 21))
Self-intersecting polygon has been converted into two simple polygons.
st_makevalid
function is simply not available inogr2ogr
, see this post.