Mit dem Paket toShape aus dem Downloadbereich kann man Java Listen jeglicher Art nutzen um Shapefiles daraus zu erzeugen. Jede Java Liste stellt somit ein Attribut oder eine Spalte eines Shapefiles dar.
Hier ein Beispiel wie die Klasse ToShape genutzt werden kann:
//Create a Geometry Factory from JTS
to be able to add geometry Objects
GeometryFactory fac =
JTSFactoryFinder.getGeometryFactory(null);
//First create ToShape object with
a optional featureName,
the path to the resulting Shapefile,
the CRS and if CRS should be forced
ToShape to1 =
new ToShape(null,
"C:\\temp\\test.shp", DefaultGeographicCRS.WGS84, false);
//Make a list of the coordinates
List<object width="300" height="150"> coords = new ArrayList<object>();
coords.add(fac.createPoint(new Coordinate(11,60)));
coords.add(fac.createPoint(new Coordinate(13,66)));
coords.add(fac.createPoint(new Coordinate(15,68)));
coords.add(fac.createPoint(new Coordinate(19,77)));
//add list and the property Definition to PropAndValues Object
PropAndValues coordList =
new PropAndValues(
new PropertyDef("Koordinaten", Point.class), coords);
//Make the same or String attributes
List<object> stationsnamen = new ArrayList<object>();
stationsnamen.add("St1");
stationsnamen.add("St2");
stationsnamen.add("St3");
stationsnamen.add("St4");
PropAndValues stationenList =
new PropAndValues(
new PropertyDef("Station", String.class), stationsnamen);
//Add the two lists to the ToShape object
to1.addPropertyValues(coordList);
to1.addPropertyValues(stationenList);
//Create the Shapefile
try {
to1.getShape();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}</object></object></object></object>