Beispiel #1
0
def test_points_intersects_polygon(gp_points, gp_polygon):
    # Get scalar Polygon
    sg_polygon = gp_polygon[0]

    # Compute expected intersection
    expected = gp_points.intersects(sg_polygon)

    # Create spatialpandas objects
    polygon = Polygon.from_shapely(sg_polygon)
    points = PointArray.from_geopandas(gp_points)
    points_series = GeoSeries(points, index=np.arange(10, 10 + len(points)))

    # Test Point.intersects
    result = np.array([
        point_el.intersects(polygon) for point_el in points
    ])
    np.testing.assert_equal(result, expected)

    # Test PointArray.intersect
    result = points.intersects(polygon)
    np.testing.assert_equal(result, expected)

    # Test PointArray.intersects with inds
    inds = np.flipud(np.arange(0, len(points)))
    result = points.intersects(polygon, inds)
    np.testing.assert_equal(result, np.flipud(expected))

    # Test GeoSeries.intersects
    pd.testing.assert_series_equal(
        points_series.intersects(polygon),
        pd.Series(expected, index=points_series.index)
    )
Beispiel #2
0
def test_point_intersects_polygon(sg_polygon, points):
    polygon = Polygon.from_shapely(sg_polygon)

    for r in range(points.shape[0]):
        x, y = points[r, :]
        result = point_intersects_polygon(x, y, polygon.buffer_values,
                                          polygon.buffer_inner_offsets)

        expected = sg_polygon.intersects(sg.Point([x, y]))
        assert expected == result