Skip to content
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

[FEA]: Allow users to define precision of coordinates #1076

Open
jarmak-nv opened this issue Apr 14, 2023 · 7 comments
Open

[FEA]: Allow users to define precision of coordinates #1076

jarmak-nv opened this issue Apr 14, 2023 · 7 comments
Labels
feature request New feature or request

Comments

@jarmak-nv
Copy link
Contributor

jarmak-nv commented Apr 14, 2023

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request

Medium

Please provide a clear description of problem you would like to solve.

Currently coordinates in cuSpatial are FP64 but many users do not require this level of precision.

We can see as much as 2x to 64x speedups dropping to FP32 depending on the hardware used to run cuSpatial. To support this, it would be nice to see a way to define coordinates, either on a global scale or on a per-geoseries scale.

Some potential implementations:

cuspatial.set_coord_precision = float32

Or

On a geoseries/dataframe using GeometryDType and recording coordinate dtype in there, along side with other geoseries specific info (ie crs if we go that route).

Describe any alternatives you have considered

N/A

Additional context

No response

@jarmak-nv jarmak-nv added the feature request New feature or request label Apr 14, 2023
@harrism
Copy link
Member

harrism commented Apr 18, 2023

How does geopandas handle precision?

@jarmak-nv
Copy link
Contributor Author

geopandas might support the changing of precision through Shapely's set_precision() function - I haven't tested this https://shapely.readthedocs.io/en/stable/reference/shapely.set_precision.html - if this doesn't work, then geopandas does not support precision changes as far as I know.

I can do some testing later to check if geopandas overrides and provides a float64 with something like:

import geopandas as gpd
from shapely.geometry import Point

point = Point(0.9, 0.9)
set_precision(point, 1.0)
gdf = gpd.GeoDataFrame(geometry=[point])

type(gdf.loc[0, 'geometry'])

@harrism
Copy link
Member

harrism commented Apr 18, 2023

Hmmm, that seems to snap values to a grid of the specified resolution. It doesn't say anything about storing them in lower precision. It provides no way to specify "32-bit", for example, it only mentions that 0 corresponds to "double precision". Seems like it conflates "resolution" and "precision".

@harrism
Copy link
Member

harrism commented Apr 18, 2023

libGEOS provides PrecisionModel. https://libgeos.org/doxygen/classgeos_1_1geom_1_1PrecisionModel.html#details Seems related to the above, but has explicit modes for fp32 and fp64.

@jarmak-nv
Copy link
Contributor Author

Yes you're right - I just tested:

from shapely.geometry import Point

point = Point(0.9, 0.9)
point = set_precision(point, 1.0)
point.coords._coords.dtype
>>> float64

@jarmak-nv
Copy link
Contributor Author

jarmak-nv commented Apr 18, 2023

So, this looks like something not offered by our CPU Python counterparts

@harrism
Copy link
Member

harrism commented Apr 18, 2023

However we decide to support this, at the header-only C++ API level it should be trivial, because it is a template library. Depending on whether or not the column-based API already dispatches to both types, supporting both fp32 and fp64 everywhere may double compile time. We already test everything in both single and double precision on the C++ side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants