arthur-e / Wicket

A modest library for moving between Well-Known Text (WKT) and various framework geometries
https://arthur-e.github.io/Wicket/
Other
586 stars 226 forks source link

How to convert WKT (MULTIPOLYGON) to GeoJSON? #91

Closed bubnenkoff closed 6 years ago

bubnenkoff commented 8 years ago

I have got MULTIPOLYGON in WKT format. I need to convert it to GeoJSON. How can I do it?

MULTIPOLYGON(((131.87329292297363 42.95694160461426,131.77997016906738 43.04944038391113,131.9172077178955 43.02110481262207,131.87329292297363 42.95694160461426)),((146.13748359680176 43.45888710021973,146.07608222961426 43.51333045959473,146.22607612609863 43.52555274963379,146.13748359680176 43.45888710021973)),((146.66998481750488 43.70443916320801,146.60467720031738 43.80388069152832,146.90497016906738 
....
arthur-e commented 8 years ago
wkt = new Wkt.Wkt();
wkt.read("MULTIPOLYGON...");
wkt.toJson(); // As object
JSON.stringify(wkt.toJson()); // As string
BayramBASDUVAR commented 7 years ago

Hello, How can we do this when extracting PostgreSQL?

ffflabs commented 6 years ago

If using PostGIS, use ST_Astext(geometry_column) in your select, to get the WKB binary geometry in WKT text format