Exemplo n.º 1
0
def test_missing_5():
    with pytest.raises(RuntimeError):
        result = cuspatial.point_in_polygon_bitmap(  # noqa: F841
            cudf.Series([0.0]),
            cudf.Series([0.0]),
            cudf.Series([0.0]),
            cudf.Series([0.0]),
            cudf.Series([0.0]),
            cudf.Series(),
        )
Exemplo n.º 2
0
def test_one_point_in():
    result = cuspatial.point_in_polygon_bitmap(
        cudf.Series([0]),
        cudf.Series([0]),
        cudf.Series([1]),
        cudf.Series([3]),
        cudf.Series([-1, 0, 1]),
        cudf.Series([-1, 1, -1]),
    )
    expected = cudf.DataFrame({"in_polygon_1": True})
    assert_eq(result, expected)
Exemplo n.º 3
0
def test_zeros():
    result = cuspatial.point_in_polygon_bitmap(
        cudf.Series([0.0]),
        cudf.Series([0.0]),
        cudf.Series([0.0]),
        cudf.Series([0.0]),
        cudf.Series([0.0]),
        cudf.Series([0.0]),
    )
    expected = cudf.DataFrame({"in_polygon_0.0": False})
    assert_eq(result, expected)
Exemplo n.º 4
0
def test_dataset():
    result = cuspatial.point_in_polygon_bitmap(
        cudf.Series([0, -8, 6.0]),
        cudf.Series([0, -8, 6.0]),
        cudf.Series([1, 2]),
        cudf.Series([5, 10]),
        cudf.Series([-10.0, 5, 5, -10, -10, 0, 10, 10, 0, 0]),
        cudf.Series([-10.0, -10, 5, 5, -10, 0, 0, 10, 10, 0]),
    )
    expected = cudf.DataFrame()
    expected["in_polygon_1"] = [True, True, False]
    expected["in_polygon_2"] = [True, False, True]
    assert_eq(result, expected)
Exemplo n.º 5
0
from shapely.geometry import Point, Polygon

import cuspatial

data_dir = "/home/jianting/cuspatial/data/"
plyreader = shapefile.Reader(data_dir + "its_4326_roi.shp")
polygon = plyreader.shapes()
plys = []
for shape in polygon:
    plys.append(Polygon(shape.points))

pnt_lon, pnt_lat = cuspatial.read_points_lonlat(data_dir + "locust.location")
fpos, rpos, plyx, plyy = cuspatial.read_polygon(data_dir + "itsroi.ply")

start = time.time()
bm = cuspatial.point_in_polygon_bitmap(pnt_lon, pnt_lat, fpos, rpos, plyx,
                                       plyy)
end = time.time()
print("Python GPU Time in ms (end-to-end)={}".format((end - start) * 1000))

bma = bm.data.to_array()
pntx = pnt_lon.data.to_array()
pnty = pnt_lat.data.to_array()

start = time.time()
mis_match = 0
for i in range(pnt_lon.data.size):
    pt = Point(pntx[i], pnty[i])
    res = 0
    for j in range(len(plys)):
        pip = plys[len(plys) - 1 - j].contains(pt)
        if pip: