-
Notifications
You must be signed in to change notification settings - Fork 560
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
Shapely 2.0 naming inconsistencies to resolve #1276
Comments
Specifically for those cases that are about functions in a submodule (and not methods on the geometry objects), i.e. for the polygonization and validity functions, we don't necessarily have to "solve" this directly, if we are happy with the new naming. In that case, the preferred top-level (vectorized) functions will have the new naming, and the old functions in the submodule can for now be left as-is soft-deprecated (until we decide if we actually want to deprecate/eventually remove them or not, depending on the discussion in #1225). It's mostly for the geometry class methods that it would be nice to already provide a consistent interface with the vectorized functions (i.e. interpolate, project, representative_point, parallel_offset, buffer resolution keyword). |
I felt like "resolution" was more understandable to shapely users than "quadsegs". The latter being sort of jargon-y. @jorisvandenbossche I would prefer to maintain the attribute and method names from shapely 1.x unless they are misleading. While 2.0 can have breaking changes, the fewer we make, the better. Users won't celebrate 2.0 as much if they have to make a lot of changes. Consistency in naming between class attributes/methods and the vectorized functions would be a plus, certainly. What would you think about changing the vectorized function names to be consistent with the class attributes and methods? Or adding in aliases in that direction? When merging pygeos into shapely, which API needs to give is a challenging question. As pygeos is newer and not yet at 1.0, maybe it could make more changes than we've considered up to now? |
Yes, I certainly wouldn't propose to remove any of the current geometry class attributes/methods. And if we wanted to do that, we should have deprecated them in Shapely 1.8. Focusing on the attributes/methods for a moment (so this is about
I am personally not super attached to the new names from pygeos (I think @caspervdw is a bit more :)), but I think one clear advantage of having them (so at least keeping those as aliases, option 2) is that they match the names from eg PostGIS (and R sf I think as well), which can improve discoverability for users. |
For two of the other items mentioned above, I opened a PR to align the moved pygeos functions with Shapely: |
The issues from the list in the top post that are not yet finalized are:
Plus for inconsistent naming for functions in submodules:
|
One more naming inconsistency that was noted by @mwtoews in #1522 (comment), is the keyword naming for the distance / radius / width in
So I think the proposal of @mwtoews to use |
What follows is an overview of some (naming) inconsistencies we currently have between the vectorized functions (moved from pygeos) and existing shapely geometry methods or functions.
We can use this as a general issue, but can also open separate issue to discuss some of them in more detail if needed.
(the naming inconsistency is listed as "original shapely name" vs "vectorized function name (moved from pygeos)")
Unary union:
unary_union
vsunion_all
Unary union is the typical way this is called (also in PostGIS), and this is an often used attribute. But, we also have
intersection_all
andsymmetric_difference_all
, for which the_all
naming scheme probably makes more sense than addingunary_
. For this reason, we could keep bothunary_union
andunion_all
as aliases?This is both an attribute on the geometry objects, as a function in the ops.py submodule.
PR -> #1536
Linear referencing related methods
interpolate
vsline_interpolate_point
project
vsline_locate_point
PostGIS also uses the
ST_LineInterpolatePoint
andST_LineLocatePoint
terminology, while theinterpolate
andproject
naming follows GEOS.Those are methods on the geometry objects
Other methods on the geometry class:
parallel_offset
vsoffset_curve
(method only on LineString)representative_point
vspoint_on_surface
PostGIS has
ST_OffsetCurve
, and also GEOS uses this naming scheme (GEOSOffsetCurve_r
).Similar for
ST_PointOnSurface
/GEOSPointOnSurface_r
Buffer resolution keyword
resolution
vsquadsegs
In Shapely, the
quadsegs
keyword was deprecated in favor ofresolution
at some point (5689abf), but the vectorized function (moved from pygeos) is usingquadsegs
(which maps to the name used in GEOS and more or less in PostGIS). @sgillies do you remember the reason for changing it toresolution
? (to have a more readable name?)Simplify preserve_topology default
The
simplify
method on the geometry object has a default ofpreserve_topology=True
. The vectorized function (moved from pygeos) on the other hand usespreserve_topology=False
.PostGIS has two separate function for this (ST_Simplify and ST_SimplifyPreserveTopology) so cannot be used as prior art.
PR -> #1392
Polygonization
triangulate
vsdelaunay_triangles
edges
vsonly_edges
voronoi_diagram
vsvoronoi_polygons
envelope
vsextend_to
,edges
vsonly_edges
polygonize
: also different return type: list of geometries vs GeometryCollectionPostGIS has
ST_DelaunayTriangles
andST_VoronoiPolygons
(andST_VoronoiLines
). GEOS usesGEOSDelaunayTriangulation_r
andGEOSVoronoiDiagram_r
.This are functions in the
shapely.ops
submodule.Validity
explain_validity
vsis_valid_reason
(in validation.py)validate
vsis_valid_reason
(in ops.py)PostGIS has
ST_IsValidReason
, GEOS also usesGEOSisValidReason_r
.transform
vsapply
Shapely has
transform(func, geom)
in ops.py, which takes a function that accepts/returns a single coordinate pair (so basicallyfunc(x, y, z=None) -> x, y, (z)
).The vectorized function (moved from pygeos) is called
apply(geometry, transformation)
(so the function is the second keyword here), and here the function is assumed to accept/return a 2D array of coordinates (all coordinates at once).This
apply
function is already used under the hood inaffine_transform
.PR -> #1393
The text was updated successfully, but these errors were encountered: