I want to convert geom
(geometry
) datatype to GeoJSON. How could I do that?
For example, the geometry in WKT:
POLYGON((4552
If you have access to PostgreSQL/PostGIS, you can use ST_GeomFromText
to read in the geometry and ST_AsGeoJSON
to save the geometry as a GeoJSON:
SELECT ST_AsGeoJSON(ST_GeomFromText('POLYGON((455216.346127297
4288433.28426224,455203.386722146 4288427.76317716,455207.791765017
4288417.51116228,455220.784166744 4288423.30230044,455216.346127297
4288433.28426224))'));
, which generates:
-------------------------------------------------------------------------------
{"type":"Polygon","coordinates":[[[455216.346127297,4288433.28426224],
[455203.386722146,4288427.76317716],[455207.791765017,4288417.51116228],
[455220.784166744,4288423.30230044],[455216.346127297,4288433.28426224]]]}
(1 row)