Assertions for comparing geometry in tests, like geopandas.testing.
Both functions raise ExUnit.AssertionError (part of Elixir core, so there is no compile
time dependency on the test framework) with a readable report of the first differing rows,
and return :ok otherwise.
import GeoFrame.Testing
assert_geoseries_equal(result, expected)
assert_geodataframe_equal(result, expected, check_less_precise: true)How geometries are compared
GeoPandas compares with topological geom_equals by default and with a tolerance when
check_less_precise is set; GeoFrame makes the same choice:
- default -
GeoFrame.GeoSeries.geom_equals/2: the same point set, so vertex order, start vertex and ring orientation do not matter; check_less_precise: true-GeoFrame.GeoSeries.geom_equals_exact/3with a tolerance of1.0e-6, which does care about vertex order;normalize: true- always the topological comparison, which is already independent of vertex order (GeoFrame has nonormalizeoperation), so it wins overcheck_less_precise.
Two null rows are equal; a null row never equals a geometry. Two rows that both hold the same empty geometry are equal.
Options
:check_crs- also require equal CRS (defaulttrue).:check_less_precise- tolerance comparison (defaultfalse). For frames it also lets float attribute values differ by1.0e-6.:check_geom_type- also require equal geometry types per row (defaultfalse).:normalize- see above (defaultfalse).:check_dtype- frames only: require equal attribute dtypes (defaulttrue).
Summary
Functions
Asserts two GeoFrame.GeoDataFrame are equal: same attribute and geometry column names in
order, equal attributes, equal geometries. Secondary geometry columns
(GeoFrame.GeoDataFrame.put_geometry/3) are compared like the active one, each with its own
CRS. See the module documentation for options.
Asserts two GeoFrame.GeoSeries are equal. See the module documentation for options.
Functions
@spec assert_geodataframe_equal( GeoFrame.GeoDataFrame.t(), GeoFrame.GeoDataFrame.t(), keyword() ) :: :ok
Asserts two GeoFrame.GeoDataFrame are equal: same attribute and geometry column names in
order, equal attributes, equal geometries. Secondary geometry columns
(GeoFrame.GeoDataFrame.put_geometry/3) are compared like the active one, each with its own
CRS. See the module documentation for options.
Examples
iex> geometry = GeoFrame.GeoSeries.from_wkt!(["POINT (1 1)"])
iex> gdf = GeoFrame.GeoDataFrame.new(Explorer.DataFrame.new(id: [1]), geometry)
iex> GeoFrame.Testing.assert_geodataframe_equal(gdf, gdf)
:ok
@spec assert_geoseries_equal( GeoFrame.GeoSeries.t(), GeoFrame.GeoSeries.t(), keyword() ) :: :ok
Asserts two GeoFrame.GeoSeries are equal. See the module documentation for options.
Examples
iex> a = GeoFrame.GeoSeries.from_wkt!(["POINT (1 1)", nil])
iex> b = GeoFrame.GeoSeries.from_wkt!(["POINT (1 1)", nil])
iex> GeoFrame.Testing.assert_geoseries_equal(a, b)
:ok