Class ShapefileWriter


  • public class ShapefileWriter
    extends Object
    ShapefileWriter allows for the storage of geometries in esris shp format. During writing, an index will also be created. To create a ShapefileWriter, do something like
    GeometryCollection geoms; File shp = new File("myshape.shp"); File shx = new File("myshape.shx"); ShapefileWriter writer = new ShapefileWriter( shp.getChannel(),shx.getChannel() ); writer.write(geoms,ShapeType.ARC); This example assumes that each shape in the collection is a LineString.
    Author:
    jamesm, aaime, Ian Schneider
    See Also:
    ShapefileWriter.java
    • Constructor Detail

    • Method Detail

      • getShpChannel

        public FileChannel getShpChannel()
        Returns:
        The Shape File Channel
      • writeHeaders

        public void writeHeaders​(ShapeType type)
                          throws IOException
        Write the headers for this shapefile.Use this function before inserting the first geometry, then when all geometries are inserted.
        Parameters:
        type - Shape type
        Throws:
        IOException
      • writeGeometry

        public void writeGeometry​(org.locationtech.jts.geom.Geometry g)
                           throws IOException
        Write a single Geometry to this shapefile. The Geometry must be compatable with the ShapeType assigned during the writing of the headers.
        Parameters:
        g -
        Throws:
        IOException