snowflake.snowpark.functions.st_envelope

snowflake.snowpark.functions.st_envelope(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str])[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.41.0/src/snowflake/snowpark/_functions/scalar_functions.py#L2949-L2972)

Returns the minimum bounding box (envelope) that contains the input GEOGRAPHY or GEOMETRY object.

Parameters:

geography_or_geometry_expression – The GEOGRAPHY or GEOMETRY data.

Returns:

The envelope as a GEOGRAPHY or GEOMETRY object.

Return type:

Column

Example:

>>> from snowflake.snowpark.functions import to_geography
>>> df = session.create_dataframe([
...     ['POLYGON((-122.306067 37.55412, -122.32328 37.561801, -122.325879 37.586852, -122.306067 37.55412))'],
...     ['POINT(-122.32328 37.561801)'],
...     ['LINESTRING(-122.32328 37.561801, -122.32328 37.562001)']
... ], schema=["geom"])
>>> df.select(st_envelope(to_geography(df["geom"])).alias("envelope")).collect()
[Row(ENVELOPE='{\n  "coordinates": [\n    [\n      [\n        -1.223258790000000e+02,\n        3.755411999999995e+01\n      ],\n      [\n        -1.223060670000000e+02,\n        3.755411999999995e+01\n      ],\n      [\n        -1.223060670000000e+02,\n        3.758685200000006e+01\n      ],\n      [\n        -1.223258790000000e+02,\n        3.758685200000006e+01\n      ],\n      [\n        -1.223258790000000e+02,\n        3.755411999999995e+01\n      ]\n    ]\n  ],\n  "type": "Polygon"\n}'), Row(ENVELOPE='{\n  "coordinates": [\n    -1.223232800000000e+02,\n    3.756180100000000e+01\n  ],\n  "type": "Point"\n}'), Row(ENVELOPE='{\n  "coordinates": [\n    [\n      -1.223232800000000e+02,\n      3.756180099999997e+01\n    ],\n    [\n      -1.223232800000000e+02,\n      3.756200100000003e+01\n    ]\n  ],\n  "type": "LineString"\n}')]
Copy
语言: 中文