def test_rescale_polygon(): """Take a polygons set and rescale/resample""" pol = Polygons(POLSET4) oldpol = pol.copy() oldpol.name = "ORIG" pol.rescale(100) pol.hlen() pol2 = Polygons(POLSET4) pol2.rescale(100, kind="slinear") pol2.name = "slinear" pol2.hlen() arr1 = pol.dataframe[pol.dhname].values arr2 = pol2.dataframe[pol2.dhname].values logger.info( "avg, min, max: POL simple %s %s %s vs slinear %s %s %s", arr1.mean(), arr1.min(), arr1.max(), arr2.mean(), arr2.min(), arr2.max(), ) if XTGSHOW: pol.quickplot(others=[oldpol, pol2])
def test_polygon_tlen_hlen(testpath): """Test the tlen and hlen operations""" pol = Polygons(testpath / POLSET3) pol.tlen() pol.hlen() assert pol.dataframe[pol.hname].all() <= pol.dataframe[pol.tname].all() assert pol.dataframe[pol.hname].any() <= pol.dataframe[pol.tname].any() pol.filter_byid(0) hlen = pol.get_shapely_objects()[0].length # shapely length is 2D! assert (abs(pol.dataframe[pol.hname].iloc[-1] - hlen)) < 0.001 assert (abs(pol.dataframe[pol.dhname].iloc[0] - 1761.148)) < 0.01
def test_rescale_polygon(testpath): """Take a polygons set and rescale/resample""" pol = Polygons(testpath / POLSET4) oldpol = pol.copy() oldpol.name = "ORIG" oldpol.hlen() pol.rescale(100) pol.hlen() pol2 = Polygons(testpath / POLSET4) pol2.rescale(100, kind="slinear") pol2.name = "slinear" pol2.hlen() assert oldpol.dataframe.H_CUMLEN.max() == pytest.approx(5335, rel=0.02) assert pol.dataframe.H_CUMLEN.max() == pytest.approx(5335, rel=0.02) assert pol2.dataframe.H_CUMLEN.max() == pytest.approx(5335, rel=0.02)