Skip to content

GeoFrame 0.2.0

Choose a tag to compare

@roger120981 roger120981 released this 26 Nov 23:07
· 50 commits to main since this release

Like 0.1.x, it is distributed through the v0.2.0 git tag and GitHub release, not through Hex
yet. The release attaches precompiled NIFs for nine targets; they are used once GeoFrame is on
Hex, where no Rust toolchain is needed. A git dependency builds the NIF from source (a stable
Rust toolchain is required).

This release adds batched reads (stream_file/2), grouped aggregation (group_by, summarise,
group_map) and precompiled NIFs, closes a set of GeoPandas parity gaps, and makes a few
behaviours stricter or closer to GDAL and GEOS. Five changes need a look in existing code; see
Breaking changes.

Breaking changes

  • set_crs/3 no longer overrides an existing CRS. Setting a different CRS on a series or
    frame that already has one raises ArgumentError, as in GeoPandas; the same CRS is a no-op, a
    missing CRS is set, and nil still clears. Migration: to relabel on purpose, pass
    allow_override: true (set_crs(gdf, "EPSG:3857", allow_override: true)); to change
    coordinates, use to_crs/2.
  • read_file(bbox:), stream_file(bbox:) and FlatGeobuf reads use GDAL's semantics: a
    feature is kept when its geometry intersects the box, not when its envelope does.
    A diagonal
    LINESTRING (0 0, 10 10) is dropped by the box 6 0 9 3. Shapefile, GeoPackage and GeoJSON
    gain the option with the same rule; GeoParquet keeps its covering-box semantics, as GeoPandas.
    Migration: results can lose rows that only the envelope touched; if you relied on the envelope
    test, filter with GeoSeries.total_bounds or an envelope intersection after reading.
  • write_feather/3 and to_arrow write 65 536-row record batches by default, as pyarrow
    and GeoPandas to_feather, instead of one record batch per file. Migration: pass
    record_batch_size: (a positive integer) to choose another size; a file with a single batch
    needs a size at least as large as the frame. Existing files read the same.
  • On a grouped frame, head, tail, slice and sample act per group (Explorer's grouped
    semantics, pandas groupby.head), keeping the original row order, with the geometry aligned.
    Migration: call ungroup/2 first to get the old global behaviour. Ungrouped frames are
    unchanged.
  • summarise with :n_distinct no longer counts nulls (pandas nunique). Migration: the
    previous value is the new one plus one for each group whose column holds a null.

