Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

We are looking to load and display a shapefile, simple polygons, then write out a WKT string of that shapefile and have the user save it somewhere.

Does anyone have some code snippets of that very function or a link to a site that covers this need?

I imagine we will be using Geotools and java to do this.

share|improve this question
    
shp2psql -w shape.shp > some.sql , then extract WKT from sql script is one option –  simplexio Dec 4 '12 at 8:02
add comment

1 Answer

You could use the JTS WKTWriter to convert geometries read in from the Shapefile to WKT and then save the strings to a file the user chose. Reading in a Shapefile and accessing the geometries are covered in the CRS tutorial.

share|improve this answer
1  
Yes, and invoking the method "toString" on each JTS geometry will return directly its WKT representation. –  julien May 24 '12 at 9:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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