geoVeRoPy.geometry module¶
- geoVeRoPy.geometry.calPolyAreaLatLon(polyLatLon: list[list[float]] | list[tuple[float, float]]) float[source]¶
Returns the area surrounded by polyLatLon on the Earth
- geoVeRoPy.geometry.calPolyAreaXY(poly: list[list[float]] | list[tuple[float, float]]) float[source]¶
- geoVeRoPy.geometry.calPolyPerimeterXY(poly: list[list[float]] | list[tuple[float, float]]) float[source]¶
- geoVeRoPy.geometry.calTriangleAreaXY(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float], pt3: list[float] | tuple[float, float]) float[source]¶
- geoVeRoPy.geometry.circleByCenterLatLon(center: list[float] | tuple[float, float], radius: int | float, lod: int = 30) list[list[float]] | list[tuple[float, float]][source]¶
Create a circle by the center and a radius. The circle is approximated by a x-gon, e.g., 30-gon polygon.
- Parameters:
center (pt, required) – The center of the circle
radius (float, required) – The radius of the circle
lod (int, optional, default as 30) – Level of details. The circle is approximated as a x-gon. E.g. 30-gon
- Returns:
A polygon that approximates the circle.
- Return type:
poly
- geoVeRoPy.geometry.circleByCenterXY(center: list[float] | tuple[float, float], radius: int | float, lod: int = 30) list[list[float]] | list[tuple[float, float]][source]¶
Create a circle by the center and a radius. The circle is approximated by a x-gon, e.g., 30-gon polygon.
- Parameters:
center (pt, required) – The center of the circle
radius (float, required) – The radius of the circle
lod (int, optional, default as 30) – Level of details. The circle is approximated as a x-gon. E.g. 30-gon
- Returns:
A polygon that approximates the circle.
- Return type:
poly
- geoVeRoPy.geometry.distBtwPolysXY(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float], polys: list[list[list[float]]] | list[list[tuple[float, float]]], polyVG: dict | None = None) dict[source]¶
Gives a Manhatten distance based on two coords.
- Parameters:
pt1 (pt, required) – The first location
pt2 (pt, required) – The second location
polys (polys, required) – The polygons as barriers.
polyVG (dict, optional, default as None) – The pre-calculated visual-graph using
polysVisibleGraph(). To avoid repeated calculation
- Returns:
A dictionary, with the distance in ‘dist’, and the path in ‘path’
- Return type:
dict
- geoVeRoPy.geometry.distEuclideanXY(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float]) dict[source]¶
Gives a Euclidean distance based on two coords.
- Parameters:
pt1 (pt, required) – The first location
pt2 (pt, required) – The second location
- Returns:
A dictionary, with the distance in ‘dist’, and the path in ‘path’
- Return type:
dict
- geoVeRoPy.geometry.distLatLon(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float], distUnit: str = 'meter') dict[source]¶
Gives a distance based on two lat/lon coords.
- Parameters:
pt1 (pt, required) – The first location
pt2 (pt, required) – The second location
- Returns:
A dictionary, with the distance in ‘dist’, and the path in ‘path’
- Return type:
dict
- geoVeRoPy.geometry.distManhattenXY(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float]) dict[source]¶
Gives a Manhatten distance based on two coords.
- Parameters:
pt1 (pt, required) – The first location
pt2 (pt, required) – The second location
- Returns:
A dictionary, with the distance in ‘dist’, and the path in ‘path’
- Return type:
dict
- geoVeRoPy.geometry.distOnGrid(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float], column, row, barriers=[], algo: str = 'A*', **kwargs) dict[source]¶
Given two coordinates on the grid, finds the ‘shortest’ path to travel
- Parameters:
pt1 (pt, required) – Starting location on the grid
pt2 (pt, required) – Ending location on the grid
column (int, required) – Number of columns
row (int, required) – Number of rows
barriers (list[pt], optional, default as []) – A list of coordinates as barriers on the grid.
algo (dict, required, default as 'A*') –
The algorithm configuration. For example
- A*, use the A star algorithm, additional information needed is as follows
measure: str, optional, default as ‘Manhatten’
**kwargs (optional) – Provide additional inputs for different algo options
- Returns:
A dictionary, with the distance in ‘dist’, and the path in ‘path’
- Return type:
dict
- geoVeRoPy.geometry.distPoly2Poly(poly1: list[list[float]] | list[tuple[float, float]] | None = None, poly2: list[list[float]] | list[tuple[float, float]] | None = None, poly1Shapely: Polygon | None = None, poly2Shapely: Polygon | None = None) float[source]¶
The distance between two polys
- Parameters:
poly1 (poly, optional, default as None) – The first polygon
poly1Shapely (shapely.Polygon, optional, default as None) – The correspond shapely object for the first polygon. Need to provide one of the following fields: [poly1, poly1Shapely]
poly2 (poly, optional, default as None) – The second polygon
poly2Shapely (shapely.Polygon, optional, default as None) – The correspond shapely object for the second polygon. Need to provide one of the following fields: [poly2, poly2Shapely]
- Returns:
The distance between two objects
- Return type:
float
- geoVeRoPy.geometry.distPt2Line(pt: list[float] | tuple[float, float], line: list[list[float] | tuple[float, float]]) float[source]¶
The distance between a point and a line
- Parameters:
pt (pt, required) – The point
line (line, required) – The line
- Returns:
The distance between two objects
- Return type:
float
- geoVeRoPy.geometry.distPt2Poly(pt: list[float] | tuple[float, float], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None) float[source]¶
The distance between a point and a polygon
- Parameters:
pt (pt, required) – The point
poly (poly, optional, default as None) – The polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
- Returns:
The distance between two objects
- Return type:
float
- geoVeRoPy.geometry.distPt2Ray(pt: list[float] | tuple[float, float], ray: list[list[float] | tuple[float, float]]) float[source]¶
The distance between a point and a ray
- Parameters:
pt (pt, required) – The point
ray (line, required) – The ray
- Returns:
The distance between two objects
- Return type:
float
- geoVeRoPy.geometry.distPt2Seg(pt: list[float] | tuple[float, float], seg: list[list[float] | tuple[float, float]]) float[source]¶
The distance between a point and a line segment
- Parameters:
pt (pt, required) – The point
seg (line, required) – The line segment
- Returns:
The distance between two objects
- Return type:
float
- geoVeRoPy.geometry.distPt2Seq(pt: list[float] | tuple[float, float], seq: list[list[float] | tuple[float, float]], closedFlag=False) float[source]¶
The distance between a point and a sequence of points
- Parameters:
pt (pt, required) – The point
seq (list of pt, required) – A sequence of points
closedFlag (bool, optional, default False) – True if the sequence is closed
- Returns:
The distance between two objects
- Return type:
float
- geoVeRoPy.geometry.headingLatLon(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float]) float[source]¶
Given current location and a goal location, calculate the heading. North is 0-degrees, clock-wise
- Parameters:
pt1 (pt, required) – The first point
pt2 (pt, required) – The second point
- Returns:
The direction from pt1 to pt2, north as 0, clock-wise
- Return type:
float
- geoVeRoPy.geometry.headingXY(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float]) float[source]¶
Given two points, returns the direction from the first point to the second point
- Parameters:
pt1 (pt, required) – The first point
pt2 (pt, required) – The second point
- Returns:
The direction from pt1 to pt2, north as 0, clock-wise
- Return type:
float
- geoVeRoPy.geometry.intLine2Line(line1: list[list[float] | tuple[float, float]], line2: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a line to another line
- Parameters:
line1 (line, required) – The first line
line2 (line, required) – The second line
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intLine2Poly(line: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, returnShaplelyObj: bool = False) dict | list[dict] | Point | Polygon | GeometryCollection[source]¶
The intersection of a line to a polygon
- Parameters:
line (line, required) – The first line
poly (poly, optional, default as None) – The second polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intLine2Ray(line: list[list[float] | tuple[float, float]], ray: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a line to a ray
- Parameters:
line (line, required) – The first line
ray (line, required) – The second ray
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intLine2Seg(line: list[list[float] | tuple[float, float]], seg: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a line to another line segment
- Parameters:
line (line, required) – The first line
seg (line, required) – The second line segment
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intPoly2Poly(poly1: list[list[float]] | list[tuple[float, float]] | None = None, poly2: list[list[float]] | list[tuple[float, float]] | None = None, poly1Shapely: Polygon | None = None, poly2Shapely: Polygon | None = None)[source]¶
Intersection between two polygons
- Parameters:
poly1 (poly, optional, default as None) – The first polygon
poly2 (poly, optional, default as None) – The second polygon
poly1Shapely (shapely.Polygon, optional, default as None) – The correspond shapely object for the first polygon. Need to provide one of the following fields: [poly1, poly1Shapely]
poly2Shapely (shapely.Polygon, optional, default as None) – The correspond shapely object for the second polygon. Need to provide one of the following fields: [poly2, poly2Shapely]
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intRay2Line(ray: list[list[float] | tuple[float, float]], line: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a ray to another line
- Parameters:
ray (line, required) – The first line
line (line, required) – The second line
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intRay2Poly(ray: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, returnShaplelyObj: bool = False) dict | list[dict] | Point | Polygon | GeometryCollection[source]¶
The intersection of a ray to a polygon
- Parameters:
ray (line, required) – The first ray
poly (poly, optional, default as None) – The second polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intRay2Ray(ray1: list[list[float] | tuple[float, float]], ray2: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a ray to another ray
- Parameters:
ray1 (line, required) – The first line
ray2 (line, required) – The second line
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intRay2Seg(ray: list[list[float] | tuple[float, float]], seg: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a ray to another line segment
- Parameters:
ray (line, required) – The first line
seg (line, required) – The second line
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intSeg2Line(seg: list[list[float] | tuple[float, float]], line: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a line segment to another line
- Parameters:
seg (line, required) – The first line segment
line (line, required) – The second line
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intSeg2Poly(seg: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, returnShaplelyObj: bool = False) dict | list[dict] | Point | Polygon | GeometryCollection[source]¶
The intersection of a line segment to a polygon
- Parameters:
seg (line, required) – The first line segment
poly (poly, optional, default as None) – The second polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intSeg2Ray(seg: list[list[float] | tuple[float, float]], ray: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a line segment to a ray
- Parameters:
line (line, required) – The first line
ray (line, required) – The second line
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intSeg2Seg(seg1: list[list[float] | tuple[float, float]], seg2: list[list[float] | tuple[float, float]]) dict[source]¶
The intersection of a line segment to another line segment
- Parameters:
seg1 (line, required) – The first line segment
seg2 (line, required) – The second line segment
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.intSeq2Poly(seq: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]])[source]¶
- geoVeRoPy.geometry.is2PtsSame(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float], error: float = 1e-05) bool[source]¶
Are two points at the ‘same’ location?
- Parameters:
pt1 (pt, required) – Coordinate of the first point
pt2 (pt, required) – Coordinate of the second point
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if two points are at the same location, False else-wise
- Return type:
bool
- geoVeRoPy.geometry.is2SegsAffine(seg1: list[list[float] | tuple[float, float]], seg2: list[list[float] | tuple[float, float]], error: float = 1e-05)[source]¶
- geoVeRoPy.geometry.is2SegsOverlap(seg1: list[list[float] | tuple[float, float]], seg2: list[list[float] | tuple[float, float]], error: float = 1e-05)[source]¶
- geoVeRoPy.geometry.is2SegsParallel(seg1: list[list[float] | tuple[float, float]], seg2: list[list[float] | tuple[float, float]], error: float = 1e-05)[source]¶
- geoVeRoPy.geometry.is2SegsSame(seg1: list[list[float] | tuple[float, float]], seg2: list[list[float] | tuple[float, float]], error: float = 1e-05) bool[source]¶
- geoVeRoPy.geometry.is3PtsClockWise(pt1: list[float] | tuple[float, float], pt2: list[float] | tuple[float, float], pt3: list[float] | tuple[float, float], error: float = 1e-05) bool | None[source]¶
Are three given pts in a clock-wise order, None as they are collinear
- Parameters:
pt1 (pt, required) – Coordinate of the first point
pt2 (pt, required) – Coordinate of the second point
pt3 (pt, required) – Coordinate of the third point
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if three given points are in a clock-wise order, False if they are in counter-clock-wise order, None if they are collinear
- Return type:
bool | None
- geoVeRoPy.geometry.isLineIntLine(line1: list[list[float] | tuple[float, float]], line2: list[list[float] | tuple[float, float]]) bool[source]¶
Is two line intersect with each other?
- Parameters:
line1 (line, required) – The first line
line2 (line, required) – The second line
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isLineIntPoly(line: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, interiorOnly: bool = False) bool[source]¶
Is a line intersects to a polygon?
- Parameters:
line (line, required) – The first line
poly (poly, optional, default as None) – The second polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isLineIntRay(line: list[list[float] | tuple[float, float]], ray: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a line intersect with a ray?
- Parameters:
line (line, required) – The first line
ray (line, required) – The second ray
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isLineIntSeg(line: list[list[float] | tuple[float, float]], seg: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a line intersect with a line segment?
- Parameters:
line (line, required) – The first line
seg (line, required) – The second line segment
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isPolyIntPoly(poly1: list[list[float]] | list[tuple[float, float]] | None = None, poly2: list[list[float]] | list[tuple[float, float]] | None = None, poly1Shapely: Polygon | None = None, poly2Shapely: Polygon | None = None, interiorOnly: bool = False) bool[source]¶
Is a polygon intersect to another polygon
- Parameters:
poly1 (poly, optional, default as None) – The first polygon
poly2 (poly, optional, default as None) – The second polygon
poly1Shapely (shapely.Polygon, optional, default as None) – The correspond shapely object for the first polygon. Need to provide one of the following fields: [poly1, poly1Shapely]
poly2Shapely (shapely.Polygon, optional, default as None) – The correspond shapely object for the second polygon. Need to provide one of the following fields: [poly2, poly2Shapely]
- Returns:
>>> { ... 'status': 'Cross', # Relations between two objects, ... 'intersect': pt, # The intersection, ... 'intersectType': 'Point', # Type of intersection ... 'interiorFlag': False, # True if the intersection is at the boundary ... }
- Return type:
dict
- geoVeRoPy.geometry.isPtInPoly(pt: list[float] | tuple[float, float], poly: list[list[float]] | list[tuple[float, float]], interiorOnly: bool = False, error: float = 1e-05) bool[source]¶
Is a pt in the polygon?
- Parameters:
pt (pt, required) – Coordinate of the point
poly (poly, required) – The polygon
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if the point is on the line segment, False else-wise
- Return type:
bool
- geoVeRoPy.geometry.isPtOnLine(pt: list[float] | tuple[float, float], line: list[list[float] | tuple[float, float]], error: float = 1e-05) bool[source]¶
Is a pt on the line?
- Parameters:
pt (pt, required) – Coordinate of the point
line (line, required) – Two coordinates to form a line
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if the point is on the line, False else-wise
- Return type:
bool
- geoVeRoPy.geometry.isPtOnPolyEdge(pt: list[float] | tuple[float, float], poly: list[list[float]] | list[tuple[float, float]], error: float = 1e-05) bool[source]¶
Is a pt on the edge of the polygon?
- Parameters:
pt (pt, required) – Coordinate of the point
poly (poly, required) – The polygon
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if the point is on the line segment, False else-wise
- Return type:
bool
- geoVeRoPy.geometry.isPtOnRay(pt: list[float] | tuple[float, float], ray: list[list[float] | tuple[float, float]], interiorOnly: bool = False, error=1e-05) bool[source]¶
Is a pt on the ray?
- Parameters:
pt (pt, required) – Coordinate of the point
ray (line, required) – Two coordinates to form a line segment
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if the point is on the line segment, False else-wise
- Return type:
bool
- geoVeRoPy.geometry.isPtOnSeg(pt: list[float] | tuple[float, float], seg: list[list[float] | tuple[float, float]], interiorOnly: bool = False, error: float = 1e-05) bool[source]¶
Is a pt on the lines segment?
- Parameters:
pt (pt, required) – Coordinate of the point
seg (line, required) – Two coordinates to form a line segment
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
error (float, optional, default as CONST_EPSILON) – Error tolerance
- Returns:
True if the point is on the line segment, False else-wise
- Return type:
bool
- geoVeRoPy.geometry.isRayIntLine(ray: list[list[float] | tuple[float, float]], line: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a ray intersect with a line?
- Parameters:
ray (line, required) – The first line segment
line (line, required) – The second line
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isRayIntPoly(ray: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, interiorOnly: bool = False) bool[source]¶
Is a ray intersects to a polygon?
- Parameters:
ray (line, required) – The first line
poly (poly, optional, default as None) – The second polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isRayIntRay(ray1: list[list[float] | tuple[float, float]], ray2: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a ray intersect with a ray?
- Parameters:
ray1 (line, required) – The first line segment
ray2 (line, required) – The second line
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isRayIntSeg(ray: list[list[float] | tuple[float, float]], seg: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a ray intersect with a line segment?
- Parameters:
ray (line, required) – The first line segment
seg (line, required) – The second line
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isSegIntBoundingbox(seg: list[list[float] | tuple[float, float]], boundingBox: list) bool[source]¶
Is a line segment intersect with a given bounding box?
- Parameters:
seg (line, required) – The first line segment
boundingBox (list, required) – A list, in the following format: [minX, maxX, minY, maxY]
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isSegIntLine(seg: list[list[float] | tuple[float, float]], line: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a line segment intersect with a line?
- Parameters:
seg (line, required) – The first line segment
line (line, required) – The second line
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isSegIntPoly(seg: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, interiorOnly: bool = False) bool[source]¶
Is a line segment intersects to a polygon?
- Parameters:
seg (line, required) – The first line
poly (poly, optional, default as None) – The second polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isSegIntRay(seg: list[list[float] | tuple[float, float]], ray: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a line segment intersect with a ray?
- Parameters:
seg (line, required) – The first line segment
ray (line, required) – The second line
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.isSegIntSeg(seg1: list[list[float] | tuple[float, float]], seg2: list[list[float] | tuple[float, float]], interiorOnly: bool = False) bool[source]¶
Is a line segment intersect with another line segment?
- Parameters:
seg1 (line, required) – The first line segment
seg2 (line, required) – The second line
interiorOnly (bool, optional, default as False) – True if only consider intersecting in the interior
- Returns:
True if intersects
- Return type:
bool
- geoVeRoPy.geometry.nearestPtLine2Poly(line: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None) dict[source]¶
Find the nearest point between a line and a polygon
- Parameters:
line (line, required) – The line
poly (poly, optional, default as None) – The polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
- Returns:
>>> { ... 'ptOnLine': pt, # The point from the line, ... 'ptOnPoly': pt, # The point from the polygon, ... }
- Return type:
dict
- geoVeRoPy.geometry.nodeSeqByDist(nodes: dict, nodeIDs: list | str = 'All', locFieldName='loc', refLoc: list[float] | tuple[float, float] | None = None, refNodeID: int | str | None = None) list[source]¶
- geoVeRoPy.geometry.nodeSeqBySweeping(nodes: dict, nodeIDs: list | str = 'All', locFieldName='loc', refLoc: list[float] | tuple[float, float] | None = None, refNodeID: int | str | None = None, isClockwise: bool = True, initDeg: float = 0) list[source]¶
Given a set of locations, and a center point, gets the sequence from sweeping
- geoVeRoPy.geometry.nodesInIsochrone(nodes: dict, nodeIDs: list | str = 'All', locFieldName='loc', refLoc: list[float] | tuple[float, float] | None = None, refNodeID: int | str | None = None, isoRange: float | None = None, sortFlag: bool = False) list[source]¶
- geoVeRoPy.geometry.polyClockWise(poly) bool[source]¶
Given a poly, return True if the poly is clockwise, False otherwise
- Parameters:
poly (poly, required) – The poly
- Returns:
True if clockwise, false otherwise
- Return type:
bool
- geoVeRoPy.geometry.polyLatLon2XYMercator(polyLatLon: list[list[float]] | list[tuple[float, float]]) list[list[float]] | list[tuple[float, float]][source]¶
- geoVeRoPy.geometry.polyXY2LatLonMercator(polyXY: list[list[float]] | list[tuple[float, float]]) list[list[float]] | list[tuple[float, float]][source]¶
- geoVeRoPy.geometry.polysIntersect(polys: list[list[list[float]]] | list[list[tuple[float, float]]] | None = None, polysShapely: list[Polygon] | None = None, returnShaplelyObj: bool = False) list[source]¶
Given a list of polygons which could be intersecting to each other, return the intersecting polygons
- Parameters:
polys (poly, optional, default as None) – A list of polygons
polysShapely (shapely.Polygon, optional, default as None) – The correspond shapely objects for polygons. Need to provide one of the following fields: [polys, polysShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
A list of polygons
- Return type:
list of polys
- geoVeRoPy.geometry.polysSubtract(polys: list[list[list[float]]] | list[list[tuple[float, float]]] | None = None, polysShapely: list[Polygon] | None = None, subPolys: list[list[list[float]]] | list[list[tuple[float, float]]] | None = None, subPolysShapely: list[Polygon] | None = None, returnShaplelyObj: bool = False) list[source]¶
Given a list of polygons, subtract a list of polygon from the first list of polygons
- Parameters:
polys (poly, optional, default as None) – A list of polygons
polysShapely (shapely.Polygon, optional, default as None) – The correspond shapely objects for polygons. Need to provide one of the following fields: [polys, polysShapely]
subPolys (poly, optional, default as None) – A list of polygons to substract
subPolysShapely (shapely.Polygon, optional, default as None) – The correspond shapely objects for polygons. Need to provide one of the following fields: [subPolys, subPolysShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
A list of polygons
- Return type:
list of polys
- geoVeRoPy.geometry.polysUnion(polys: list[list[list[float]]] | list[list[tuple[float, float]]] | None = None, polysShapely: list[Polygon] | None = None, returnShaplelyObj: bool = False) list[source]¶
Given a list of polygons which could be intersecting to each other, return unioned polygons that are not intersecting
- Parameters:
polys (poly, optional, default as None) – A list of polygons
polysShapely (shapely.Polygon, optional, default as None) – The correspond shapely objects for polygons. Need to provide one of the following fields: [polys, polysShapely]
returnShaplelyObj (bool, optional, default as False) – True if alter the result to be a shapely object
- Returns:
A list of polygons
- Return type:
list of polys
- geoVeRoPy.geometry.polysVisibleGraph(polys: list[list[list[float]]] | list[list[tuple[float, float]]]) dict[source]¶
Create a visual graph for given polys.
- Parameters:
polys (polys, required) – The polys to create visual graph
- Returns:
Each polygon has a index p, each point in the polygon has a index e, therefore, a (p, e) pair defines a location. The visual graph returns use (p, e) as keys, collects the location of (p, e) in ‘loc’, and finds the set of visible (p, e) in ‘visible’
- Return type:
dict
- geoVeRoPy.geometry.ptFoot2Line(pt: list[float] | tuple[float, float], line: list[list[float] | tuple[float, float]]) list[float] | tuple[float, float][source]¶
Given a point and a line, return the foot of that point on the line
- Parameters:
pt (pt, required) – The point where the foot will go through
line (line Required) – The line which the foot is perpendicular to
- Returns:
The foot of that point on the line
- Return type:
pt
- geoVeRoPy.geometry.ptInDistLatLon(pt: list[float] | tuple[float, float], direction: int | float, distMeters: int | float) list[float] | tuple[float, float][source]¶
A location in distance with given direction in lat/lon.
- Parameters:
pt (pt, required) – The origin point
direction (float, required) – The direction from origin point
dist (float, required)
- Returns:
The new location
- Return type:
pt
- geoVeRoPy.geometry.ptInDistXY(pt: list[float] | tuple[float, float], direction: int | float, dist: int | float) list[float] | tuple[float, float][source]¶
A location in distance with given direction.
- Parameters:
pt (pt, required) – The origin point
direction (float, required) – The direction from origin point
dist (float, required)
- Returns:
The new location
- Return type:
pt
- geoVeRoPy.geometry.ptInSeqMileage(seq: list[list[float] | tuple[float, float]], dist: int | float, dimension: str = 'XY') list[float] | tuple[float, float][source]¶
Given a list of lat/lon coordinates, and a traveling mileage, returns the coordinate
- geoVeRoPy.geometry.ptLatLon2XYMercator(ptLatLon: list[float] | tuple[float, float]) list[float] | tuple[float, float][source]¶
Given a point in (lat, lon), map it to a (x, y) coordinate using Mercator projection
- Parameters:
ptLatLon (pt, required) – The coordinate in (lat, lon)
- Returns:
The coordinate in (x, y)
- Return type:
tuple
- geoVeRoPy.geometry.ptPolyCenter(poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None) list[float] | tuple[float, float][source]¶
Given a poly, returns the centroid of the poly
- Parameters:
poly (poly, optional, default as None) – The polygon
polyShapely (shapely.Polygon, optional, default as None) – The correspond shapely object for polygon. Need to provide one of the following fields: [poly, polyShapely]
- Returns:
The centroid
- Return type:
pt
- geoVeRoPy.geometry.ptXY2LatLonMercator(ptXY: list[float] | tuple[float, float]) list[float] | tuple[float, float][source]¶
Given a point in (x, y), map it to a (lat, lon) coordinate using Mercator projection
- Parameters:
ptXY (pt, required) – The coordinate in (x, y)
- Returns:
The coordinate in (lat, lon)
- Return type:
tuple
- geoVeRoPy.geometry.rayPerp2Line(pt: list[float] | tuple[float, float], line: list[list[float] | tuple[float, float]]) list[list[float] | tuple[float, float]][source]¶
Given a point and a line, return a ray from that point and perpendicular to the given line
- Parameters:
pt (pt, required) – The point where the ray will go through
line (line Required) – The line which the ray is perpendicular to
- Returns:
A ray that is perpendicular to the line
- Return type:
line
- geoVeRoPy.geometry.seq2TimedSeq(seq: list[list[float] | tuple[float, float]], vehSpeed: float, timeEachStop: float = 0, startTime: float = 0)[source]¶
- geoVeRoPy.geometry.seqLinkSeq(seq1: list[list[float] | tuple[float, float]], seq2: list[list[float] | tuple[float, float]], error: float = 1e-05)[source]¶
Given two seqs, link them together if possible, return None if they are separated
- Parameters:
seq1 (list[pt], required) – The first sequence
seq2 (list[pt], required) – The second sequence
- Returns:
The sequence connected both seq, or None if two seqs are separated
- Return type:
list[pt]
- geoVeRoPy.geometry.snapInTimedSeq(timedSeq: list[tuple[list[float] | tuple[float, float], float]], t: float) dict[source]¶
Given a timedSeq, return the location, speed, and trajectory at time t
- Parameters:
timedSeq (timedSeq, required) – The timed sequence
t (float, required) – The snapshot timestamp
- Returns:
>>> { ... 'loc': location, ... 'speed': speed, ... 'trajectory': trajectory ... }
- Return type:
dict
- geoVeRoPy.geometry.subSegFromPoly(seg: list[list[float] | tuple[float, float]], poly: list[list[float]] | list[tuple[float, float]] | None = None, polyShapely: Polygon | None = None, returnShaplelyObj: bool = False)[source]¶
- geoVeRoPy.geometry.traceInTimedSeq(timedSeq: list[tuple[list[float] | tuple[float, float], float]], ts: float, te: float) list[list[float] | tuple[float, float]][source]¶
Given a timedSeq, a start time and an end time, returns the trace between start time and end time.
- Parameters:
timedSeq (timedSeq, required) – The timed sequence
ts (float, required) – The start time
te (float, required) – The end time
- Returns:
The line segment sequence between start time and end time in the timedSeq
- Return type:
list
- geoVeRoPy.geometry.vecPolar2XY(vecPolar) list[float] | tuple[float, float][source]¶
Given vector’s norm and its degree to North, convert it into a 2-tuple vector
- Parameters:
vecPolar (tuple[float|int, float|int], required) – A 2-tuple (vVal, vDeg), vVal is the norm and vDeg is the direction, 0 as North, clockwise, in [0, 360)
- Returns:
The XY vector
- Return type:
tuple[float|int, float|int]
- geoVeRoPy.geometry.vecXY2Polar(vecXY: list[float] | tuple[float, float])[source]¶
Given a 2-tuple, convert it into a norm and a direction in degree
- Parameters:
vecXY (tuple[float|int, float|int], required) – A 2-tuple (vX, vY), the coordinate of vector
- Returns:
The polar vector
- Return type:
tuple[float|int, float|int]