Added

  • Precompiled NIFs through rustler_precompiled: the release workflow builds
    aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl,
    x86_64-apple-darwin, x86_64-pc-windows-gnu, x86_64-pc-windows-msvc,
    x86_64-unknown-freebsd, x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl (NIF
    version 2.15) on each v* tag and attaches them to the release. A Hex package verifies the
    download against a shipped checksum file; GEOFRAME_BUILD=true forces a source build.
  • A git or path dependency builds the NIF from source automatically (no GEOFRAME_BUILD
    needed), because a package without the checksum file cannot download a precompiled NIF; Rustler
    is then fetched as a dependency.
  • GeoFrame.stream_file/2: a lazy Stream of GeoDataFrame batches for GeoParquet,
    FlatGeobuf, Feather / Arrow IPC, Shapefile (.shp, .zip), GeoPackage and GeoJSON, with
    batch_size: (default 65 536), bbox:, columns: and format options. Concatenating the
    batches equals read_file/2; early halts release the reader. On 500 000 points with
    10 000-row batches, peak memory is 155 to 196 MB against 235 to 308 MB for a whole read
    (GeoJSON 72 MB: 175 MB against 637 MB).
  • read_file(path, rows: n | first..last) for every format, as GeoPandas rows=: the first n
    rows or an inclusive range, applied after bbox: and skipping rows cheaply where the format
    allows (for example rows: 10 on a GeoParquet file: 1 ms against 239 ms).
  • read_file(bbox:) for Shapefile, GeoPackage and GeoJSON, and record_batch_size: on
    write_feather / to_arrow.
  • GeoDataFrame.group_by/2, ungroup/2, groups/1 and summarise/3: attribute aggregations
    (:sum :mean :median :min :max :count :first :last :n_distinct) and geometry aggregations
    (:union_all :intersection_all :collect :envelope :convex_hull :centroid :first :last :count)
    computed in one NIF call, 8 to 14 times faster than a per-group loop at 100 000 rows and 1 000
    groups. summarise(group_by(gdf, by), []) equals dissolve(gdf, by: by).
  • GeoDataFrame.group_map/4 (pandas groupby(by).apply(fun)) and the top-level GeoFrame
    delegates group_by/2, summarise/3, ungroup/2 and group_map/4.
  • sindex_query/4 accepts a list of WKT strings or a single WKT string as input (a single
    geometry returns the ascending tree indices, as GeoPandas) and the sort: option;
    get_geometry/2 takes a per-row index list or series.
  • GeoDataFrame.from_features/2 keeps the property column order for ordered input (keyword
    lists, {key, value} pairs, Jason.OrderedObject); to_geo_dict/2 with GeoPandas' na:,
    show_bbox: and drop_id:; GeoDataFrame.to_wkb/2 (hex:, srid:), to_wkt/2 and
    rename_geometry/2.
  • dissolve accepts as_index: false and observed: false (unobserved categories become empty
    groups); as_index: true and level: raise because GeoFrame has no index. The default stays
    observed: true.
  • frechet_distance works on every geometry type, as GEOS, not only on LineStrings.
  • buffer/3 takes a per-row distance (a list with nil, or a series) and single_sided:; lines
    and points match GEOS, polygons return the band, which matches GEOS only for polygons small
    relative to the distance (documented in docs/parity.md).
  • The vertex constructors (line_strings_from_vertices, polygons_from_rings, ...) accept
    {x, y, z} and [x, y, z] vertices as Shapely 2.2.
  • GeoFrame.Kino.deck/2: click popups (popup: true | [columns]) and several layers
    (deck([gdf1, {gdf2, name: ..., color: ...}], opts)) with a layer-control panel; a single
    frame sends the same payload as before.
  • Shapefiles and GeoPackages written with one of the 1 217 supplementary EPSG codes keep their
    definition: a WKT1 .prj is written and the GeoPackage definition is filled, instead of a
    warning and undefined. 119 codes have no WKT1 in PROJ (Krovak Modified 5515 and 5516, 3D,
    geocentric and compound CRSs) and behave as before.

Changed

  • A missing Z reads as 0, as GDAL: a two-value position in a 3D GeoJSON geometry, and a row
    without Z written to a Shapefile or FlatGeobuf layer with Z (a stored NaN Z stays NaN).
  • is_valid is false and make_valid repairs a polygon whose interior is disconnected, as GEOS
    (Interior is disconnected): a hole touching the shell at two or more points, or a chain or
    cycle of holes cutting the interior. A single touch stays valid. null_out_invalid nulls
    these polygons.
  • is_valid_reason follows GEOS's check order and wording (Self-intersection[2 2],
    Hole lies outside shell[...], Too few points in geometry component[...], and so on).
  • polygonize with node: true and lines crossing polygons matches GEOS: no extra small face,
    and the crossing point is a vertex of the merged ring. On a 2 000-case fuzz, polygonize
    mismatches fell from 46 to 2 (and 54 to 3 on a second seed), with no case worse; build_area
    improves too (495 to 472 and 474 to 450) but still differs from GEOS where GEOS drops collinear
    vertices.

Documentation

  • docs/parity.md and the README follow every change above. The reference suite is
    now 19 118 cases: 18 379 agree with GeoPandas / Shapely and 739 are documented deviations,
    none unexplained (0.1.1: 18 134 agree and 730 documented of 18 864).

Internal

  • The release workflow uploads artifacts on pull requests that change it; the .cargo config
    links musl cdylibs without static CRT.

Full changelog: CHANGELOG.md