create_index¶
In [ ]:
create_index(vdf: vDataFrame,
gid: str,
g: str,
index: str,
overwrite: bool = False,
max_mem_mb: int = 256,
skip_nonindexable_polygons: bool = False)
Creates a spatial index on a set of polygons to speed up spatial intersection with a set of points.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
vdf | vDataFrame | ❌ | vDataFrame to use to compute the spatial join. |
gid | str | ❌ | Name of an integer column that uniquely identifies the polygon. The gid cannot be NULL. |
g | str | ❌ | Name of a geometry or geography (WGS84) column or expression that contains polygons and multipolygons. Only polygon and multipolygon can be indexed. Other shape types are excluded from the index. |
index | str | ✓ | Name of the index. |
overwrite | bool | ✓ | BOOLEAN value that specifies whether to overwrite the index, if an index exists. |
max_mem_mb | int | ✓ | A positive integer that assigns a limit to the amount of memory in megabytes that create_index can allocate during index construction. |
skip_nonindexable_polygons | bool | ✓ | In rare cases, intricate polygons (for instance, with too high resolution or anomalous spikes) cannot be indexed. These polygons are considered non-indexable. When set to False, non-indexable polygons cause the index creation to fail. When set to True, index creation can succeed by excluding non-indexable polygons from the index. |
Returns¶
tablesample : An object containing the result. For more information, see utilities.tablesample.
Example¶
In [3]:
from verticapy.geo import *
from verticapy.learn.datasets import load_world
world = load_world()
world["id"] = "ROW_NUMBER() OVER(ORDER BY country, pop_est)"
display(world)
In [4]:
create_index(world, "id", "geometry", "world_polygons", True)
Out[4]: