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)
123
pop_est
Int
Abc
continent
Varchar(32)
Abc
country
Varchar(82)
🌎
Geometry(1048576)
123
id
Integer
134124811AsiaAfghanistan1
23047987EuropeAlbania2
340969443AfricaAlgeria3
429310273AfricaAngola4
54050AntarcticaAntarctica5
644293293South AmericaArgentina6
73045191AsiaArmenia7
823232413OceaniaAustralia8
98754413EuropeAustria9
109961396AsiaAzerbaijan10
11329988North AmericaBahamas11
12157826578AsiaBangladesh12
139549747EuropeBelarus13
1411491346EuropeBelgium14
15360346North AmericaBelize15
1611038805AfricaBenin16
17758288AsiaBhutan17
1811138234South AmericaBolivia18
193856181EuropeBosnia and Herz.19
202214858AfricaBotswana20
21207353391South AmericaBrazil21
22443593AsiaBrunei22
237101510EuropeBulgaria23
2420107509AfricaBurkina Faso24
2511466756AfricaBurundi25
2616204486AsiaCambodia26
2724994885AfricaCameroon27
2835623680North AmericaCanada28
295625118AfricaCentral African Rep.29
3012075985AfricaChad30
3117789267South AmericaChile31
321379302771AsiaChina32
3347698524South AmericaColombia33
344954674AfricaCongo34
354930258North AmericaCosta Rica35
364292095EuropeCroatia36
3711147407North AmericaCuba37
381221549AsiaCyprus38
3910674723EuropeCzechia39
4024184810AfricaCôte d'Ivoire40
4183301151AfricaDem. Rep. Congo41
425605948EuropeDenmark42
43865267AfricaDjibouti43
4410734247North AmericaDominican Rep.44
4516290913South AmericaEcuador45
4697041072AfricaEgypt46
476172011North AmericaEl Salvador47
48778358AfricaEq. Guinea48
495918919AfricaEritrea49
501251581EuropeEstonia50
51105350020AfricaEthiopia51
522931South AmericaFalkland Is.52
53920938OceaniaFiji53
545491218EuropeFinland54
55140Seven seas (open ocean)Fr. S. Antarctic Lands55
5667106161EuropeFrance56
571772255AfricaGabon57
582051363AfricaGambia58
594926330AsiaGeorgia59
6080594017EuropeGermany60
6127499924AfricaGhana61
6210768477EuropeGreece62
6357713North AmericaGreenland63
6415460732North AmericaGuatemala64
6512413867AfricaGuinea65
661792338AfricaGuinea-Bissau66
67737718South AmericaGuyana67
6810646714North AmericaHaiti68
699038741North AmericaHonduras69
709850845EuropeHungary70
71339747EuropeIceland71
721281935911AsiaIndia72
73260580739AsiaIndonesia73
7482021564AsiaIran74
7539192111AsiaIraq75
765011102EuropeIreland76
778299706AsiaIsrael77
7862137802EuropeItaly78
792990561North AmericaJamaica79
80126451398AsiaJapan80
8110248069AsiaJordan81
8218556698AsiaKazakhstan82
8347615739AfricaKenya83
841895250EuropeKosovo84
852875422AsiaKuwait85
865789122AsiaKyrgyzstan86
877126706AsiaLaos87
881944643EuropeLatvia88
896229794AsiaLebanon89
901958042AfricaLesotho90
914689021AfricaLiberia91
926653210AfricaLibya92
932823859EuropeLithuania93
94594130EuropeLuxembourg94
952103721EuropeMacedonia95
9625054161AfricaMadagascar96
9719196246AfricaMalawi97
9831381992AsiaMalaysia98
9917885245AfricaMali99
1003758571AfricaMauritania100
Rows: 1-100 | Columns: 5
In [4]:
create_index(world, "id", "geometry", "world_polygons", True)
Out[4]:
Abc
type
Varchar(20)
123
polygons
Integer
123
SRID
Integer
123
min_x
Float
123
min_y
Float
123
max_x
Float
123
max_y
Float
Abc
info
Varchar(500)
1GEOMETRY1770-180.0-90.0180.083.64513
Rows: 1-1 | Columns: 8