What does ST_GeomFromText do?

ST_GeomFromText is a function used in spatial databases, such as PostGIS (an extension of PostgreSQL), to create a geometry object from a Well-Known Text (WKT) representation. WKT is a text markup language for representing vector geometry objects.

Syntax

ST_GeomFromText(geometry_text, [srid])
  • geometry_text: A string representing the geometry in WKT format (e.g., 'POINT(1 1)', 'LINESTRING(0 0, 1 1)', 'POLYGON((0 0, 1 1, 1 0, 0 0))').
  • srid (optional): The Spatial Reference System Identifier, which defines the coordinate system for the geometry.

Example

SELECT ST_GeomFromText('POINT(1 1)', 4326);

This creates a point geometry at the coordinates (1, 1) with an SRID of 4326 (WGS 84).

0 Comments

no data
Be the first to share your comment!