Jump to Navigation

js

Основные геометрические функции PostGIS

Основные функции PostGIS

Полный справочник фукций (англ.)

8.5.27 ST_Transform

ST_Transform — Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.

Возвращает новую геометрию с координатами, трансформированными в систему координат, указанную в целочисленном параметре srid.

Synopsis

geometry ST_Transform(geometry g1, integer srid);

Description

Returns a new geometry with its coordinates transformed to spatial reference system referenced by the SRID integer parameter.
The destination SRID must exist in the SPATIAL_REF_SYS table.
ST_Transform is often confused with ST_SetSRID(). ST_Transform actually changes the coordinates of a geometry from one
spatial reference system to another, while ST_SetSRID() simply changes the SRID identifier of the geometry
 

8.7.15 <->

<-> — Returns the distance between two points. For point / point checks it uses floating point accuracy (as opposed to the double
precision accuracy of the underlying point geometry). For other geometry types the distance between the floating point bounding
box centroids is returned. Useful for doing distance ordering and nearest neighbor limits using KNN gist functionality.

Synopsis

double precision <->( geometry A , geometry B );

Description

The <-> operator returns distance between two points read from the spatial index for points (float precision). For other geometries
it returns the distance from centroid of bounding box of geometries. Useful for doing nearest neighbor approximate distance
ordering.

 

8.8.9 ST_Area

ST_Area — Returns the area of the surface if it is a polygon or multi-polygon. For "geometry" type area is in SRID units. For
"geography" area is in square meters.

Synopsis

float ST_Area(geometry g1);
float ST_Area(geography geog, boolean use_spheroid=true);

Description

Returns the area of the geometry if it is a polygon or multi-polygon. Return the area measurement of an ST_Surface or
ST_MultiSurface value. For geometry Area is in the units of the srid. For geography area is in square meters and defaults
to measuring about the spheroid of the geography (currently only WGS84). To measure around the faster but less accurate sphere
-- ST_Area(geog,false).

 

8.8.11 ST_Centroid

ST_Centroid— Returns the geometric center of a geometry.

Synopsis

geometry ST_Centroid(geometry g1);

Description

Computes the geometric center of a geometry, or equivalently, the center of mass of the geometry as a POINT. For [MULTI]POINTs,
this is computed as the arithmetic mean of the input coordinates. For [MULTI]LINESTRINGs, this is computed as the
weighted length of each line segment. For [MULTI]POLYGONs, "weight" is thought in terms of area. If an empty geometry is
supplied, an empty GEOMETRYCOLLECTION is returned. If NULL is supplied, NULL is returned.
The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension
geometries contribute zero "weight" to the centroid).

 

8.8.13 ST_Contains

ST_Contains — Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies
in the interior of A.

Synopsis

boolean ST_Contains(geometry geomA, geometry geomB);

Description

Geometry A contains Geometry B if and only if no points of B lie in the exterior of A, and at least one point of the interior of B
lies in the interior of A. An important subtlety of this definition is that A does not contain its boundary, but A does contain itself.
Contrast that to ST_ContainsProperly where geometry A does not Contain Properly itself.
Returns TRUE if geometry B is completely inside geometry A. For this function to make sense, the source geometries must both
be of the same coordinate projection, having the same SRID. ST_Contains is the inverse of ST_Within. So ST_Contains(A,B)
implies ST_Within(B,A) except in the case of invalid geometries where the result is always false regardless or not defined.

 

8.8.14 ST_ContainsProperly

ST_ContainsProperly — Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain
properly itself, but does contain itself.

Synopsis

boolean ST_ContainsProperly(geometry geomA, geometry geomB);

Description

Returns true if B intersects the interior of A but not the boundary (or exterior).
A does not contain properly itself, but does contain itself.

 

8.8.17 ST_Crosses

ST_Crosses— Returns TRUE if the supplied geometries have some, but not all, interior points in common.

Synopsis

boolean ST_Crosses(geometry g1, geometry g2);

Description

ST_Crosses takes two geometry objects and returns TRUE if their intersection "spatially cross", that is, the geometries have
some, but not all interior points in common. The intersection of the interiors of the geometries must not be the empty set and
must have a dimensionality less than the the maximum dimension of the two input geometries. Additionally, the intersection of
the two geometries must not equal either of the source geometries. Otherwise, it returns FALSE.

 

8.8.19 ST_Disjoint

