Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

[BUG]: Number of polygons cannot exceed 31 #1563

@mspachecoagoro

Description

@mspachecoagoro

Version

25.04.00

On which installation method(s) does this occur?

Conda

Describe the issue

I am trying to check if a cuspatial GeoSeries with 11 multipoligons contain a point and it returns an error.

Image

Image

Image

Error message:

RuntimeError Traceback (most recent call last)
Cell In[39], line 1
----> 1 strata_gdf.geometry.contains(point)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/geoseries.py:1063, in GeoSeries.contains(self, other, align, allpairs, mode)
1010 """Returns a Series of dtype('bool') with value True for each
1011 aligned geometry that contains other.
1012
(...)
1058 polygon_indices, each of which is a Series of dtype('int32').
1059 """
1060 predicate = CONTAINS_DISPATCH[(self.column_type, other.column_type)](
1061 align=align, allpairs=allpairs, mode=mode
1062 )
-> 1063 return predicate(self, other)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/binpred_interface.py:299, in BinPred.call(self, lhs, rhs)
266 def call(self, lhs: "GeoSeries", rhs: "GeoSeries") -> Series:
267 """System call for the binary predicate. Calls the _call method,
268 which is implemented by the subclass. Executing the binary predicate
269 returns the results of the binary predicate as a GeoSeries.
(...)
297 dtype: bool
298 """
--> 299 return self._call(lhs, rhs)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/binpred_interface.py:320, in BinPred._call(self, lhs, rhs)
301 def _call(self, lhs: "GeoSeries", rhs: "GeoSeries") -> Series:
302 """Call the binary predicate. This method is implemented by the
303 subclass.
304
(...)
318 GeoSeries.
319 """
--> 320 return self._preprocess(lhs, rhs)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/feature_contains.py:50, in ContainsPredicate._preprocess(self, lhs, rhs)
48 def _preprocess(self, lhs, rhs):
49 preprocessor_result = super()._preprocess_multipoint_rhs(lhs, rhs)
---> 50 return self._compute_predicate(lhs, rhs, preprocessor_result)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/feature_contains.py:138, in ContainsPredicate._compute_predicate(self, lhs, rhs, preprocessor_result)
133 def _compute_predicate(self, lhs, rhs, preprocessor_result):
134 if contains_only_points(rhs):
135 # Special case in GeoPandas, points are not contained
136 # in the boundary of a polygon, so only return true if
137 # the points are contained_properly.
--> 138 contains = _basic_contains_count(lhs, rhs).reset_index(drop=True)
139 return contains > 0
140 elif contains_only_linestrings(rhs):

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/basic_predicates.py:87, in _basic_contains_count(lhs, rhs)
85 lhs = lhs
86 rhs = _multipoints_from_geometry(rhs)
---> 87 contains = lhs.contains_properly(rhs, mode="basic_count")
88 return contains

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/geoseries.py:1163, in GeoSeries.contains_properly(self, other, align, allpairs, mode)
1068 """Returns a Series of dtype('bool') with value True for each
1069 aligned geometry that contains other.
1070
(...)
1158 Series of dtype('int32') in the case of allpairs=True.
1159 """
1160 predicate = CONTAINS_PROPERLY_DISPATCH[
1161 (self.column_type, other.column_type)
1162 ](align=align, allpairs=allpairs, mode=mode)
-> 1163 return predicate(self, other)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/binpred_interface.py:299, in BinPred.call(self, lhs, rhs)
266 def call(self, lhs: "GeoSeries", rhs: "GeoSeries") -> Series:
267 """System call for the binary predicate. Calls the _call method,
268 which is implemented by the subclass. Executing the binary predicate
269 returns the results of the binary predicate as a GeoSeries.
(...)
297 dtype: bool
298 """
--> 299 return self._call(lhs, rhs)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/binpred_interface.py:320, in BinPred._call(self, lhs, rhs)
301 def _call(self, lhs: "GeoSeries", rhs: "GeoSeries") -> Series:
302 """Call the binary predicate. This method is implemented by the
303 subclass.
304
(...)
318 GeoSeries.
319 """
--> 320 return self._preprocess(lhs, rhs)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/feature_contains_properly.py:65, in ContainsProperlyPredicate._preprocess(self, lhs, rhs)
63 def _preprocess(self, lhs, rhs):
64 preprocessor_result = super()._preprocess_multipoint_rhs(lhs, rhs)
---> 65 return self._compute_predicate(lhs, rhs, preprocessor_result)

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/feature_contains_properly.py:115, in ContainsProperlyPredicate._compute_predicate(self, lhs, rhs, preprocessor_result)
113 if mode == "pairwise":
114 lhs_indices = preprocessor_result.point_indices
--> 115 pip_result = contains_properly(
116 lhs[lhs_indices], preprocessor_result.final_rhs, mode=mode
117 )
118 # If the mode is pairwise or brute_force, we need to replace the
119 # pairwise_index of each repeated polygon with the part_index
120 # from the preprocessor result.
121 if "pairwise_index" in pip_result.columns:

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/contains.py:181, in contains_properly(polygons, points, mode)
176 return _pairwise_contains_properly(points, polygons)
177 else:
178 # Use stack to convert the result to the same shape as quadtree's
179 # result, name the columns appropriately, and return the
180 # two-column DataFrame.
--> 181 bitmask_result = _brute_force_contains_properly(points, polygons)
182 bitmask_result_df = bitmask_result.stack().reset_index()
183 trues = bitmask_result_df[bitmask_result_df[0]]

File ~/miniconda3/envs/rapids-25.04/lib/python3.12/site-packages/cuspatial/core/binpreds/contains.py:99, in _brute_force_contains_properly(points, polygons)
77 def _brute_force_contains_properly(points, polygons):
78 """Compute from a series of points and a series of polygons which points
79 are properly contained within the corresponding polygon. Polygon A contains
80 Point B properly if B intersects the interior of A but not the boundary (or
(...)
97 within its corresponding polygon.
98 """
---> 99 pip_result = cpp_byte_point_in_polygon(
100 as_column(points.points.x).to_pylibcudf(mode="read"),
101 as_column(points.points.y).to_pylibcudf(mode="read"),
102 as_column(polygons.polygons.part_offset).to_pylibcudf(mode="read"),
103 as_column(polygons.polygons.ring_offset).to_pylibcudf(mode="read"),
104 as_column(polygons.polygons.x).to_pylibcudf(mode="read"),
105 as_column(polygons.polygons.y).to_pylibcudf(mode="read"),
106 )
107 result = DataFrame(
108 pip_bitmap_column_to_binary_array(
109 polygon_bitmap_column=ColumnBase.from_pylibcudf(pip_result),
110 width=len(polygons.polygons.part_offset) - 1,
111 )
112 )
113 final_result = DataFrame(
114 {
115 name: result[name].astype("bool")
116 for name in reversed(result.columns)
117 }
118 )

File point_in_polygon.pyx:34, in cuspatial._lib.point_in_polygon.point_in_polygon()

RuntimeError: cuSpatial failure at: /opt/conda/conda-bld/work/cpp/include/cuspatial/detail/point_in_polygon.cuh:93: Number of polygons cannot exceed 31

Minimum reproducible example

Relevant log output

Environment details

Other/Misc.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalIssues filed by people outside the teamNeeds TriageNeed team to review and classifybugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions