Class EsriShapefile

java.lang.Object
ucar.unidata.gis.shapefile.EsriShapefile

public class EsriShapefile extends Object
EsriShapefile.java Encapsulates details of ESRI Shapefile format, documented at http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
Author:
Russ Rew
  • Field Details

  • Constructor Details

    • EsriShapefile

      public EsriShapefile(String filename) throws IOException
      Read an ESRI shapefile and extract all features into an in-memory structure.
      Parameters:
      filename - name of ESRI shapefile (typically has ".shp" extension)
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(URL url) throws IOException
      Read an ESRI shapefile from a URL and extract all features into an in-memory structure.
      Parameters:
      url - URL of ESRI shapefile
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(String filename, double coarseness) throws IOException
      Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.
      Parameters:
      filename - name of ESRI shapefile (typically has ".shp" extension)
      coarseness - to tradeoff plot quality versus speed.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(URL url, double coarseness) throws IOException
      Read an ESRI shapefile from a URL and extract all features into an in-memory structure, with control of time versus resolution.
      Parameters:
      url - URL of ESRI shapefile
      coarseness - to tradeoff plot quality versus speed.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(URL url, Rectangle2D bBox, double coarseness) throws IOException
      Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.
      Parameters:
      url - URL of ESRI shapefile
      bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
      coarseness - to tradeoff plot quality versus speed.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(String filename, Rectangle2D bBox, double coarseness) throws IOException
      Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.
      Parameters:
      filename - name of ESRI shapefile
      bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
      coarseness - to tradeoff plot quality versus speed.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(URL url, Rectangle2D bBox) throws IOException
      Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.
      Parameters:
      url - URL of ESRI shapefile
      bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(String filename, Rectangle2D bBox) throws IOException
      Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.
      Parameters:
      filename - name of ESRI shapefile
      bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • EsriShapefile

      public EsriShapefile(InputStream iStream, Rectangle2D bBox, double coarseness) throws IOException
      Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box, with control of time versus resolution.
      Parameters:
      iStream - input from which to read
      bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
      coarseness - the coarseness
      Throws:
      IOException - Signals that an I/O exception has occurred.
  • Method Details

    • getDbFile

      public DbaseFile getDbFile()
      Get the Dbase file object
      Returns:
      the DbaseFile object; may be null
    • getProjFile

      public ProjFile getProjFile()
      Get the projection file
      Returns:
      the projection file; may be null
    • percentRead

      public double percentRead()
      Return percent of file read, so far.
      Returns:
      percent of file read, so far.
    • getNumFeatures

      public int getNumFeatures()
      Returns:
      number of features in shapefile
    • numShapes

      public int numShapes()
      Returns:
      number of features in shapefile deprecated
    • getVersion

      public int getVersion()
      Returns shapefile format version (currently 1000)
      Returns:
      version, as stored in shapefile.
    • getBoundingBox

      public Rectangle2D getBoundingBox()
      Get bounding box, according to file (not computed from features)
      Returns:
      bounding box for shapefilew, as stored in header.
    • getFeatures

      public List getFeatures()
      Get a List of all the GisFeatures in the shapefile. This is very fast after the constructor has been called, since it is created during construction.
      Returns:
      a List of features
    • getFeatures

      public List getFeatures(Rectangle2D bBox)
      Get a List of all the features in the shapefile that intersect the specified bounding box. This requires testing every feature in the List created at construction, so it's faster to just give a bounding box o the constructor if you will only do this once.
      Parameters:
      bBox - specifying the bounding box with which all the returned features bounding boxes have a non-empty intersection.
      Returns:
      a new list of features in the shapefile whose bounding boxes intersect the specified bounding box.
    • getFeatureType

      public int getFeatureType()
      Get the feature type
      Returns:
      the type
    • main

      public static void main(String[] args) throws IOException
      The main method.
      Parameters:
      args - the arguments
      Throws:
      IOException - Signals that an I/O exception has occurred.