ST_Disjoint— Returns TRUE if the Geometries do not "spatially intersect" - if they do not share any space together.

Synopsis

boolean ST_Disjoint( geometry A , geometry B );

Description

Overlaps, Touches, Within all imply geometries are not spatially disjoint. If any of the aforementioned returns true, then the
geometries are not spatially disjoint. Disjoint implies false for spatial intersection.

 

8.8.20 ST_Distance

ST_Distance — For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two
geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in
meters.

Synopsis

float ST_Distance(geometry g1, geometry g2);
float ST_Distance(geography gg1, geography gg2);
float ST_Distance(geography gg1, geography gg2, boolean use_spheroid);

Description

For geometry type returns the 2-dimensional minimum cartesian distance between two geometries in projected units (spatial ref
units). For geography type defaults to return the minimum distance around WGS 84 spheroid between two geographies in meters.
Pass in false to return answer in sphere instead of spheroid.

 

8.8.23 ST_Distance_Sphere

ST_Distance_Sphere — Returns minimum distance in meters between two lon/lat geometries. Uses a spherical earth and radius
of 6370986 meters. Faster than ST_Distance_Spheroid ST_Distance_Spheroid, but less accurate. PostGIS versions prior to 1.5
only implemented for points.

Synopsis

float ST_Distance_Sphere(geometry geomlonlatA, geometry geomlonlatB);

Description

Returns minimum distance in meters between two lon/lat points. Uses a spherical earth and radius of 6370986 meters. Faster
than ST_Distance_Spheroid, but less accurate. PostGIS Versions prior to 1.5 only implemented for points.
Note
This function currently does not look at the SRID of a geometry and will always assume its in WGS 84 long lat. Prior
versions of this function only support points.

 

8.8.29 ST_Intersects

ST_Intersects — Returns TRUE if the Geometries/Geography "spatially intersect in 2D" - (share any portion of space) and
FALSE if they don’t (they are Disjoint). For geography -- tolerance is 0.00001 meters (so any points that close are considered to
intersect)

Synopsis

boolean ST_Intersects( geometry geomA , geometry geomB );
boolean ST_Intersects( geography geogA , geography geogB );

Description

If a geometry or geography shares any portion of space then they intersect. For geography -- tolerance is 0.00001 meters (so any
points that are close are considered to intersect)
Overlaps, Touches, Within all imply spatial intersection. If any of the aforementioned returns true, then the geometries also
spatially intersect. Disjoint implies false for spatial intersection.

 

8.8.30 ST_Length

ST_Length — Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial
reference and geography are in meters (default spheroid)

Synopsis

float ST_Length(geometry a_2dlinestring);
float ST_Length(geography geog, boolean use_spheroid=true);

Description

For geometry: Returns the cartesian 2D length of the geometry if it is a linestring, multilinestring, ST_Curve, ST_MultiCurve. 0
is returned for areal geometries. For areal geometries use ST_Perimeter. Geometry: Measurements are in the units of the spatial
reference system of the geometry. Geography: Units are in meters and also acts as a Perimeter function for areal geogs.
Currently for geometry this is an alias for ST_Length2D, but this may change to support higher dimensions.

 

8.8.39 ST_Perimeter

ST_Perimeter—Return the length measurement of the boundary of an ST_Surface or ST_MultiSurface geometry or geography.
(Polygon, Multipolygon). geometry measurement is in units of spatial reference and geography is in meters.

Synopsis

float ST_Perimeter(geometry g1);
float ST_Perimeter(geography geog, boolean use_spheroid=true);

Description

Returns the 2D perimeter of the geometry/geography if it is a ST_Surface, ST_MultiSurface (Polygon, Multipolygon). 0 is
returned for non-areal geometries. For linestrings use ST_Length. Measurements for geometry are in the units of the spatial
reference system of the geometry. Measurements for geography are in meters. If use_spheroid is set to false, then will
model earth as a sphere instead of a spheroid.
Currently this is an alias for ST_Perimeter2D, but this may change to support higher dimensions.

 

8.8.47 ST_Touches

ST_Touches— Returns TRUE if the geometries have at least one point in common, but their interiors do not intersect.

Synopsis

boolean ST_Touches(geometry g1, geometry g2);

Description

Returns TRUE if the only points in common between g1 and g2 lie in the union of the boundaries of g1 and g2. The ST_Touches
relation applies to all Area/Area, Line/Line, Line/Area, Point/Area and Point/Line pairs of relationships, but not to the
Point/Point pair.

 

