split_polygon_n¶
In [ ]:
split_polygon_n(p: str,
nbins: int = 100)
Splits a polygon into (nbins ** 2) smaller polygons of approximately equal total area. This process is inexact, and the split polygons have approximated edges; greater values for nbins produces more accurate and precise edge approximations.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
p | str | ❌ | String representation of the Polygon. |
nbins | int | ✓ | Number of bins used to cut the longitude and the latitude. Split polygons have approximated edges, and greater values for nbins leads to more accurate and precise edge approximations. |
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]:
In [33]:
split_p = split_polygon_n(p)
split_p
Out[33]:
In [34]:
split_p["geom"].geo_plot(color="white",
edgecolor="black")
Out[34]: