Package ucar.unidata.gis.shapefile
Class EsriShapefile
java.lang.Object
ucar.unidata.gis.shapefile.EsriShapefile
EsriShapefile.java
Encapsulates details of ESRI Shapefile format, documented at
http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
- Author:
- Russ Rew
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassEsriFeature.java Created: Sat Feb 20 17:19:53 1999classRepresents a Multipoint in an ESRI shapefile.classA NULL shape in an ESRI shapefile.classRepresents a single point in an ESRI shapefile.classClass descriptionclassRepresents a Polygon in an ESRI shapefile as a List of GisParts.classRepresents a PolygonZ in an ESRI shapefile as a List of GisParts.classRepresents a Polyline in an ESRI shapefile as a List of GisParts.classClass description -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intmuti patchstatic final intmultipoint shapestatic final intMeasured multi pointstatic final intmultipoint with zstatic final intnull shapestatic final intpoint shapestatic final intMeasured pointstatic final intpoint with Zstatic final intpolygon shapestatic final intMeasured polygonstatic final intpolygon with zstatic final intpolyline shapestatic final intMeasured polylinestatic final intpolyline with zstatic final intshapefile magic number -
Constructor Summary
ConstructorsConstructorDescriptionEsriShapefile(InputStream iStream, Rectangle2D bBox, double coarseness) 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.EsriShapefile(String filename) Read an ESRI shapefile and extract all features into an in-memory structure.EsriShapefile(String filename, double coarseness) Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.EsriShapefile(String filename, Rectangle2D bBox) Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.EsriShapefile(String filename, Rectangle2D bBox, double coarseness) Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.EsriShapefile(URL url) Read an ESRI shapefile from a URL and extract all features into an in-memory structure.EsriShapefile(URL url, double coarseness) Read an ESRI shapefile from a URL and extract all features into an in-memory structure, with control of time versus resolution.EsriShapefile(URL url, Rectangle2D bBox) Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.EsriShapefile(URL url, Rectangle2D bBox, double coarseness) Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box. -
Method Summary
Modifier and TypeMethodDescriptionGet bounding box, according to file (not computed from features)Get the Dbase file objectGet a List of all the GisFeatures in the shapefile.getFeatures(Rectangle2D bBox) Get a List of all the features in the shapefile that intersect the specified bounding box.intGet the feature typeintGet the projection fileintReturns shapefile format version (currently 1000)static voidThe main method.intdoubleReturn percent of file read, so far.
-
Field Details
-
SHAPEFILE_CODE
public static final int SHAPEFILE_CODEshapefile magic number- See Also:
-
NULL
public static final int NULLnull shape- See Also:
-
POINT
public static final int POINTpoint shape- See Also:
-
POLYLINE
public static final int POLYLINEpolyline shape- See Also:
-
POLYGON
public static final int POLYGONpolygon shape- See Also:
-
MULTIPOINT
public static final int MULTIPOINTmultipoint shape- See Also:
-
POINTZ
public static final int POINTZpoint with Z- See Also:
-
POLYLINEZ
public static final int POLYLINEZpolyline with z- See Also:
-
POLYGONZ
public static final int POLYGONZpolygon with z- See Also:
-
MULTIPOINTZ
public static final int MULTIPOINTZmultipoint with z- See Also:
-
POINTM
public static final int POINTMMeasured point- See Also:
-
POLYLINEM
public static final int POLYLINEMMeasured polyline- See Also:
-
POLYGONM
public static final int POLYGONMMeasured polygon- See Also:
-
MULTIPOINTM
public static final int MULTIPOINTMMeasured multi point- See Also:
-
MULTIPATCH
public static final int MULTIPATCHmuti patch- See Also:
-
-
Constructor Details
-
EsriShapefile
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
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
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
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 shapefilecoarseness- to tradeoff plot quality versus speed.- Throws:
IOException- Signals that an I/O exception has occurred.
-
EsriShapefile
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 shapefilebBox- bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is usedcoarseness- to tradeoff plot quality versus speed.- Throws:
IOException- Signals that an I/O exception has occurred.
-
EsriShapefile
Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.- Parameters:
filename- name of ESRI shapefilebBox- bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is usedcoarseness- to tradeoff plot quality versus speed.- Throws:
IOException- Signals that an I/O exception has occurred.
-
EsriShapefile
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 shapefilebBox- 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
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 shapefilebBox- 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
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 readbBox- bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is usedcoarseness- the coarseness- Throws:
IOException- Signals that an I/O exception has occurred.
-
-
Method Details
-
getDbFile
Get the Dbase file object- Returns:
- the DbaseFile object; may be null
-
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
Get bounding box, according to file (not computed from features)- Returns:
- bounding box for shapefilew, as stored in header.
-
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
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
The main method.- Parameters:
args- the arguments- Throws:
IOException- Signals that an I/O exception has occurred.
-