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

A question when i want to find the closest segment in a set to a point #134

Open
HanZhaang opened this issue Dec 19, 2019 · 1 comment
Open

Comments

@HanZhaang
Copy link

I tried to define a bounding box of a segment. for example:
(0, 0), to (2, 2), bounding box is (0,0,2,2) minx,miny,maxx,maxy
It worked perfectly.
But when I met segment (0,2) to (2, 0) , its bounding box is same as the former one. but they are different segments.
How should I define such segment?

@sr-murthy
Copy link
Collaborator

sr-murthy commented Feb 10, 2020

The entries in the R-tree index are minimum bounding rectangles (MBR) of point sets, not oriented line segments, and the intersection and nearest neightbour queries are point-MBR queries.

The MBR (min. bounding rectangle) of the line segment from (0, 2) to (2, 0) is given by (0, 0, 2, 2), using the (minx, miny, maxx, maxy) convention, same as for the line segment from (0, 0) to (2, 2). Geometrically, the two line segments have different orientation, but their MBRs are the same. You can check this.

In [1]: from shapely.geometry import Point, LineString                                                                            

In [2]: p00, p22 = Point(0, 0), Point(2, 2)                                                                                       

In [3]: l1 = LineString((p00, p22))                                                                                               

In [4]: l1.bounds                                                                                                                 
Out[4]: (0.0, 0.0, 2.0, 2.0)

In [5]: p02, p20 = Point(0, 2), Point(2, 0)                                                                                       

In [6]: l2 = LineString((p02, p20))                                                                                               

In [7]: l2.bounds                                                                                                                 
Out[7]: (0.0, 0.0, 2.0, 2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants