6

Does any has any experience with converting string geojson into com.vividsolutions.jts geometry object (point, polygon, etc). Maybe there is some java library I cannot find.

Greets!

5

GeoTools provides a GeoJSON module which will read in GeoJSON files and convert them to GeoTools Feature Collections - the geometry elements of these collections is stored as a JTS object. So all you need is

 Geometry geom = (Geometry) feature.getDefaultGeometry();
12

For a much more lightweight alternative to GeoTools, check out jts2geojson:

GeoJSONReader reader = new GeoJSONReader();
Geometry geometry = reader.read(json);
4

There seems to be nowadays also native GeoJSON reader/writer code in JTS trunk:

https://sourceforge.net/p/jts-topo-suite/code/HEAD/tree/trunk/jtsio/src/main/java/com/vividsolutions/jts/io/geojson/

EDIT

OpenJUMP can read and write GeoJSON with code that is in https://sourceforge.net/p/jump-pilot/code/HEAD/tree/core/trunk/src/com/vividsolutions/jump/io/geojson/. Perhaps it could be reused.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.