Conversation
|
Cool! I will try to take a look at it one of the coming days. Currently at EuroScipy conference, so a bit busy, but, I will sit together here with one of the numpy developers who is interested in seeing the dtype stuff :-) |
jorisvandenbossche
left a comment
There was a problem hiding this comment.
Added a bunch of suggestions, but this is great work!
One thing I was wondering, you now use a GeometryObject where the pointer is a NULL pointer, but alternatively, we could also directly use a NULL pointer in the array (instead of a pointer to a GeometryObject with NULL pointer in it).
I think in practice this would give None in the python interface (so None instead of the custom pygeos.NaG in the user interface). Just a thought, not convinced myself this is necessarily better.
I added two additional functions to identify NaG values:
is_geometryandis_null
Additionally to those, it would alos be useful to have a fast ufunc exposed to just check that the input only contains "valid objects" (in pygeos array's context, so a geometry or a NaG) as well. So basically a is_geometry(a) | is_null(a), but as single ufunc this can be more efficient.
pygeos/predicates.py
Outdated
|
|
||
|
|
||
| def is_null(geometry, **kwargs): | ||
| """Returns True if the object is not a geometry (NaG) |
There was a problem hiding this comment.
Thought: could also call this as a more generic is_missing, to avoid a specific choice between NA or NULL (eg in pandas nowadays we are standardizing on NA, at least in the method names)
|
Thanks for the remarks, I made some changes:
|
Maybe good to wait to see how this numpy-dtype extension thing plays out? |
On the short term, it unfortunately won't play out. See the discussion in #34. It will need changes in numpy to be feasible (but changes they would welcome / want to plan). |
| <pygeos.Geometry LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)> | ||
| >>> boundary(Geometry("MULTIPOINT (0 0, 1 2)")) | ||
| <pygeos.NaG> | ||
| >>> boundary(Geometry("MULTIPOINT (0 0, 1 2)")) is None |
There was a problem hiding this comment.
Alternative could be to do print(..) which then actually shows None (but both are of course workarounds for None having no repr)
Oh I wasn 't following the discussion. So I implemented 3 ufuncs |
[Done] Separating Missing (NaG) and Empty
Closes #28, closes #29
This is some work separating the concepts of missing geometries (not-a-geometry or NaG) values and empty geometries. The idea is to keep a single NaG object (like None) that has its GEOSGeometry pointer set to NULL.
All geometry-returning functions propagate the NaG; predicates return False for any import NaG; integer returning functions return -1 for NaG.
I added two additional functions to identify NaG values:
is_geometryandis_null.Further there should be functions that create arrays of empty geometries.