linestring.is_simple is wrong
See original GitHub issueExpected behavior and actual behavior.
My non-self-crossing line should return is_simple
= True
Steps to reproduce the problem.
import polyline as pl
import shapely as shp
bart_line_pl = 'ly~iV{|ndFqHbHbJqIq@l@vFoFw@t@mCjCdEaEtAaB??NM??lCgCnMgMxG}GtLsL??vAwAdDaD??vCuCb@c@d@g@`@e@\\_@Za@Za@pF}G~@kAz@mAx@kAbAwAhBmCf@w@f@w@f@y@j@y@h@}@l@}@nAeBpAoBhBkC??rAoBzAyB??`EaGnBsCXa@zG{J|Zsn@rK{RzCaG??Vi@??hBsD??HO??R_@??HQ??Zq@zDmI|D}JjA}B~AyBhDgElDiEvGuIbNiP|AaBbBaBdByA`BkApBoAbCuA`CiAhSuIbDyAlCqAhCwAxBoAdBmAzAoAjAiA|@}@~@kAbHmJdAoAfAkArAoAtAmA`BoAfBkA`BeAlGcD`KqFjLsG`BeAxAgArAmArA_BdAwAz@sAxEiIfG{KjAgB~AkBhBgBbBqAnBqArBgAbCmAzC{AfC{AtBcBXUnAkAbBeB`DuDvIuKn@s@n@q@l@m@t@k@r@e@v@e@??fCaB??zAcAzAcA??rA}@rA_Ab@WfJsF??p@c@\\UPMNMNMNMNOJKLOLOJOJOLSJOTe@Ti@^{@??|AoD??JU\\y@Rg@Tq@R{@Ho@Fy@Bm@@o@DkFD{D@mD??@u@???oB@s@Bi@Dw@Hs@??P{@T{@v@gC??Ne@d@_BLe@Jg@Je@Hi@Di@Bk@@s@?q@BcE??BqDBoC@qD?kA?g@Ce@Ec@I_@Kc@Qg@Uc@Wa@Yc@}DeF??yEgG??k@u@??y@gAuEcG??c@i@UYYY]Ya@[a@U_@Sa@Oa@Oc@Oc@Ka@Ic@Gc@Ge@Ee@Cc@Ak@Ae@?oLB??qNBs@?q@Au@?g@Aq@Co@Cq@Em@Gk@Gm@Gi@Ko@Kk@Mm@Om@Qo@Ug@Qk@Ui@Wi@Yi@[g@[g@[c@]c@Y_CgBmBwAGGeBqAmA_Ak@a@e@a@e@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At@_Aj@}@h@cAb@eA\\eAZkARiARuApGsg@NwAHaABY??Bi@D_A???}@A_A??G}AMkA[cB{DgMuCiK}Js^w@}CQiAGu@AeADaA~@cOXmEpAeV^kEr@}I'
ls = shp.geometry.LineString(pl.decode(bart_line_pl)); ls
ls.is_simple
Notes:
- I don’t know if this is a generic issue; I only encountered it in this use case.
- If you run this in a notebook, you can display the line
ls
and confirm that it is not self-crossing (see screenshot)
Operating system
Mac OSX 10.14.5
Shapely version and provenance
Installed from conda-forge
$ conda list shapely
# packages in environment at ...:
#
shapely 1.6.4 py36he8793f5_0
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
linestring.is_simple is wrong · Issue #768 · shapely ... - GitHub
My non-self-crossing line should return is_simple = True Steps to reproduce the problem. import polyline as pl import shapely as shp ...
Read more >com.vividsolutions.jts.geom.LineString.isSimple java code ...
isSimple. method. in. com.vividsolutions.jts.geom.LineString ... {@code true} if the {@link PolyLine} has valid geometry, otherwise {@code false} */ public ...
Read more >Getting ST_IsSimple reason and detail similar to ...
From "Ensuring OpenGIS compliancy of geometries": A LINESTRING is simple if it does not pass through the same POINT twice (except for the ......
Read more >How to find if Shapely LineString is complex (i.e. self-intersects)
True if the geometry is simple, meaning that any self-intersections are only at boundary points, else False.
Read more >IsSimpleOp (org.locationtech.jts:jts-core 1.19.0 API)
(Note: this means that isSimple cannot be used to test for (invalid) ... If it is required to test whether a set of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can compare the coordinates of the linestring pair-wise:
You have many duplicate coordinates, which is not allowed in the Simple Features specification.
A possible automatic fix would
ls.simplify(0)
.Right back at you! Any time I file a bug report or voice a wish, I also look at issues to see if I can help, that’s the spirit.