8.8.48 ST_Within

ST_Within— Returns true if the geometry A is completely inside geometry B

Synopsis

boolean ST_Within(geometry A, geometry B);

Description

Returns TRUE if geometry A is completely inside geometry B. For this function to make sense, the source geometries must both
be of the same coordinate projection, having the same SRID. It is a given that if ST_Within(A,B) is true and ST_Within(B,A) is
true, then the two geometries are considered spatially equal.

 

8.10.1 ST_Buffer

ST_Buffer — (T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less
than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar
transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options:
quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#

Synopsis

geometry ST_Buffer(geometry g1, float radius_of_buffer);
geometry ST_Buffer(geometry g1, float radius_of_buffer, integer num_seg_quarter_circle);
geometry ST_Buffer(geometry g1, float radius_of_buffer, text buffer_style_parameters);
geography ST_Buffer(geography g1, float radius_of_buffer_in_meters);

Description

Returns a geometry/geography that represents all points whose distance from this Geometry/geography is less than or equal to
distance.
Geometry: Calculations are in the Spatial Reference System of the geometry. Introduced in 1.5 support for different end cap and
mitre settings to control shape.

 

8.10.8 ST_Difference

ST_Difference— Returns a geometry that represents that part of geometry A that does not intersect with geometry B.

Synopsis

geometry ST_Difference(geometry geomA, geometry geomB);

Description

Returns a geometry that represents that part of geometry A that does not intersect with geometry B. One can think of this as
GeometryA - ST_Intersection(A,B). If A is completely contained in B then an empty geometry collection is returned.

 

8.10.13 ST_Intersection

ST_Intersection — (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation
does a transform to geometry to do the intersection and then transform back to WGS84.

Synopsis

geometry ST_Intersection( geometry geomA , geometry geomB );
geography ST_Intersection( geography geogA , geography geogB );

Description

Returns a geometry that represents the point set intersection of the Geometries.
In other words - that portion of geometry A and geometry B that is shared between the two geometries.
If the geometries do not share any space (are disjoint), then an empty geometry collection is returned.
ST_Intersection in conjunction with ST_Intersects is very useful for clipping geometries such as in bounding box, buffer, region
queries where you only want to return that portion of a geometry that sits in a country or region of interest.

 

8.10.26 ST_Split

ST_Split— Returns a collection of geometries resulting by splitting a geometry.

Synopsis

geometry ST_Split(geometry input, geometry blade);

Description

The function supports splitting a line by point, a line by line, a polygon by line. The returned geometry is always a collection.
Think of this function as the opposite of ST_Union. Theoretically applying ST_Union to the elements of the returned collection
should always yield the original geometry.
Availability: 2.0.0

 

8.10.27 ST_SymDifference

ST_SymDifference — Returns a geometry that represents the portions of A and B that do not intersect. It is called a symmetric
difference because ST_SymDifference(A,B) = ST_SymDifference(B,A).

Synopsis

geometry ST_SymDifference(geometry geomA, geometry geomB);

Description

Returns a geometry that represents the portions of A and B that do not intersect. It is called a symmetric difference because
ST_SymDifference(A,B) = ST_SymDifference(B,A). One can think of this as ST_Union(geomA,geomB) - ST_Intersection(A,B).

 

8.10.28 ST_Union

ST_Union— Returns a geometry that represents the point set union of the Geometries.

Synopsis

geometry ST_Union(geometry set g1field);
geometry ST_Union(geometry g1, geometry g2);
geometry ST_Union(geometry[] g1_array);

Description

Output type can be a MULTI*, single geometry, or Geometry Collection. Comes in 2 variants. Variant 1 unions 2 geometries
resulting in a new geometry with no intersecting regions. Variant 2 is an aggregate function that takes a set of geometries and
unions them into a single ST_Geometry resulting in no intersecting regions.
Aggregate version: This function returns a MULTI geometry or NON-MULTI geometry from a set of geometries. The ST_Union()
function is an "aggregate" function in the terminology of PostgreSQL. That means that it operates on rows of data, in the same
way the SUM() and AVG() functions do and like most aggregates, it also ignores NULL geometries.
Non-Aggregate version: This function returns a geometry being a union of two input geometries. Output type can be a MULTI*,
NON-MULTI or GEOMETRYCOLLECTION. If any are NULL, then NULL is returned.

 

Вход на сайт



about seo