public class ShapeFileCoordinatesInverter{
public static void convert(String input, String output) throws Exception{
//load shp file
ShapeFileReader reader = null;
reader = new ShapeFileReader(new File(input));
reader.open();
//get all geometries and invert LAT,LNG coordinates
Geometry[] geometries = reader.readAll();
for(int i = 0 ; i < geometries.length ; i++ ){
Coordinate[] coordinates = geometries[i].getCoordinates();
for(int j = 0 ; j < coordinates.length ; j++ ){
double x = coordinates[j].x;
coordinates[j].x = coordinates[j].y;
coordinates[j].y = x;
}
}
//save shp file
ShapeFileWriter writer = null;
writer = new ShapeFileWriter(output);
writer.open();
writer.write(geometries);
//closing Readers, Writers
reader.close();
writer.close();
}