-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create pairwise_point_in_polygon
to be used by pairwise GeoSeries
#750
Create pairwise_point_in_polygon
to be used by pairwise GeoSeries
#750
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a long input test to have more point/polygon points than the size of a grid.
cpp/include/cuspatial/experimental/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu
Outdated
Show resolved
Hide resolved
cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu
Outdated
Show resolved
Hide resolved
cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need an epsilon when comparing to zero...
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the experimental epsilon code with printfs and my question about the utility of pairwise PiP for big data, looks good.
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last few comments
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon_kernel.cuh
Outdated
Show resolved
Hide resolved
rerun tests |
cpp/include/cuspatial/experimental/detail/is_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu
Outdated
Show resolved
Hide resolved
Co-authored-by: Mark Harris <mharris@nvidia.com>
Co-authored-by: Mark Harris <mharris@nvidia.com>
Co-authored-by: Mark Harris <mharris@nvidia.com>
cpp/include/cuspatial/experimental/detail/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/is_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/pairwise_point_in_polygon.cuh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments above, adopt if you see fit.
Co-authored-by: Michael Wang <isVoid@users.noreply.github.com>
…m/cuspatial into feature/pairwise_point_in_polygon
@gpucibot merge |
…749) This PR closes the above named issues relating to creating a .contains method and, more importantly, resolving boundary case inconsistency with `point_in_polygon`. ~As it stands the colinearity test I've added to `is_point_in_polygon` doubles the runtime of brute-force `point_in_polygon` and has no visible effect on the runtime of `quadtree_point_in_polygon`.~ ~- Note I need to double check the above benchmark, having set this project down for the last few weeks.~ This depends on #750, please do not review the C++ code here until that PR is merged. Please do review the python code. ## Benchmark Benchmark results are in, looks like there's no measurable speed difference between 22.12 pre-boundary exclusion and our current implementation: ``` (rapids) rapids@compose:~/cuspatial/python/cuspatial/benchmarks$ pytest api/bench_api.py::bench_point_in_polygon ================================================== test session starts =================================================== platform linux -- Python 3.8.15, pytest-7.2.0, pluggy-1.0.0 benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) rootdir: /home/tcomer/mnt/NVIDIA/rapids-docker/cuspatial/python/cuspatial/benchmarks, configfile: pytest.ini plugins: cov-4.0.0, benchmark-4.0.0, cases-3.6.13, xdist-3.0.2, anyio-3.6.2, hypothesis-6.58.1 collected 1 item api/bench_api.py . [100%] ---------------------------------------------- benchmark: 1 tests --------------------------------------------- Name (time in s) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations --------------------------------------------------------------------------------------------------------------- bench_point_in_polygon 1.9636 1.9749 1.9678 0.0043 1.9660 0.0045 1;0 0.5082 5 1 --------------------------------------------------------------------------------------------------------------- Legend: Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile. OPS: Operations Per Second, computed as 1 / Mean =================================================== 1 passed in 16.28s =================================================== (rapids) rapids@compose:~/cuspatial/python/cuspatial/benchmarks$ git status On branch feature/GeoSeries.contains ``` vs `branch-22.12` ``` (rapids) rapids@compose:~/cuspatial/python/cuspatial/benchmarks$ pytest api/bench_api.py::bench_point_in_polygon ================================== test session starts =================================== platform linux -- Python 3.8.15, pytest-7.2.0, pluggy-1.0.0 benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) rootdir: /home/tcomer/mnt/NVIDIA/rapids-docker/cuspatial/python/cuspatial/benchmarks, configfile: pytest.ini plugins: cov-4.0.0, benchmark-4.0.0, cases-3.6.13, xdist-3.0.2, anyio-3.6.2, hypothesis-6.58.1 collected 1 item api/bench_api.py . [100%] ---------------------------------------------- benchmark: 1 tests --------------------------------------------- Name (time in s) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations --------------------------------------------------------------------------------------------------------------- bench_point_in_polygon 1.9516 1.9843 1.9730 0.0126 1.9760 0.0127 1;0 0.5068 5 1 --------------------------------------------------------------------------------------------------------------- Legend: Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile. OPS: Operations Per Second, computed as 1 / Mean =================================== 1 passed in 16.61s =================================== (rapids) rapids@compose:~/cuspatial/python/cuspatial/benchmarks$ git status On branch benchmark/branch-22.12 ``` ## Still adding: - [x] Detailed description of xfail result. - [x] Self-review existing `.contains` implementation in python. - [x] Update `.contains` docs when necessary. - [x] Benchmark again and document here. - [x] Move binops_with_quadtree.py to next branch. - [x] `.contains` Examples Authors: - H. Thomson Comer (https://github.com/thomcom) Approvers: - Michael Wang (https://github.com/isVoid) - Mark Harris (https://github.com/harrism) URL: #749
Description
This PR provides two primary outcomes: it adds a
pairwise_point_in_polygon
API in the header-only and cudf-backed C++ functionality, and it modifies theis_point_in_polygon
kernel to perform boundary exclusion.The
pairwise_point_in_polygon
API has been added becauseGeoPandas.GeoSeries.contains
only supports a pairwise operation and a many-to-one operation, but does not implement the all-pairs approach to point-in-polygon we developed.Boundary exclusion has been added for two reasons: The main reason is because
GeoPandas.GeoSeries.contains
applies boundary exclusion: points that are in the boundary of a polygon are not considered to be "in" the polygon. The other reason to add boundary exclusion is because our results were previously undefined. Some boundary points were excluded in point-in-polygon, and others were not. This PR resolves that inconsistency.Checklist