Skip to main content

Geospatial File Formats

A filename extension is not a data contract. A useful geospatial dataset couples geometry or cells with CRS, schema, identifiers, missing-value rules, encoding, and provenance. Format conversion can preserve some of these and silently weaken others.

Prerequisites​

Complete vector and raster data. You should be able to state which metadata is needed to interpret each layer.

Learning goals​

  • Compare GeoJSON, GeoPackage, GeoParquet, Shapefile, GeoTIFF, and ASCII grid trade-offs.
  • Distinguish geometry encodings such as WKT and WKB from feature containers.
  • Validate CRS, schema, geometry types, missing values, and counts after round trips.
  • Avoid assuming that extension, driver defaults, or successful reads prove semantic equivalence.

Choose by contract and workflow​

FormatUseful forImportant boundary
GeoJSON (RFC 7946)small web-facing feature collectionsWGS 84 longitude-latitude; text size and numeric precision matter
GeoPackageportable SQLite container with vector tables, CRS metadata, and optional indexeslayer and geometry-column rules; a file can hold several tables
GeoParquetcolumnar analytics and larger feature tablesreader/writer specification version, geometry encoding, CRS metadata, and row-group behavior
Shapefilelegacy exchangemulti-file dataset, constrained field names/types, weak modern schema support
GeoTIFFgeoreferenced raster bandstransform, CRS, band metadata, masks, tiling, compression, and overview choices
ASCII gridtransparent tiny teaching gridslimited metadata; CRS commonly travels in a sidecar file

WKT and WKB encode a geometry. They do not by themselves carry a feature's attributes, stable identifier, provenance, or necessarily its CRS. A CSV column of WKT is therefore not automatically a self-describing geospatial dataset.

Our GeoJSON fixtures use a project-owned foreign metadata member to make the teaching contract visible. RFC 7946 fixes coordinate semantics to WGS 84 longitude, latitude; production writers and readers should be tested against the exact standard and driver settings they use. Do not add a deprecated GeoJSON crs member and assume every reader will honor it.

Worked example​

import json
from pathlib import Path

import geopandas as gpd
import shapely

path = Path("tests/fixtures/geospatial-data-science/places.geojson")
document = json.loads(path.read_text(encoding="utf-8"))
places = gpd.GeoDataFrame.from_features(
document["features"],
crs=document["metadata"]["crs"],
)
geometry = places.geometry.iloc[0]
missing_kind = int(places["kind"].isna().sum())
wkb = shapely.to_wkb(geometry)
print(f"features={len(places)} missing_kind={missing_kind} geometry={geometry.geom_type}")
print(f"wkt={geometry.wkt} wkb_bytes={len(wkb)} crs={places.crs.to_string()}")

Expected output:

features=5 missing_kind=1 geometry=Point
wkt=POINT (13.39 52.52) wkb_bytes=21 crs=OGC:CRS84

The example constructs the frame from local content so the verifier has no driver or network dependency. In an application, geopandas.read_file and GeoDataFrame.to_file use a GDAL-backed engine; inspect its supported drivers and pass an explicit driver where inference would be ambiguous.

Round-trip verification​

Before and after a format conversion, compare at least:

  1. feature and null counts;
  2. stable identifiers and attribute types;
  3. CRS equivalence, axis convention, and units;
  4. geometry type, dimensionality, validity, emptiness, and bounds;
  5. precision or tolerance appropriate to the source measurement;
  6. layer names, band descriptions, NoData/masks, and time metadata where applicable;
  7. source hash, tool versions, options, and rejected records.

Topological equality is often more relevant than byte equality for geometry, but it can hide coordinate-order or precision changes. Conversely, byte equality is too strict across valid encodings. Choose checks from the intended semantics rather than from convenience.

Limitations and common mistakes​

  • Renaming a file does not convert its format.
  • Driver defaults can change CRS representation, field types, precision, index columns, or polygon orientation.
  • Missing CRS metadata is not permission to guess from plausible coordinate ranges.
  • A successful read can still coerce unsupported values or omit auxiliary metadata.
  • Cloud-optimized layouts and partitioning improve access patterns only when writers, object storage, and readers share the contract.

Practice​

Design a round-trip checklist for moving a multi-layer GeoPackage to an analytics format and a web format. Identify which output cannot preserve multiple layers in one file and how you will retain provenance.

Next steps​

Next, validate geometry validity and topology before measurement, overlay, or repair.

Primary sources​

Checked 2026-10-18: IETF, RFC 7946 GeoJSON; GDAL, GeoJSON driver and GeoPackage driver; OGC GeoParquet, format specification; GeoPandas, reading and writing files.