split_polygon_n

In [ ]:
split_polygon_n(p: str, 
                cursor=None, 
                nbins: int = 100)

Splits a polygon into (nbins ** 2) smaller polygons with approximately the same total area.

Parameters

Name Type Optional Description
p
str
String representation of the Polygon.
cursor
DBcursor
Vertica database cursor.
nbins
int
Number of bins used to cut the longitude and the latitude.

Returns

vDataFrame : output vDataFrame including the new polygons.

Example

In [32]:
from verticapy.geo import *
from verticapy import *

p = 'POLYGON ((121.334030916 31.5081948415, 121.334030917 31.5079167872, 121.333748304 31.5081948413, 121.334030916 31.5081948415))'
poly = tablesample({"triangle": [p]}).to_vdf()
poly["triangle"].apply("ST_GeomFromText({})")
poly["triangle"].geo_plot(color="white",
                          edgecolor="black")
Out[32]:
<AxesSubplot:>
In [33]:
split_p = split_polygon_n(p)
split_p
Out[33]:
123
gid
Int
🌎
Geometry(2024)
199
2100
3199
4200
5201
6299
7300
8301
9302
10399
11400
12401
13402
14403
15499
16500
17501
18502
19503
20504
21599
22600
23601
24602
25603
26604
27605
28699
29700
30701
31702
32703
33704
34705
35706
36799
37800
38801
39802
40803
41804
42805
43806
44807
45899
46900
47901
48902
49903
50904
51905
52906
53907
54908
55999
561000
571001
581002
591003
601004
611005
621006
631007
641008
651009
661099
671100
681101
691102
701103
711104
721105
731106
741107
751108
761109
771110
781199
791200
801201
811202
821203
831204
841205
851206
861207
871208
881209
891210
901211
911299
921300
931301
941302
951303
961304
971305
981306
991307
1001308
Rows: 1-100 | Columns: 2
In [34]:
split_p["geom"].geo_plot(color="white",
                         edgecolor="black")
Out[34]:
<AxesSubplot:>