[GIS] ny efficient way to convert GeoJSON to WKT

convertgeojsonpostgiswell-known-text

I want to use ST_GeomFromText() to load vector data to PostGIS. However, I don't know how to convert from Geojson type to WKT.

N.B. I know I can use OGR2OGR to upload the GeoJSON directly, but I just want to confirm if there is any way to convert it or not.

Best Answer

why not use

see Creating GeoJSON Feature Collections with JSON and PostGIS functions or ST_GeomFromGeoJSON from OpenGeo.

To convert to WKT, use

  • ST_AsText , the reverse of ST_GeomFromText() which return the Well-Known Text (WKT)
  • ST_AsEWKT same with SRID meta data