Class ogr
- All Implemented Interfaces:
ogrConstants
In particular, it provides ogr.RegisterAll() and ogr.Open() methods.
-
Field Summary
Fields inherited from interface org.gdal.ogr.ogrConstants
ALTER__FLAG, ALTER_ALL_FLAG, ALTER_ALTERNATIVE_NAME_FLAG, ALTER_COMMENT_FLAG, ALTER_DEFAULT_FLAG, ALTER_DOMAIN_FLAG, ALTER_GEOM_FIELD_DEFN_ALL_FLAG, ALTER_GEOM_FIELD_DEFN_NAME_FLAG, ALTER_GEOM_FIELD_DEFN_NULLABLE_FLAG, ALTER_GEOM_FIELD_DEFN_SRS_COORD_EPOCH_FLAG, ALTER_GEOM_FIELD_DEFN_SRS_FLAG, ALTER_GEOM_FIELD_DEFN_TYPE_FLAG, ALTER_NAME_FLAG, ALTER_NULLABLE_FLAG, ALTER_TYPE_FLAG, ALTER_UNIQUE_FLAG, ALTER_WIDTH_PRECISION_FLAG, F_VAL_ALL, F_VAL_ALLOW_NULL_WHEN_DEFAULT, F_VAL_GEOM_TYPE, F_VAL_NULL, F_VAL_WIDTH, GGT_COUNT_NOT_NEEDED, GGT_GEOMCOLLECTIONZ_TINZ, GGT_STOP_IF_MIXED, NullFID, ODrCCreateDataSource, ODrCDeleteDataSource, ODsCAddFieldDomain, ODsCCreateGeomFieldAfterCreateLayer, ODsCCreateLayer, ODsCCurveGeometries, ODsCDeleteFieldDomain, ODsCDeleteLayer, ODsCEmulatedTransactions, ODsCMeasuredGeometries, ODsCRandomLayerRead, ODsCRandomLayerWrite, ODsCTransactions, ODsCUpdateFieldDomain, ODsCZGeometries, OFDMP_DEFAULT_VALUE, OFDMP_GEOMETRY_WEIGHTED, OFDMP_SUM, OFDSP_DEFAULT_VALUE, OFDSP_DUPLICATE, OFDSP_GEOMETRY_RATIO, OFDT_CODED, OFDT_GLOB, OFDT_RANGE, OFSTBoolean, OFSTFloat32, OFSTInt16, OFSTJSON, OFSTNone, OFSTUUID, OFTBinary, OFTDate, OFTDateTime, OFTInteger, OFTInteger64, OFTInteger64List, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTStringList, OFTTime, OFTWideString, OFTWideStringList, OGRERR_CORRUPT_DATA, OGRERR_FAILURE, OGRERR_INVALID_HANDLE, OGRERR_NON_EXISTING_FEATURE, OGRERR_NONE, OGRERR_NOT_ENOUGH_DATA, OGRERR_NOT_ENOUGH_MEMORY, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, OGRERR_UNSUPPORTED_OPERATION, OGRERR_UNSUPPORTED_SRS, OJLeft, OJRight, OJUndefined, OLCAlterFieldDefn, OLCAlterGeomFieldDefn, OLCCreateField, OLCCreateGeomField, OLCCurveGeometries, OLCDeleteFeature, OLCDeleteField, OLCFastFeatureCount, OLCFastGetArrowStream, OLCFastGetExtent, OLCFastSetNextByIndex, OLCFastSpatialFilter, OLCIgnoreFields, OLCMeasuredGeometries, OLCRandomRead, OLCRandomWrite, OLCRename, OLCReorderFields, OLCSequentialWrite, OLCStringsAsUTF8, OLCTransactions, OLCUpdateFeature, OLCUpsertFeature, OLCZGeometries, OLMD_FID64, wkb25Bit, wkb25DBit, wkbCircularString, wkbCircularStringM, wkbCircularStringZ, wkbCircularStringZM, wkbCompoundCurve, wkbCompoundCurveM, wkbCompoundCurveZ, wkbCompoundCurveZM, wkbCurve, wkbCurveM, wkbCurvePolygon, wkbCurvePolygonM, wkbCurvePolygonZ, wkbCurvePolygonZM, wkbCurveZ, wkbCurveZM, wkbGeometryCollection, wkbGeometryCollection25D, wkbGeometryCollectionM, wkbGeometryCollectionZM, wkbLinearRing, wkbLineString, wkbLineString25D, wkbLineStringM, wkbLineStringZM, wkbMultiCurve, wkbMultiCurveM, wkbMultiCurveZ, wkbMultiCurveZM, wkbMultiLineString, wkbMultiLineString25D, wkbMultiLineStringM, wkbMultiLineStringZM, wkbMultiPoint, wkbMultiPoint25D, wkbMultiPointM, wkbMultiPointZM, wkbMultiPolygon, wkbMultiPolygon25D, wkbMultiPolygonM, wkbMultiPolygonZM, wkbMultiSurface, wkbMultiSurfaceM, wkbMultiSurfaceZ, wkbMultiSurfaceZM, wkbNDR, wkbNone, wkbPoint, wkbPoint25D, wkbPointM, wkbPointZM, wkbPolygon, wkbPolygon25D, wkbPolygonM, wkbPolygonZM, wkbPolyhedralSurface, wkbPolyhedralSurfaceM, wkbPolyhedralSurfaceZ, wkbPolyhedralSurfaceZM, wkbSurface, wkbSurfaceM, wkbSurfaceZ, wkbSurfaceZM, wkbTIN, wkbTINM, wkbTINZ, wkbTINZM, wkbTriangle, wkbTriangleM, wkbTriangleZ, wkbTriangleZM, wkbUnknown, wkbXDR
-
Method Summary
Modifier and TypeMethodDescriptionstatic Geometry
ApproximateArcAngles
(double dfCenterX, double dfCenterY, double dfZ, double dfPrimaryRadius, double dfSecondaryRadius, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees) Stroke arc to linestring.static Geometry
BuildPolygonFromEdges
(Geometry hLineCollection) static Geometry
BuildPolygonFromEdges
(Geometry hLineCollection, int bBestEffort) Build a ring from a bunch of arcs.static Geometry
BuildPolygonFromEdges
(Geometry hLineCollection, int bBestEffort, int bAutoClose) Build a ring from a bunch of arcs.static Geometry
BuildPolygonFromEdges
(Geometry lineCollection, int bBestEffort, int bAutoClose, double dfTolerance) Build a ring from a bunch of arcs.static Geometry
CreateGeometryFromEsriJson
(String input_string) static Geometry
Create a new Geometry from a GML string.static Geometry
CreateGeometryFromJson
(String json) Create a new Geometry from a GeoJSON string.static Geometry
CreateGeometryFromWkb
(byte[] wkb) Create a new Geometry from a well known binary (wkb) content.static Geometry
CreateGeometryFromWkb
(byte[] wkb, SpatialReference srs) Create a new Geometry from a well known binary (wkb) content.static Geometry
Create a new Geometry from a well known text (wkt) string.static Geometry
CreateGeometryFromWkt
(String wkt, SpatialReference srs) Create a new Geometry from a well known text (wkt) content.static FieldDomain
CreateGlobFieldDomain
(String name, String description, int type, int subtype, String glob) static FieldDomain
CreateRangeFieldDomain
(String name, String description, int type, int subtype, double min, boolean minIsInclusive, double max, double maxIsInclusive) static void
Use return code instead of exceptions.static Geometry
static Geometry
static Geometry
ForceToLineString
(Geometry geom_in) static Geometry
Convert to multilinestring.static Geometry
ForceToMultiPoint
(Geometry geom) Convert to multipoint.static Geometry
ForceToMultiPolygon
(Geometry geom) Convert to multipolygon.static Geometry
ForceToPolygon
(Geometry geom) Convert to polygon.static String[]
GeneralCmdLineProcessor
(String[] args) General utility option processing.static String[]
GeneralCmdLineProcessor
(String[] args, int options) General utility option processing.static Vector
General utility option processing.static Vector
GeneralCmdLineProcessor
(Vector args, int options) General utility option processing.static String
GeometryTypeToName
(int eType) Fetch a human readable name corresponding to an OGRwkBGeometryType value.static Driver
GetDriver
(int iDriver) Fetch the indicated driver.static Driver
GetDriverByName
(String name) Fetch the indicated driver.static int
Fetch the number of registered drivers.static String
GetFieldSubTypeName
(int type) static String
GetFieldTypeName
(int type) Fetch human readable name for a field type.static int
static int
static int
static int
static DataSource
GetOpenDS
(int iDS) Return the iDS th datasource opened.static int
Return the number of opened datasources.static boolean
static int
GT_Flatten
(int eType) static int
GT_GetCollection
(int eType) static int
GT_GetCurve
(int eType) static int
GT_GetLinear
(int eType) static int
GT_HasM
(int eType) static int
GT_HasZ
(int eType) static int
GT_IsCurve
(int arg0) static int
GT_IsNonLinear
(int arg0) static int
GT_IsSubClassOf
(int eType, int eSuperType) static int
GT_IsSurface
(int arg0) static int
GT_SetM
(int eType) static int
GT_SetModifier
(int eType, int bSetZ) static int
GT_SetModifier
(int eType, int bSetZ, int bSetM) static int
GT_SetZ
(int eType) static DataSource
Open a file / data source with one of the registered drivers.static DataSource
Open a file / data source with one of the registered drivers.static DataSource
Open a file / data source with one of the registered drivers.static DataSource
OpenShared
(String filename) Open a file / data source with one of the registered drivers.static DataSource
OpenShared
(String filename, int update) Open a file / data source with one of the registered drivers.static void
Register all known configured OGR drivers.static int
SetGenerate_DB2_V72_BYTE_ORDER
(int bGenerate_DB2_V72_BYTE_ORDER) Special entry point to enable the hack for generating DB2 V7.2 style WKB.static void
SetNonLinearGeometriesEnabledFlag
(int bFlag) static void
Use exceptions instead of error return codes.
-
Method Details
-
UseExceptions
public static void UseExceptions()Use exceptions instead of error return codes.This is the default behavior : methods that in C/C++ return an OGRErr return code would throw a RuntimeException() in case the code it is different from ogr.OGRERR_NONE. By calling this method, you can get back to that original state if DontUseExceptions() was called in-between. This will only apply to the org.gdal.ogr.* package.
- Since:
- Java bindings 1.7.0
-
DontUseExceptions
public static void DontUseExceptions()Use return code instead of exceptions.By default, methods that in C/C++ return an OGRErr return code would throw a RuntimeException() in case the code it is different from ogr.OGRERR_NONE. By calling this method, you can prevent the exception to be thrown and get the original error code (ogr.OGRERR_* codes) This will only apply to the org.gdal.ogr.* package.
- Since:
- Java bindings 1.7.0
-
GetUseExceptions
public static boolean GetUseExceptions() -
GetGEOSVersionMajor
public static int GetGEOSVersionMajor() -
GetGEOSVersionMinor
public static int GetGEOSVersionMinor() -
GetGEOSVersionMicro
public static int GetGEOSVersionMicro() -
CreateGeometryFromWkb
Create a new Geometry from a well known binary (wkb) content.- Parameters:
wkb
- the wkb contentsrs
- the srs to assign to the geometry- Returns:
- the new geometry
-
CreateGeometryFromWkb
Create a new Geometry from a well known binary (wkb) content.- Parameters:
wkb
- the wkb content- Returns:
- the new geometry
- Since:
- Java bindings 1.7.0
-
CreateGeometryFromWkt
Create a new Geometry from a well known text (wkt) content.- Parameters:
wkt
- the wkt contentsrs
- the srs to assign to the geometry- Returns:
- the new geometry
-
CreateGeometryFromWkt
Create a new Geometry from a well known text (wkt) string.- Parameters:
wkt
- the wkt content- Returns:
- the new geometry
- Since:
- Java bindings 1.7.0
-
CreateGeometryFromGML
Create a new Geometry from a GML string.- Parameters:
gml
- the GML string- Returns:
- the new geometry
-
CreateGeometryFromJson
Create a new Geometry from a GeoJSON string.- Parameters:
json
- the GeoJSON string- Returns:
- the new geometry
-
CreateGeometryFromEsriJson
-
BuildPolygonFromEdges
public static Geometry BuildPolygonFromEdges(Geometry lineCollection, int bBestEffort, int bAutoClose, double dfTolerance) Build a ring from a bunch of arcs.- Parameters:
lineCollection
- geometry of type OGRGeometryCollection (or OGRMultiLineString) containing the line string geometries to be built into rings.bBestEffort
- not yet implemented???.bAutoClose
- indicates if the ring should be close when first and last points of the ring are the same.dfTolerance
- tolerance into which two arcs are considered close enough to be joined.- Returns:
- a polygon or null in case of failure
-
BuildPolygonFromEdges
public static Geometry BuildPolygonFromEdges(Geometry hLineCollection, int bBestEffort, int bAutoClose) Build a ring from a bunch of arcs.Same as below with dfTolerance == 0.
- Since:
- Java bindings 1.7.0
- See Also:
-
BuildPolygonFromEdges
Build a ring from a bunch of arcs.Same as below with bAutoClose == 0 and dfTolerance == 0.
- Since:
- Java bindings 1.7.0
- See Also:
-
BuildPolygonFromEdges
-
ApproximateArcAngles
public static Geometry ApproximateArcAngles(double dfCenterX, double dfCenterY, double dfZ, double dfPrimaryRadius, double dfSecondaryRadius, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees) Stroke arc to linestring.Stroke an arc of a circle to a linestring based on a center point, radius, start angle and end angle, all angles in degrees.
- Parameters:
dfCenterX
- center XdfCenterY
- center YdfZ
- center ZdfPrimaryRadius
- X radius of ellipse.dfSecondaryRadius
- Y radius of ellipse.dfRotation
- rotation of the ellipse clockwise.dfStartAngle
- angle to first point on arc (clockwise of X-positive)dfEndAngle
- angle to last point on arc (clockwise of X-positive)dfMaxAngleStepSizeDegrees
- the largest step in degrees along the arc.- Returns:
- LineString geometry representing an approximation of the arc.
- Since:
- Java bindings 1.7.0
-
ForceToPolygon
Convert to polygon.Tries to force the provided geometry to be a polygon. Currently this just effects a change on multipolygons.
Note: contrary to the C/C++ method, a new object is returned.
- Parameters:
geom
- the input geometry- Returns:
- new geometry.
- Since:
- Java bindings 1.8.0
-
ForceToLineString
-
ForceToMultiPolygon
Convert to multipolygon.Tries to force the provided geometry to be a multipolygon. Currently this just effects a change on polygons.
Note: contrary to the C/C++ method, a new object is returned.
- Parameters:
geom
- the input geometry- Returns:
- new geometry.
- Since:
- Java bindings 1.8.0
-
ForceToMultiPoint
Convert to multipoint.Tries to force the provided geometry to be a multipoint. Currently this just effects a change on points.
Note: contrary to the C/C++ method, a new object is returned.
- Parameters:
geom
- the input geometry- Returns:
- new geometry.
- Since:
- Java bindings 1.8.0
-
ForceToMultiLineString
Convert to multilinestring.Tries to force the provided geometry to be a multilinestring.
- linestrings are placed in a multilinestring.
- geometry collections will be converted to multilinestring if they only contain linestrings.
- polygons will be changed to a collection of linestrings (one per ring).
Note: contrary to the C/C++ method, a new object is returned.
- Parameters:
geom
- the input geometry- Returns:
- new geometry.
- Since:
- Java bindings 1.8.0
-
ForceTo
-
ForceTo
-
CreateRangeFieldDomain
public static FieldDomain CreateRangeFieldDomain(String name, String description, int type, int subtype, double min, boolean minIsInclusive, double max, double maxIsInclusive) -
CreateGlobFieldDomain
public static FieldDomain CreateGlobFieldDomain(String name, String description, int type, int subtype, String glob) -
GetDriverCount
public static int GetDriverCount()Fetch the number of registered drivers.- Returns:
- the drivers count.
-
GetOpenDSCount
public static int GetOpenDSCount()Return the number of opened datasources.- Returns:
- the number of opened datasources.
-
SetGenerate_DB2_V72_BYTE_ORDER
public static int SetGenerate_DB2_V72_BYTE_ORDER(int bGenerate_DB2_V72_BYTE_ORDER) Special entry point to enable the hack for generating DB2 V7.2 style WKB.DB2 seems to have placed (and require) an extra 0x30 or'ed with the byte order in WKB. This entry point is used to turn on or off the generation of such WKB.
-
RegisterAll
public static void RegisterAll()Register all known configured OGR drivers.This function will drive any of the following that are configured into OGR. Many others as well that haven't been updated in this documentation (see full list):
- Arc/Info Binary Coverage
- Arc/Info .E00 (ASCII) Coverage
- Atlas BNA
- Comma Separated Value (.csv)
- DODS/OPeNDAP
- ESRI Personal GeoDatabase
- ESRI ArcSDE
- ESRI Shapefile
- FMEObjects Gateway
- GeoJSON
- Geoconcept Export
- GeoRSS
- GML
- GMT
- GPX
- GRASS
- Informix DataBlade
- INTERLIS
- INGRES
- KML
- Mapinfo File
- Microstation DGN
- Memory
- MySQL
- Oracle Spatial
- ODBC
- OGDI Vectors
- PostgreSQL
- S-57 (ENC)
- SDTS
- SQLite
- UK .NTF
- U.S. Census TIGER/Line
- VRT - Virtual Datasource
- X-Plane/Flightgear aeronautical data
This function should generally be called once at the beginning of the application.
-
GeometryTypeToName
Fetch a human readable name corresponding to an OGRwkBGeometryType value.- Parameters:
eType
- the geometry type.- Returns:
- human readable string, or null on failure.
- Since:
- Java bindings 1.7.0
-
GetFieldTypeName
Fetch human readable name for a field type.- Parameters:
type
- the field type to get name for.- Returns:
- field type name
- Since:
- Java bindings 1.7.0
-
GetFieldSubTypeName
-
GT_Flatten
public static int GT_Flatten(int eType) -
GT_SetZ
public static int GT_SetZ(int eType) -
GT_SetM
public static int GT_SetM(int eType) -
GT_SetModifier
public static int GT_SetModifier(int eType, int bSetZ, int bSetM) -
GT_SetModifier
public static int GT_SetModifier(int eType, int bSetZ) -
GT_HasZ
public static int GT_HasZ(int eType) -
GT_HasM
public static int GT_HasM(int eType) -
GT_IsSubClassOf
public static int GT_IsSubClassOf(int eType, int eSuperType) -
GT_IsCurve
public static int GT_IsCurve(int arg0) -
GT_IsSurface
public static int GT_IsSurface(int arg0) -
GT_IsNonLinear
public static int GT_IsNonLinear(int arg0) -
GT_GetCollection
public static int GT_GetCollection(int eType) -
GT_GetCurve
public static int GT_GetCurve(int eType) -
GT_GetLinear
public static int GT_GetLinear(int eType) -
SetNonLinearGeometriesEnabledFlag
public static void SetNonLinearGeometriesEnabledFlag(int bFlag) -
GetNonLinearGeometriesEnabledFlag
public static int GetNonLinearGeometriesEnabledFlag() -
GetOpenDS
Return the iDS th datasource opened.- Parameters:
iDS
- the index of the dataset to return (between 0 and GetOpenDSCount() - 1)
-
Open
Open a file / data source with one of the registered drivers.This method loops through all the drivers registered with the driver manager trying each until one succeeds with the given data source.
If this method fails, gdal.GetLastErrorMsg() can be used to check if there is an error message explaining why.
The returned dataset should be properly closed with the DataSource.delete() method.
Example:
DataSource ds = ogr.Open( "polygon.shp" ); if( ds == null ) { return; } ... use the data source ... ds.delete();
- Parameters:
filename
- the name of the file, or data source to open.update
- 0 for read-only access (the default) or 1 for read-write access.- Returns:
- null on error or if the pass name is not supported by this driver, otherwise a pointer to an DataSource. This DataSource should be closed by calling the delete() method when it is no longer needed.
-
Open
Open a file / data source with one of the registered drivers.Same as below with update == 0
- Since:
- Java bindings 1.7.0
- See Also:
-
GetDriverByName
Fetch the indicated driver.- Parameters:
name
- the driver name- Returns:
- the driver, or null if no driver with that name is found
-
GetDriver
Fetch the indicated driver.- Parameters:
iDriver
- the driver index, from 0 to GetDriverCount()-1.- Returns:
- the driver, or null if iDriver is out of range.
-
GeneralCmdLineProcessor
General utility option processing.Same as below but with arguments as a Vector of strings
- Returns:
- updated argument list as a new Vector of strings
- Since:
- Java bindings 1.7.0
- See Also:
-
GeneralCmdLineProcessor
General utility option processing.Same as below but with arguments as a Vector of strings and options == 0
- Returns:
- updated argument list as a new Vector of strings
- Since:
- Java bindings 1.7.0
- See Also:
-
GeneralCmdLineProcessor
General utility option processing.This function is intended to provide a variety of generic commandline options for all OGR commandline utilities. It takes care of the following commandline options:
- --version: report version of OGR in use.
- --license: report OGR license info.
- --formats: report all format drivers configured.
- --format [format]: report details of one format driver.
- --optfile filename: expand an option file into the argument list.
- --config key value: set system configuration option.
- --debug [on/off/value]: set debug level.
- --mempreload dir: preload directory contents into /vsimem
- --help-general: report detailed help on general options.
The typical usage looks something like the following. Note that the formats should be registered so that the --formats and --format options will work properly.
public static void main( Strings[] args ) { ogr.RegisterAll(); args = ogr.GeneralCmdLineProcessor( args, 0 ); }
- Parameters:
args
- the argument list arrayoptions
- currently unused- Returns:
- updated argument list array.
- Since:
- Java bindings 1.7.0
-
GeneralCmdLineProcessor
General utility option processing.Same as below with options == 0
- Since:
- Java bindings 1.7.0
- See Also:
-
Open
Open a file / data source with one of the registered drivers.Same as below with boolean value being transformed to 1 (for true) or 0 (for false)
- Since:
- Java bindings 1.7.0
- See Also:
-