intersect¶
In [ ]:
intersect(vdf: vDataFrame,
index: str,
gid: str,
g: str = "",
x: str = "",
y: str = "",)
Spatially intersects a point or points with a set of polygons.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
vdf | vDataFrame | ❌ | vDataFrame to use to compute the spatial join. |
index | str | ❌ | Name of the index. |
gid | str | ❌ | An integer column or integer that uniquely identifies the spatial object(s) of g or x and y. |
g | str | ✓ | A geometry or geography (WGS84) column that contains points. The g column can contain only point geometries or geographies. |
x | str | ✓ | x-coordinate or longitude. |
y | str | ✓ | y-coordinate or latitude. |
Returns¶
vDataFrame : object containing the result of the intersection.
Example¶
In [38]:
from verticapy.geo import *
from verticapy.datasets import load_world, load_cities
world = load_world()
world["id"] = "ROW_NUMBER() OVER(ORDER BY country, pop_est)"
display(world)
cities = load_cities()
cities["id"] = "ROW_NUMBER() OVER (ORDER BY city)"
cities["lat"] = "ST_X(geometry)"
cities["lon"] = "ST_Y(geometry)"
display(cities)
In [39]:
# Creating Index
create_index(world, "id", "geometry", "world_polygons", True)
Out[39]:
In [40]:
# Intersect using Geometry
intersect(cities, "world_polygons", "id", "geometry")
Out[40]:
In [41]:
# Intersect using Latitude and Longitude
intersect(cities, "world_polygons", "id", x="lat", y="lon")
Out[41]: