Repository navigation
Zarr v3 writing, sharding and bit shuffle; netCDF writing; RST; shapefiles from memory - #14
Merged
Merged
Conversation
Zarr: write v3 stores as GDAL does (FORMAT=ZARR_V3 creation option), with gzip or zstd (pure-Rust ruzstd encoder; zstd for v2 too). Read v3 sharding (nested, index at either end, CRC32C), transposition and v2 Fortran order, and Blosc bit shuffling. Arrays without georeferencing are no longer flipped. netCDF: a classic writer (CDF-1, CDF-2 with FORMAT=NC2 or when large, CDF-5 with FORMAT=NC5) laid out as GDAL writes rasters: CF lon/lat or x/y coordinates, a grid mapping with CF parameters for the common projections plus crs_wkt, spatial_ref and GeoTransform, nodata as _FillValue, unsigned types with _Unsigned. The reader now reads signed types flagged _Unsigned and their fill values. RST: an empty reference system in metres is read as GDAL's local CRS, and the GeoTIFF writer writes local CRSs as GDAL does. Shapefile and MapInfo MIF/MID are read from memory (zip archives of their files), WebAssembly included. RasterWriteOptions gains creation_options (CLI --co KEY=VALUE).
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 19 minutes. View limit details
opengeos is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
Comment |
giswqs
added a commit
that referenced
this pull request
Oct 14, 2026
Use the creation options #14 added: RASTER_TABLE names the tile table and TILE_FORMAT picks PNG or JPEG tiles, as in GDAL. The docs list netCDF writing and the formats read from bytes in WebAssembly.
This was referenced Oct 14, 2026
giswqs
added a commit
that referenced
this pull request
Oct 14, 2026
Use the creation options #14 added: RASTER_TABLE names the tile table and TILE_FORMAT picks PNG or JPEG tiles, as in GDAL. The docs list netCDF writing and the formats read from bytes in WebAssembly.
giswqs
added a commit
that referenced
this pull request
Oct 14, 2026
Use the creation options #14 added: RASTER_TABLE names the tile table and TILE_FORMAT picks PNG or JPEG tiles, as in GDAL. The docs list netCDF writing and the formats read from bytes in WebAssembly.
giswqs
added a commit
that referenced
this pull request
Oct 14, 2026
…eader (#19) * GeoPackage: R-tree indexes, raster tiles, own reader Write GeoPackages the way GDAL does, and read them with terrio's own SQLite reader instead of wbvector's: - An R-tree spatial index for every geometry column: the rtree virtual table, its node/rowid/parent shadow tables packed in one go (sort-tile-recursive, float bounds rounded outwards as SQLite does) and GDAL's triggers, plus gpkg_ogr_contents and gpkg_extensions. GDAL reports HasSpatialIndex, spatial filters match, and SQLite's integrity_check and rtreecheck pass. - Raster writing: Byte rasters as PNG (or JPEG) tile pyramids, one-band Int16, UInt16 and Float32 rasters as 2D gridded coverages (16-bit PNG or float TIFF tiles), GDAL's CUSTOM tiling, overview zoom levels, nodata and band count metadata. GDAL reads them back identically and validate_gpkg.py accepts them. - A reader of feature and attribute tables with GDAL's field types, feature ids and CRSs; files with both layers and rasters open as their layers and list the rasters as GPKG:file:table subdatasets. - GeoPackages read from and written to bytes, WebAssembly included. The SQLite writer now builds index b-trees of any size and writes triggers and virtual tables. Layers without a CRS use GDAL's undefined SRS (99999); layers without geometries are attribute tables. CRS identification no longer takes a datum's or prime meridian's EPSG code for the CRS's (a WKT GDAL wrote was identified as EPSG:8901). * Docs: GeoPackage rasters, bytes and benchmarks Formats, JavaScript and architecture pages list GeoPackage raster writing and reading from bytes; the GeoPackage benchmark rows are re-measured with terrio's own reader. * GeoPackage: RASTER_TABLE and TILE_FORMAT creation options Use the creation options #14 added: RASTER_TABLE names the tile table and TILE_FORMAT picks PNG or JPEG tiles, as in GDAL. The docs list netCDF writing and the formats read from bytes in WebAssembly. * CRS: identify WKT whose only codes are a datum's After #20, a WKT GDAL wrote into a GeoPackage, with EPSG codes on its datum and prime meridian only, got no code at all (the registry took 8901, the prime meridian's, which the new check rightly rejects). Match it again without its authorities, as GDAL does: EPSG:4326. * Docs: netCDF writing, GeoPackage in WebAssembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the raster gaps listed in #11 (Zarr, netCDF writing, RST) and reads Shapefile and MapInfo MIF/MID from memory (#12's open item), checked against GDAL 3.12.
Results against GDAL 3.12
scripts/raster_roundtrip.py(read = GDAL writes, terrio reads; write = terrio writes, GDAL reads back; pixels, type, geotransform, CRS, nodata compared):Zarr read variants added to the script: GDAL's Zarr v3, v3 with
CHUNK_MEMORY_LAYOUT=F(atransposecodec), v2 Fortran order, Blosc withBLOSC_SHUFFLE=BIT. Write variants: v2 none/zlib, v3 none/zstd/gzip. netCDF: GDAL's classic (FORMAT=NC) files are now read too; terrio writes CDF-1 and CDF-2.Sharding: GDAL 3.12 cannot read sharded arrays ("Unsupported codec: sharding_indexed"), so terrio's reader was checked against zarr-python 3.2 instead: 28 arrays (sharded with and without zstd, odd inner chunks, index at the start with big-endian gzip inner chunks, sharded and transposed, transposed, Blosc lz4/zstd bit shuffle; float32/int16/uint8/float64) all read identical to NumPy. zarr-python and xarray read terrio's v3 stores (zstd included); xarray and rioxarray read terrio's netCDF files with the same CRS and transform as GDAL's own files.
compare_with_gdal.py --pixelsover the test data: 60 files identical; the only difference is the one listed in #13 (kml_samples.kml, an empty layer's extent).What changed
drivers/zarr.rs): v3 writing as GDAL writes it (--co FORMAT=ZARR_V3: group and arrayzarr.json,dimension_names,/chunk keys, X/Y coordinate arrays,_CRS); zstd for v2 and v3 and gzip for v3 (pure-Rustruzstdencoder, so it works in WebAssembly). Reading: v3sharding_indexed(nested, index at either end, CRC32C index),transposeand v2order: "F", Blosc bit shuffle. Arrays without georeferencing are no longer flipped upside down.drivers/netcdf_write.rs, new): classic CDF-1 (default), CDF-2 (FORMAT=NC2, or automatically above 2 GiB), CDF-5 (FORMAT=NC5). Laid out as GDAL lays it out:Band1(lat, lon)or(y, x)(several bands:band_data(band, y, x)so GDAL reads one multi-band dataset), rows south to north, pixel-centre coordinate variables with CF standard names and units, a grid mapping variable named as GDAL names it with CF parameters (latitude_longitude, transverse_mercator incl. UTM, mercator incl. Web Mercator, LCC 1SP/2SP, Albers, LAEA, polar stereographic, sinusoidal),crs_wkt,spatial_ref,GeoTransform,_FillValue,_Unsigned/valid_rangefor bytes,Conventions = "CF-1.5". UInt16 is a short with_Unsigned = "true"(GDAL reads it as UInt16); UInt32 and 64-bit integers are stored as doubles, as GDAL stores them, because this GDAL build reads neither unsigned ints nor CDF-5._Unsignedfailed with a type mismatch (GDAL's classic Byte files); their fill values keep their bits (-1s→ 65535)..shp+.dbf/.prj/.cpg) and MapInfo MIF/MID are read from zip archives in memory, in WebAssembly too (shapefile::parse,vector::read_parts). The JS test that expected an error now readsne_countries.zip(177 features, as GDAL).RasterWriteOptions::creation_options(GDAL-styleKEY/VALUE),terrio convert --co KEY=VALUEand the same on the raster processing commands;netCDFis now writable in the driver list.Known differences
fill_value: null, which is invalid in v3 (GDAL warns, zarr-python refuses to open it).Still missing
.refprojections other than geographic (GDAL reads Mercator etc.).Shared files touched
crates/terrio/src/dataset.rs:RasterWriteOptions::creation_options; options passed to the driver writers.crates/terrio/src/formats.rs: netCDF writable.crates/terrio/src/memory.rs: Shapefile/MapInfo from zip archives in the in-memory codecs; test.crates/terrio/src/drivers/mod.rs: writer signature takes the write options; netCDF writer.crates/terrio/src/drivers/vector/mod.rs,shapefile.rs: byte-based shapefile parsing,read_parts.crates/terrio/src/drivers/gtiff_write.rs: local CRS GeoKeys.convert.rs,rasterout.rs,python/src/raster.rs: option struct literals,--co.scripts/raster_roundtrip.py,js/README.md,js/tests/node.test.mjs,ROADMAP.md.Checks
cargo fmt,cargo clippy --workspace --all-targets -D warnings,cargo test --workspace(with and withoutTERRIO_TEST_DATA),cargo build -p terrio --target wasm32-unknown-unknown, the npm package's node tests on a wasm-pack build (16/16 with test data), the Python tests (83 passed), andpre-commit run --all-filesall pass.