Format Support
This page provides an overview of the geospatial data formats supported by GeoTools and how format support is implemented within the library. GeoTools supports a wide range of vector and raster formats with a focus on standardized, open specifications.
For information about specific data stores, see Data Stores.
Format Support Architecture
GeoTools implements a consistent architecture for format support with format-specific implementations that enable a unified API while accommodating the unique characteristics of each format.
Class Hierarchy
The format support is implemented through a hierarchy of classes that provide consistent interfaces for the different formats:
Vector Data Formats
Shapefile
Shapefile is a widely used vector data format developed by Esri. GeoTools provides comprehensive support for reading and writing Shapefiles.
Key Components
ShapefileDataStore: Main class providing access to Shapefile dataShapefileDataStoreFactory: Creates Shapefile data storesShapefileFeatureSource: Provides access to features from ShapefilesDbaseFileWriter: Writes attributes to DBF files
Features & Capabilities
- Support for all geometry types (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon)
- Reading and writing attributes via DBF files
- Optional spatial indexing for efficient queries (
.qixfiles) - Customizable character encoding support for international text
- Memory mapping option for improved performance
- Support for
.prjfiles for coordinate reference systems - Support for
.shxindex files
Limitations
- 2GB file size limit for individual files
- Attribute names limited to 10 characters in DBF format
- Single geometry type per file
- Limited data types (no direct support for UUID, XML, arrays, etc.)
GeoPackage Vector
GeoPackage is an open, standards-based, platform-independent, portable, self-describing, compact format for transferring geospatial information. It's based on SQLite and supports both vector and raster data.
Key Components
GeoPackage: Main class for working with GeoPackage filesGeoPkgDataStore: Provides access to GeoPackage feature dataGeoPkgDialect: SQL dialect for GeoPackage SQLite databaseGeoPkgDataStoreFactory: Creates GeoPackage data stores
Features & Capabilities
- SQLite-based storage for vector data
- Spatial indexing using SQLite's R-tree implementation
- Advanced data types including dates, times, enumerations
- SQL-based filtering and querying
- Support for GeoPackage extensions
- Ability to store both vector and raster data in a single file
- Metadata tables for describing contents
GeoPackage Structure
Raster Data Formats
GeoTIFF
GeoTIFF is a public domain metadata standard which allows georeferencing information to be embedded within a TIFF file. It is the most widely used format for raster data in GIS applications.
Key Components
GeoTiffReader: Reads GeoTIFF filesGeoTiffWriter: Writes GeoTIFF filesGeoTiffFormat: Format description and accessGeoTiffMetadata2CRSAdapter: Converts GeoTIFF metadata to CRS
Features & Capabilities
- Reading and writing georeferenced raster data
- Support for embedded coordinate reference systems
- Support for ground control points (GCPs)
- Overview (pyramid) support for efficient rendering
- Compression options for reducing file size
- Support for various pixel types and bands
- Transparent handling of world files and projection files
- Support for GDAL metadata tags and PAM datasets
Reading Process
GeoPackage Raster
GeoPackage also supports raster data through its tile-based storage model, which is designed for efficient access and web mapping.
Key Components
GeoPackageReader: Reads raster data from GeoPackage filesTileEntryandTileMatrix: Represent tile structureTileReader: Reads individual tiles
Features & Capabilities
- Tile-based storage of raster data
- Multiple zoom levels (pyramids) for efficient display at different scales
- Compact storage format
- Compatibility with web mapping frameworks
- Unified format for both vector and raster data
Working with Different Formats
Reading Vector Data
Vector data reading follows a consistent pattern across formats:
// Shapefile
File file = new File("data.shp");
ShapefileDataStore store = new ShapefileDataStore(file.toURI().toURL());
SimpleFeatureSource source = store.getFeatureSource();
SimpleFeatureCollection features = source.getFeatures();
// GeoPackage
Map<String, Object> params = new HashMap<>();
params.put("dbtype", "geopkg");
params.put("database", "data.gpkg");
DataStore store = DataStoreFinder.getDataStore(params);
String typeName = store.getTypeNames()[0];
SimpleFeatureSource source = store.getFeatureSource(typeName);
SimpleFeatureCollection features = source.getFeatures();Reading Raster Data
Similarly, raster data reading follows a consistent pattern:
// GeoTIFF
File file = new File("data.tif");
GeoTiffReader reader = new GeoTiffReader(file);
GridCoverage2D coverage = reader.read(null);
// GeoPackage Raster
File file = new File("data.gpkg");
GeoPackageReader reader = new GeoPackageReader(file, null);
String coverageName = reader.getGridCoverageNames()[0];
GridCoverage2D coverage = reader.read(coverageName, null);Format-Specific Parameters and Options
Shapefile Parameters
| Parameter | Type | Description |
|---|---|---|
url | URL | URL to the .shp file |
namespace | URI | Namespace URI for the feature type |
memory mapped buffer | Boolean | Enable/disable memory mapping |
cache and reuse memory maps | Boolean | Cache and reuse memory maps |
create spatial index | Boolean | Automatically create spatial index |
charset | Charset | Character encoding for DBF file |
timezone | TimeZone | Timezone used for date fields |
enable spatial index | Boolean | Use spatial index if available |
GeoPackage Parameters
| Parameter | Type | Description |
|---|---|---|
dbtype | String | Must be "geopkg" |
database | File | The GeoPackage file |
user | String | Database user |
passwd | String | Database password |
namespace | URI | Namespace URI for the feature type |
Batch insert size | Integer | Number of features to insert in a single batch |
GeoTIFF Parameters
| Parameter | Type | Description |
|---|---|---|
INPUT_TRANSPARENT_COLOR | Color | Color to be made transparent |
SUGGESTED_TILE_SIZE | String | Suggested tile size |
WRITE_TIFF_TAGS | Boolean | Whether to write GeoTIFF tags |
SOURCE_URL | URL | Source URL for the GeoTIFF |
COMPRESSION | String | Compression type (e.g., "LZW") |
COMPRESSION_QUALITY | Float | Quality level for compression |
Date/Time Handling in Various Formats
Each format has its own approach to handling date and time values:
Shapefile
- Uses fixed-width DBF format
- Dates are stored in YY-MM-DD format
- No native support for time or timestamp
- Timezone handling through the
timezoneparameter
// Configuring timezone for Shapefile
ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
Map<String, Serializable> params = new HashMap<>();
params.put("url", file.toURI().toURL());
params.put("timezone", TimeZone.getTimeZone("UTC"));
DataStore dataStore = factory.createDataStore(params);GeoPackage
- Uses SQLite date/time types
- Follows ISO-8601 format:
YYYY-MM-DDTHH:MM:SS.SSSZ - Full support for date, time, and timestamp
- Timezone handling baked into the ISO format
// Date formatting in GeoPackage
static final String DATE_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";Format Support Extensions
The GeoTools format support architecture is designed to be extensible. To add support for a new format:
Vector Format Extension
- Implement
DataStoreFactorySpifor format discovery - Extend
ContentDataStorefor format-specific data store implementation - Implement appropriate
FeatureSourceandFeatureReaderinterfaces
Raster Format Extension
- Extend
AbstractGridFormatfor format description and capabilities - Extend
AbstractGridCoverage2DReaderfor reading raster data - (Optional) Extend
AbstractGridCoverageWriterfor writing raster data