postgis函数

1、st_dwitnin 比st_distance速度快,需要在geometry字段上创建gist索引
SELECT the_geom
FROM geom_table
WHERE ST_Distance(the_geom, ‘SRID=312;POINT(100000 200000)’) < 100

SELECT the_geom
FROM geom_table
WHERE ST_DWithin(the_geom, ‘SRID=312;POINT(100000 200000)’, 100)
2、AddGeometryColumn
– Add a spatial column to the table
SELECT AddGeometryColumn (‘my_schema’,‘my_spatial_table’,‘geom’,4326,‘POINT’,2);
3、st_intersects
判断两个feature是否相交返回bool值
4、st_intersection
返回相交的geometry
5、st_astext
转换geometry为text
6、st_geomfromtext(‘POINT(30 120)’,4326)
如上,给定text,创建geometry
7、st_area、st_length
求面积,长度
8、st_union
geometry合并
9、postgis geometry与arcgis geometry互相转换
第一步:postgis》》gis

  1. 将得到的byte通过ArcEngine的接口得到IGeometry,如下所示:

IGeometryFactory3 factory = new GeometryEnvironment() as IGeometryFactory3;
factory.CreateGeometryFromWkbVariant(wkb, out geom, out countin);

第二步:gis》》postgis

  1. 修改指定的要素后通过 geometry得到wkb

IGeometryFactory3 factory = new GeometryEnvironment() as IGeometryFactory3;
byte[] geoBytes = factory.CreateWkbVariantFromGeometry(geometry) as byte[];

  1. 拼接SQL时要将上面的byte[]数组转码

    其实postgis处理存到pg中的是一长串的16进制字符串,相信大家打开数据库能看到,要想拼接好SQL串就得这样来一下:st_geometryfromwkb(decode(’" + geoByteStr + "’, ‘hex’))其中的geoByteStr是byte[]转成16进制的字串
    10、DropGeometryTable
    SELECT DropGeometryTable (‘my_schema’,‘my_spatial_table’);
    ----RESULT output —
    my_schema.my_spatial_table dropped.
    – The above is now equivalent to –
    DROP TABLE my_schema.my_spatial_table;
    11、SELECT PostGIS_Extensions_Upgrade();
    将postgresql安装的扩展进行更新,更新到最新版本

ST_3DExtent - an aggregate function that returns the box3D bounding box that bounds rows of geometries.
ST_Accum - Aggregate. Constructs an array of geometries.
ST_AsGeobuf - Return a Geobuf representation of a set of rows.
ST_AsMVT - Return a Mapbox Vector Tile representation of a set of rows.
ST_ClusterIntersecting - Aggregate. Returns an array with the connected components of a set of geometries
ST_ClusterWithin - Aggregate. Returns an array of GeometryCollections, where each GeometryCollection represents a set of
geometries separated by no more than the specified distance.
ST_Collect - Return a specified ST_Geometry value from a collection of other geometries.
ST_Extent - an aggregate function that returns the bounding box that bounds rows of geometries.
ST_MakeLine - Creates a Linestring from point, multipoint, or line geometries.
ST_MemUnion - Same as ST_Union, only memory-friendly (uses less memory and more processor time).
ST_Polygonize - Aggregate. Creates a GeometryCollection containing possible polygons formed from the constituent linework
of a set of geometries.
ST_SameAlignment - Returns true if rasters have same skew, scale, spatial ref, and offset (pixels can be put on same grid
without cutting into pixels) and false if they don’t with notice detailing issue.
ST_Union - Returns a geometry that represents the point set union of the Geometries.
• TopoElementArray_Agg - Returns a topoelementarray for a set of element_id, type arrays (topoelements)
ST_Area - Returns the area of the surface if it is a Polygon or MultiPolygon. For geometry, a 2D Cartesian area is determined
with units specified by the SRID. For geography, area is determined on a curved surface with units in square meters. This
method implements the SQL/MM specification. SQL-MM 3: 8.1.2, 9.5.3
ST_AsBinary - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.37
ST_AsText - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.25
ST_Boundary - Returns the closure of the combinatorial boundary of this Geometry. This method implements the SQL/MM
specification. SQL-MM 3: 5.1.14
ST_Buffer - (T)Returns a geometry covering all points within a given distancefrom the input geometry. This method implements
the SQL/MM specification. SQL-MM 3: 5.1.17
ST_Centroid - Returns the geometric center of a geometry. This method implements the SQL/MM specification.
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. This method implements the SQL/MM specification. SQL-MM 3: 5.1.31
ST_Crosses - Returns TRUE if the supplied geometries have some, but not all, interior points in common. This method
implements the SQL/MM specification. SQL-MM 3: 5.1.29

ST_Difference - Returns a geometry that represents that part of geometry A that does not intersect with geometry B. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.20
ST_Dimension - The inherent dimension of this Geometry object, which must be less than or equal to the coordinate dimension.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.2
ST_Disjoint - Returns TRUE if the Geometries do not “spatially intersect” - if they do not share any space together. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.26
ST_Distance - For geometry type returns the 2D Cartesian distance between two geometries in projected units (based on spatial
reference system). For geography type defaults to return minimum geodesic distance between two geographies in meters. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.23
ST_EndPoint - Returns the last point of a LINESTRING or CIRCULARLINESTRING geometry as a POINT. This method
implements the SQL/MM specification. SQL-MM 3: 7.1.4
ST_Envelope - Returns a geometry representing the double precision (float8) bounding box of the supplied geometry. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.15
ST_Equals - Returns true if the given geometries represent the same geometry. Directionality is ignored. This method implements
the SQL/MM specification. SQL-MM 3: 5.1.24
ST_ExteriorRing - Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the
geometry is not a polygon. Will not work with MULTIPOLYGON This method implements the SQL/MM specification.
ST_GeomFromText - Return a specified ST_Geometry value from Well-Known Text representation (WKT). This method
implements the SQL/MM specification. SQL-MM 3: 5.1.40
• ST_GeomFromWKB
- Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional
SRID. This method implements the SQL/MM specification. SQL-MM 3: 5.1.41
ST_GeometryFromText - Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an
alias name for ST_GeomFromText This method implements the SQL/MM specification. SQL-MM 3: 5.1.40
• ST_GetFaceEdges - Returns a set of ordered edges that bound aface. This method implements the SQL/MM specification.
SQL-MM 3 Topo-Geo and Topo-Net 3: Routine Details: X.3.5
PostGIS 2.5.3dev Manual 739 / 846
• ST_GetFaceGeometry - Returns the polygon in the given topology with the specified face id. This method implements the
SQL/MM specification. SQL-MM 3 Topo-Geo and Topo-Net 3: Routine Details: X.3.16
• ST_InitTopoGeo - Creates a new topology schema and registers this new schema in the topology.topology table and details
summary of process. This method implements the SQL/MM specification. SQL-MM 3 Topo-Geo and Topo-Net 3: Routine
Details: X.3.17
• ST_InteriorRingN - Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a
polygon or the given N is out of range. This method implements the SQL/MM specification. SQL-MM 3: 8.2.6, 8.3.5
• ST_Intersection - (T)Returns a geometry that represents the shared portion of geomA and geomB. This method implements
the SQL/MM specification. SQL-MM 3: 5.1.18
• 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) This method implements the SQL/MM specification. SQL-MM 3: 5.1.27
• ST_IsClosed - Returns TRUE if the LINESTRING’s start and end points are coincident. For Polyhedral surface is closed
(volumetric). This method implements the SQL/MM specification. SQL-MM 3: 7.1.5, 9.3.3
• ST_IsEmpty - Returns true if this Geometry is an empty geometrycollection, polygon, point etc. This method implements the
SQL/MM specification. SQL-MM 3: 5.1.7
• ST_IsRing - Returns TRUE if this LINESTRING is both closed and simple. This method implements the SQL/MM specification.
SQL-MM 3: 7.1.6
• ST_IsSimple - Returns (TRUE) if this Geometry has no anomalous geometric points, such as self intersection or self tangency.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.8
• ST_IsValid - Returns true if the ST_Geometry is well formed. This method implements the SQL/MM specification. SQL-MM
3: 5.1.9
• 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) This method implements the SQL/MM specification. SQL-MM 3:
7.1.2, 9.3.4
• ST_LineFromText - Makes a Geometry from WKT representation with the given SRID. If SRID is not given, it defaults to 0.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.8
• ST_LineFromWKB - Makes a LINESTRING from WKB with the given SRID This method implements the SQL/MM specification.
SQL-MM 3: 7.2.9
• ST_LinestringFromWKB - Makes a geometry from WKB with the given SRID. This method implements the SQL/MM specification.
SQL-MM 3: 7.2.9
• ST_M - Return the M coordinate of the point, or NULL if not available. Input must be a point. This method implements the
SQL/MM specification.
• ST_MLineFromText - Return a specified ST_MultiLineString value from WKT representation. This method implements the
SQL/MM specification.SQL-MM 3: 9.4.4
• ST_MPointFromText - Makes a Geometry from WKT with the given SRID. If SRID is not given, it defaults to 0. This method
implements the SQL/MM specification. SQL-MM 3: 9.2.4
• ST_MPolyFromText - Makes a MultiPolygon Geometry from WKT with the given SRID. If SRID is not given, it defaults to
0. This method implements the SQL/MM specification. SQL-MM 3: 9.6.4
• ST_ModEdgeHeal - Heal two edges by deleting the node connecting them, modifying the first edgeand deleting the second
edge. Returns the id of the deleted node. This method implements the SQL/MM specification. SQL-MM: Topo-Geo and
Topo-Net 3: Routine Details: X.3.9
• ST_ModEdgeSplit - Split an edge by creating a new node along an existing edge, modifying the original edge and adding a
new edge. This method implements the SQL/MM specification. SQL-MM: Topo-Geo and Topo-Net 3: Routine Details: X.3.9
PostGIS 2.5.3dev Manual 740 / 846
• ST_MoveIsoNode - Moves an isolated node in a topology from one point to another. If new apoint geometry exists as a node
an error is thrown. Returns description of move. This method implements the SQL/MM specification. SQL-MM: Topo-Net
Routines: X.3.2
• ST_NewEdgeHeal - Heal two edges by deleting the node connecting them, deleting both edges,and replacing them with an
edge whose direction is the same as the firstedge provided. This method implements the SQL/MM specification. SQL-MM:
Topo-Geo and Topo-Net 3: Routine Details: X.3.9
• ST_NewEdgesSplit - Split an edge by creating a new node along an existing edge, deleting the original edge and replacing it
with two new edges. Returns the id of the new node created that joins the new edges. This method implements the SQL/MM
specification. SQL-MM: Topo-Net Routines: X.3.8
• ST_NumGeometries - If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the number of geometries, for single
geometries will return 1, otherwise return NULL. This method implements the SQL/MM specification. SQL-MM 3: 9.1.4
• ST_NumInteriorRings - Return the number of interior rings of a polygon geometry. This method implements the SQL/MM
specification. SQL-MM 3: 8.2.5
• ST_NumPatches - Return the number of faces on a Polyhedral Surface. Will return null for non-polyhedral geometries. This
method implements the SQL/MM specification. SQL-MM 3: ?
• ST_NumPoints - Return the number of points in an ST_LineString or ST_CircularString value. This method implements the
SQL/MM specification. SQL-MM 3: 7.2.4
• ST_OrderingEquals - Returns true if the given geometries represent the same geometry and points are in the same directional
order. This method implements the SQL/MM specification. SQL-MM 3: 5.1.43
• ST_Overlaps - Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by
each other. This method implements the SQL/MM specification. SQL-MM 3: 5.1.32
• ST_PatchN - Return the 1-based Nth geometry (face) if the geometry is a POLYHEDRALSURFACE, POLYHEDRALSURFACEM.
Otherwise, return NULL. This method implements the SQL/MM specification. SQL-MM 3: ?
• 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. This method
implements the SQL/MM specification. SQL-MM 3: 8.1.3, 9.5.4
• ST_Point - Returns an ST_Point with the given coordinate values. OGC alias for ST_MakePoint. This method implements the
SQL/MM specification. SQL-MM 3: 6.1.2
• ST_PointFromText - Makes a point Geometry from WKT with the given SRID. If SRID is not given, it defaults to unknown.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.8
• ST_PointFromWKB - Makes a geometry from WKB with the given SRID This method implements the SQL/MM specification.
SQL-MM 3: 6.1.9
• ST_PointN - Return the Nth point in the first LineString or circular LineString in the geometry. Negative values are counted
backwards from the end of the LineString. Returns NULL if there is no linestring in the geometry. This method implements
the SQL/MM specification. SQL-MM 3: 7.2.5, 7.3.5
• ST_PointOnSurface - Returns a POINT guaranteed to lie on the surface. This method implements the SQL/MM specification.
SQL-MM 3: 8.1.5, 9.5.6. According to the specs, ST_PointOnSurface works for surface geometries (POLYGONs,
MULTIPOLYGONS, CURVED POLYGONS). So PostGIS seems to be extending what the spec allows here. Most databases
Oracle,DB II, ESRI SDE seem to only support this function for surfaces. SQL Server 2008 like PostGIS supports for all
common geometries.
• ST_Polygon - Returns a polygon built from the specified linestring and SRID. This method implements the SQL/MM specification.
SQL-MM 3: 8.3.2
• ST_PolygonFromText - Makes a Geometry from WKT with the given SRID. If SRID is not given, it defaults to 0. This method
implements the SQL/MM specification. SQL-MM 3: 8.3.6
PostGIS 2.5.3dev Manual 741 / 846
• ST_Relate - Returns true if this Geometry is spatially related to anotherGeometry, by testing for intersections between the
Interior, Boundary and Exterior of the two geometries as specified by the values in the intersectionMatrixPattern. If no intersectionMatrixPattern
is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.25
• ST_RemEdgeModFace - Removes an edge and, if the removed edge separated two faces,delete one of the them and modify
the other to take the space of both. This method implements the SQL/MM specification. SQL-MM: Topo-Geo and Topo-Net
3: Routine Details: X.3.15
• ST_RemEdgeNewFace - Removes an edge and, if the removed edge separated two faces,delete the original faces and replace
them with a new face. This method implements the SQL/MM specification. SQL-MM: Topo-Geo and Topo-Net 3: Routine
Details: X.3.14
• ST_RemoveIsoEdge - Removes an isolated edge and returns description of action. If the edge is not isolated, then an exception
is thrown. This method implements the SQL/MM specification. SQL-MM: Topo-Geo and Topo-Net 3: Routine Details:
X+1.3.3
• ST_RemoveIsoNode - Removes an isolated node and returns description of action. If the node is not isolated (is start or end
of an edge), then an exception is thrown. This method implements the SQL/MM specification. SQL-MM: Topo-Geo and
Topo-Net 3: Routine Details: X+1.3.3
• ST_SRID - Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table. This method
implements the SQL/MM specification. SQL-MM 3: 5.1.5
• ST_StartPoint - Returns the first point of a LINESTRING geometry as a POINT. This method implements the SQL/MM
specification. SQL-MM 3: 7.1.3
• 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). This method implements the SQL/MM specification.
SQL-MM 3: 5.1.21
• ST_Touches - Returns TRUE if the geometries have at least one point in common, but their interiors do not intersect. This
method implements the SQL/MM specification. SQL-MM 3: 5.1.28
• ST_Transform - Return a new geometry with its coordinates transformed to a different spatial reference. This method implements
the SQL/MM specification. SQL-MM 3: 5.1.6
• ST_Union - Returns a geometry that represents the point set union of the Geometries. This method implements the SQL/MM
specification. SQL-MM 3: 5.1.19 the z-index (elevation) when polygons are involved.
• ST_WKBToSQL - Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias
name for ST_GeomFromWKB that takes no srid This method implements the SQL/MM specification. SQL-MM 3: 5.1.36
• ST_WKTToSQL - Return a specified ST_Geometry value fromWell-Known Text representation (WKT). This is an alias name
for ST_GeomFromText This method implements the SQL/MM specification. SQL-MM 3: 5.1.34
• ST_Within - Returns true if the geometry A is completely inside geometry B This method implements the SQL/MM specification.
SQL-MM 3: 5.1.30
• ST_X - Return the X coordinate of the point, or NULL if not available. Input must be a point. This method implements the
SQL/MM specification. SQL-MM 3: 6.1.3
• ST_Y - Return the Y coordinate of the point, or NULL if not available. Input must be a point. This method implements the
SQL/MM specification. SQL-MM 3: 6.1.4
• ST_Z - Return the Z coordinate of the point, or NULL if not available. Input must be a point. This method implements the
SQL/MM specification.
PostGIS 2.5.3dev Manual 742 / 846
14.4 PostGIS Geography Support Functions
The functions and operators given below are PostGIS functions/operators that take as input or return as output a geography data
type object.
Note
Functions with a (T) are not native geodetic functions, and use a ST_Transform call to and from geometry to do the
operation. As a result, they may not behave as expected when going over dateline, poles, and for large geometries or
geometry pairs that cover more than one UTM zone. Basic transform - (favoring UTM, Lambert Azimuthal (North/South),
and falling back on mercator in worst case scenario)
• ST_Area - Returns the area of the surface if it is a Polygon or MultiPolygon. For geometry, a 2D Cartesian area is determined
with units specified by the SRID. For geography, area is determined on a curved surface with units in square meters.
• ST_AsBinary - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
• ST_AsEWKT - Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.
• ST_AsGML - Return the geometry as a GML version 2 or 3 element.
• ST_AsGeoJSON - Return the geometry as a GeoJSON element.
• ST_AsKML - Return the geometry as a KML element. Several variants. Default version=2, default maxdecimaldigits=15
• ST_AsSVG - Returns a Geometry in SVG path data given a geometry or geography object.
• ST_AsText - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
• ST_Azimuth - Returns the north-based azimuth as the angle in radians measured clockwise from the vertical on pointA to
pointB.
• ST_Buffer - (T)Returns a geometry covering all points within a given distancefrom the input geometry.
• ST_Centroid - Returns the geometric center of a geometry.
• ST_CoveredBy - Returns 1 (TRUE) if no point in Geometry/Geography A is outside Geometry/Geography B
• ST_Covers - Returns 1 (TRUE) if no point in Geometry B is outside Geometry A
• ST_DWithin - Returns true if the geometries are within the specified distance of one another. For geometry units are in those
of spatial reference and for geography units are in meters and measurement is defaulted to use_spheroid=true (measure around
spheroid), for faster check, use_spheroid=false to measure along sphere.
• ST_Distance - For geometry type returns the 2D Cartesian distance between two geometries in projected units (based on spatial
reference system). For geography type defaults to return minimum geodesic distance between two geographies in meters.
• ST_GeogFromText - Return a specified geography value from Well-Known Text representation or extended (WKT).
• ST_GeogFromWKB - Creates a geography instance from a Well-Known Binary geometry representation (WKB) or extended
Well Known Binary (EWKB).
• ST_GeographyFromText - Return a specified geography value from Well-Known Text representation or extended (WKT).
• = - Returns TRUE if the coordinates and coordinate order geometry/geography A are the same as the coordinates and coordinate
order of geometry/geography B.
• ST_Intersection - (T)Returns a geometry that represents the shared portion of geomA and geomB.
• 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)
PostGIS 2.5.3dev Manual 743 / 846
• 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)
• 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.
• ST_Project - Returns a POINT projected from a start point using a distance in meters and bearing (azimuth) in radians.
• ST_Segmentize - Return a modified geometry/geography having no segment longer than the given distance.
• ST_Summary - Returns a text summary of the contents of the geometry.
• <-> - Returns the 2D distance between A and B.
• && - Returns TRUE if A’s 2D bounding box intersects B’s 2D bounding box.
14.5 PostGIS Raster Support Functions
The functions and operators given below are PostGIS functions/operators that take as input or return as output a raster data type
object. Listed in alphabetical order.
• Box3D - Returns the box 3d representation of the enclosing box of the raster.
• @ - Returns TRUE if A’s bounding box is contained by B’s. Uses double precision bounding box.
• ~ - Returns TRUE if A’s bounding box is contains B’s. Uses double precision bounding box.
• = - Returns TRUE if A’s bounding box is the same as B’s. Uses double precision bounding box.
• && - Returns TRUE if A’s bounding box intersects B’s bounding box.
• &< - Returns TRUE if A’s bounding box is to the left of B’s.
• &> - Returns TRUE if A’s bounding box is to the right of B’s.
• ~= - Returns TRUE if A’s bounding box is the same as B’s.
• ST_Retile - Return a set of configured tiles from an arbitrarily tiled raster coverage.
• ST_AddBand - Returns a raster with the new band(s) of given type added with given initial value in the given index location.
If no index is specified, the band is added to the end.
• ST_AsBinary/ST_AsWKB - Return the Well-Known Binary (WKB) representation of the raster.
• ST_AsGDALRaster - Return the raster tile in the designated GDAL Raster format. Raster formats are one of those supported
by your compiled library. Use ST_GDALDrivers() to get a list of formats supported by your library.
• ST_AsHexWKB - Return the Well-Known Binary (WKB) in Hex representation of the raster.
• ST_AsJPEG - Return the raster tile selected bands as a single Joint Photographic Exports Group (JPEG) image (byte array). If
no band is specified and 1 or more than 3 bands, then only the first band is used. If only 3 bands then all 3 bands are used and
mapped to RGB.
• ST_AsPNG - Return the raster tile selected bands as a single portable network graphics (PNG) image (byte array). If 1, 3, or
4 bands in raster and no bands are specified, then all bands are used. If more 2 or more than 4 bands and no bands specified,
then only band 1 is used. Bands are mapped to RGB or RGBA space.
• ST_AsRaster - Converts a PostGIS geometry to a PostGIS raster.
• ST_AsTIFF - Return the raster selected bands as a single TIFF image (byte array). If no band is specified or any of specified
bands does not exist in the raster, then will try to use all bands.
• ST_Aspect - Returns the aspect (in degrees by default) of an elevation raster band. Useful for analyzing terrain.
PostGIS 2.5.3dev Manual 744 / 846
• ST_Band - Returns one or more bands of an existing raster as a new raster. Useful for building new rasters from existing
rasters.
• ST_BandFileSize - Returns the file size of a band stored in file system. If no bandnum specified, 1 is assumed.
• ST_BandFileTimestamp - Returns the file timestamp of a band stored in file system. If no bandnum specified, 1 is assumed.
• ST_BandIsNoData - Returns true if the band is filled with only nodata values.
• ST_BandMetaData - Returns basic meta data for a specific raster band. band num 1 is assumed if none-specified.
• ST_BandNoDataValue - Returns the value in a given band that represents no data. If no band num 1 is assumed.
• ST_BandPath - Returns system file path to a band stored in file system. If no bandnum specified, 1 is assumed.
• ST_BandPixelType - Returns the type of pixel for given band. If no bandnum specified, 1 is assumed.
• ST_Clip - Returns the raster clipped by the input geometry. If band number not is specified, all bands are processed. If crop is
not specified or TRUE, the output raster is cropped.
• ST_ColorMap - Creates a new raster of up to four 8BUI bands (grayscale, RGB, RGBA) from the source raster and a specified
band. Band 1 is assumed if not specified.
• ST_Contains - Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of
rastB lies in the interior of rastA.
• ST_ContainsProperly - Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA.
• ST_ConvexHull - Return the convex hull geometry of the raster including pixel values equal to BandNoDataValue. For regular
shaped and non-skewed rasters, this gives the same result as ST_Envelope so only useful for irregularly shaped or skewed
rasters.
• ST_Count - Returns the number of pixels in a given band of a raster or raster coverage. If no band is specified defaults to band

  1. If exclude_nodata_value is set to true, will only count pixels that are not equal to the nodata value.
    • ST_CountAgg - Aggregate. Returns the number of pixels in a given band of a set of rasters. If no band is specified defaults to
    band 1. If exclude_nodata_value is set to true, will only count pixels that are not equal to the NODATA value.
    • ST_CoveredBy - Return true if no points of raster rastA lie outside raster rastB.
    • ST_Covers - Return true if no points of raster rastB lie outside raster rastA.
    • ST_DFullyWithin - Return true if rasters rastA and rastB are fully within the specified distance of each other.
    • ST_DWithin - Return true if rasters rastA and rastB are within the specified distance of each other.
    • ST_Disjoint - Return true if raster rastA does not spatially intersect rastB.
    • ST_DumpAsPolygons - Returns a set of geomval (geom,val) rows, from a given raster band. If no band number is specified,
    band num defaults to 1.
    • ST_DumpValues - Get the values of the specified band as a 2-dimension array.
    • ST_Envelope - Returns the polygon representation of the extent of the raster.
    • ST_FromGDALRaster - Returns a raster from a supported GDAL raster file.
    • ST_GeoReference - Returns the georeference meta data in GDAL or ESRI format as commonly seen in a world file. Default
    is GDAL.
    • ST_Grayscale - Creates a new one-8BUI band raster from the source raster and specified bands representing Red, Green and
    Blue
    • ST_HasNoBand - Returns true if there is no band with given band number. If no band number is specified, then band number
    1 is assumed.
    PostGIS 2.5.3dev Manual 745 / 846
    • ST_Height - Returns the height of the raster in pixels.
    • ST_HillShade - Returns the hypothetical illumination of an elevation raster band using provided azimuth, altitude, brightness
    and scale inputs.
    • ST_Histogram - Returns a set of record summarizing a raster or raster coverage data distribution separate bin ranges. Number
    of bins are autocomputed if not specified.
    • ST_Intersection - Returns a raster or a set of geometry-pixelvalue pairs representing the shared portion of two rasters or the
    geometrical intersection of a vectorization of the raster and a geometry.
    • ST_Intersects - Return true if raster rastA spatially intersects raster rastB.
    • ST_IsEmpty - Returns true if the raster is empty (width = 0 and height = 0). Otherwise, returns false.
    • ST_MakeEmptyCoverage - Cover georeferenced area with a grid of empty raster tiles.
    • ST_MakeEmptyRaster - Returns an empty raster (having no bands) of given dimensions (width & height), upperleft X and Y,
    pixel size and rotation (scalex, scaley, skewx & skewy) and reference system (srid). If a raster is passed in, returns a new raster
    with the same size, alignment and SRID. If srid is left out, the spatial ref is set to unknown (0).
    • ST_MapAlgebra (callback function version) - Callback function version - Returns a one-band raster given one or more input
    rasters, band indexes and one user-specified callback function.
    • ST_MapAlgebraExpr - 1 raster band version: Creates a new one band raster formed by applying a valid PostgreSQL algebraic
    operation on the input raster band and of pixeltype provided. Band 1 is assumed if no band is specified.
    • ST_MapAlgebraExpr - 2 raster band version: Creates a new one band raster formed by applying a valid PostgreSQL algebraic
    operation on the two input raster bands and of pixeltype provided. band 1 of each raster is assumed if no band numbers are
    specified. The resulting raster will be aligned (scale, skew and pixel corners) on the grid defined by the first raster and have its
    extent defined by the “extenttype” parameter. Values for “extenttype” can be: INTERSECTION, UNION, FIRST, SECOND.
    • ST_MapAlgebraFct - 1 band version - Creates a new one band raster formed by applying a valid PostgreSQL function on the
    input raster band and of pixeltype prodived. Band 1 is assumed if no band is specified.
    • ST_MapAlgebraFct - 2 band version - Creates a new one band raster formed by applying a valid PostgreSQL function on the
    2 input raster bands and of pixeltype prodived. Band 1 is assumed if no band is specified. Extent type defaults to INTERSECTION
    if not specified.
    • ST_MapAlgebraFctNgb - 1-band version: Map Algebra Nearest Neighbor using user-defined PostgreSQL function. Return a
    raster which values are the result of a PLPGSQL user function involving a neighborhood of values from the input raster band.
    • ST_MapAlgebra (expression version) - Expression version - Returns a one-band raster given one or two input rasters, band
    indexes and one or more user-specified SQL expressions.
    • ST_MemSize - Returns the amount of space (in bytes) the raster takes.
    • ST_MetaData - Returns basic meta data about a raster object such as pixel size, rotation (skew), upper, lower left, etc.
    • ST_MinConvexHull - Return the convex hull geometry of the raster excluding NODATA pixels.
    • ST_NearestValue - Returns the nearest non-NODATA value of a given band’s pixel specified by a columnx and rowy or a
    geometric point expressed in the same spatial reference coordinate system as the raster.
    • ST_Neighborhood - Returns a 2-D double precision array of the non-NODATA values around a given band’s pixel specified
    by either a columnX and rowY or a geometric point expressed in the same spatial reference coordinate system as the raster.
    • ST_NotSameAlignmentReason - Returns text stating if rasters are aligned and if not aligned, a reason why.
    • ST_NumBands - Returns the number of bands in the raster object.
    • ST_Overlaps - Return true if raster rastA and rastB intersect but one does not completely contain the other.
    • ST_PixelAsCentroid - Returns the centroid (point geometry) of the area represented by a pixel.
    PostGIS 2.5.3dev Manual 746 / 846
    • ST_PixelAsCentroids - Returns the centroid (point geometry) for each pixel of a raster band along with the value, the X and
    the Y raster coordinates of each pixel. The point geometry is the centroid of the area represented by a pixel.
    • ST_PixelAsPoint - Returns a point geometry of the pixel’s upper-left corner.
    • ST_PixelAsPoints - Returns a point geometry for each pixel of a raster band along with the value, the X and the Y raster
    coordinates of each pixel. The coordinates of the point geometry are of the pixel’s upper-left corner.
    • ST_PixelAsPolygon - Returns the polygon geometry that bounds the pixel for a particular row and column.
    • ST_PixelAsPolygons - Returns the polygon geometry that bounds every pixel of a raster band along with the value, the X and
    the Y raster coordinates of each pixel.
    • ST_PixelHeight - Returns the pixel height in geometric units of the spatial reference system.
    • ST_PixelOfValue - Get the columnx, rowy coordinates of the pixel whose value equals the search value.
    • ST_PixelWidth - Returns the pixel width in geometric units of the spatial reference system.
    • ST_Polygon - Returns a multipolygon geometry formed by the union of pixels that have a pixel value that is not no data value.
    If no band number is specified, band num defaults to 1.
    • ST_Quantile - Compute quantiles for a raster or raster table coverage in the context of the sample or population. Thus, a value
    could be examined to be at the raster’s 25%, 50%, 75% percentile.
    • ST_RastFromHexWKB - Return a raster value from a Hex representation of Well-Known Binary (WKB) raster.
    • ST_RastFromWKB - Return a raster value from a Well-Known Binary (WKB) raster.
    • ST_RasterToWorldCoord - Returns the raster’s upper left corner as geometric X and Y (longitude and latitude) given a column
    and row. Column and row starts at 1.
    • ST_RasterToWorldCoordX - Returns the geometric X coordinate upper left of a raster, column and row. Numbering of columns
    and rows starts at 1.
    • ST_RasterToWorldCoordY - Returns the geometric Y coordinate upper left corner of a raster, column and row. Numbering of
    columns and rows starts at 1.
    • ST_Reclass - Creates a new raster composed of band types reclassified from original. The nband is the band to be changed. If
    nband is not specified assumed to be 1. All other bands are returned unchanged. Use case: convert a 16BUI band to a 8BUI
    and so forth for simpler rendering as viewable formats.
    • ST_Resample - Resample a raster using a specified resampling algorithm, new dimensions, an arbitrary grid corner and a set
    of raster georeferencing attributes defined or borrowed from another raster.
    • ST_Rescale - Resample a raster by adjusting only its scale (or pixel size). New pixel values are computed using the Nearest-
    Neighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is Nearest-
    Neighbor.
    • ST_Resize - Resize a raster to a new width/height
    • ST_Reskew - Resample a raster by adjusting only its skew (or rotation parameters). New pixel values are computed using the
    NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is
    NearestNeighbor.
    • ST_Rotation - Returns the rotation of the raster in radian.
    • ST_Roughness - Returns a raster with the calculated “roughness” of a DEM.
    • ST_SRID - Returns the spatial reference identifier of the raster as defined in spatial_ref_sys table.
    • ST_SameAlignment - Returns true if rasters have same skew, scale, spatial ref, and offset (pixels can be put on same grid
    without cutting into pixels) and false if they don’t with notice detailing issue.
    • ST_ScaleX - Returns the X component of the pixel width in units of coordinate reference system.
    PostGIS 2.5.3dev Manual 747 / 846
    • ST_ScaleY - Returns the Y component of the pixel height in units of coordinate reference system.
    • ST_SetBandIndex - Update the external band number of an out-db band
    • ST_SetBandIsNoData - Sets the isnodata flag of the band to TRUE.
    • ST_SetBandNoDataValue - Sets the value for the given band that represents no data. Band 1 is assumed if no band is specified.
    To mark a band as having no nodata value, set the nodata value = NULL.
    • ST_SetBandPath - Update the external path and band number of an out-db band
    • ST_SetGeoReference - Set Georeference 6 georeference parameters in a single call. Numbers should be separated by white
    space. Accepts inputs in GDAL or ESRI format. Default is GDAL.
    • ST_SetRotation - Set the rotation of the raster in radian.
    • ST_SetSRID - Sets the SRID of a raster to a particular integer srid defined in the spatial_ref_sys table.
    • ST_SetScale - Sets the X and Y size of pixels in units of coordinate reference system. Number units/pixel width/height.
    • ST_SetSkew - Sets the georeference X and Y skew (or rotation parameter). If only one is passed in, sets X and Y to the same
    value.
    • ST_SetUpperLeft - Sets the value of the upper left corner of the pixel of the raster to projected X and Y coordinates.
    • ST_SetValue - Returns modified raster resulting from setting the value of a given band in a given columnx, rowy pixel or the
    pixels that intersect a particular geometry. Band numbers start at 1 and assumed to be 1 if not specified.
    • ST_SetValues - Returns modified raster resulting from setting the values of a given band.
    • ST_SkewX - Returns the georeference X skew (or rotation parameter).
    • ST_SkewY - Returns the georeference Y skew (or rotation parameter).
    • ST_Slope - Returns the slope (in degrees by default) of an elevation raster band. Useful for analyzing terrain.
    • ST_SnapToGrid - Resample a raster by snapping it to a grid. New pixel values are computed using the NearestNeighbor
    (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor.
    • ST_Summary - Returns a text summary of the contents of the raster.
    • ST_SummaryStats - Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster band of a raster
    or raster coverage. Band 1 is assumed is no band is specified.
    • ST_SummaryStatsAgg - Aggregate. Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster
    band of a set of raster. Band 1 is assumed is no band is specified.
    • ST_TPI - Returns a raster with the calculated Topographic Position Index.
    • ST_TRI - Returns a raster with the calculated Terrain Ruggedness Index.
    • ST_Tile - Returns a set of rasters resulting from the split of the input raster based upon the desired dimensions of the output
    rasters.
    • ST_Touches - Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect.
    • ST_Transform - Reprojects a raster in a known spatial reference system to another known spatial reference system using
    specified resampling algorithm. Options are NearestNeighbor, Bilinear, Cubic, CubicSpline, Lanczos defaulting to Nearest-
    Neighbor.
    • ST_Union - Returns the union of a set of raster tiles into a single raster composed of 1 or more bands.
    • ST_UpperLeftX - Returns the upper left X coordinate of raster in projected spatial ref.
    • ST_UpperLeftY - Returns the upper left Y coordinate of raster in projected spatial ref.
    PostGIS 2.5.3dev Manual 748 / 846
    • ST_Value - Returns the value of a given band in a given columnx, rowy pixel or at a particular geometric point. Band numbers
    start at 1 and assumed to be 1 if not specified. If exclude_nodata_value is set to false, then all pixels include nodata pixels are
    considered to intersect and return value. If exclude_nodata_value is not passed in then reads it from metadata of raster.
    • ST_ValueCount - Returns a set of records containing a pixel band value and count of the number of pixels in a given band of a
    raster (or a raster coverage) that have a given set of values. If no band is specified defaults to band 1. By default nodata value
    pixels are not counted. and all other values in the pixel are output and pixel band values are rounded to the nearest integer.
    • ST_Width - Returns the width of the raster in pixels.
    • ST_Within - Return true if no points of raster rastA lie in the exterior of raster rastB and at least one point of the interior of
    rastA lies in the interior of rastB.
    • ST_WorldToRasterCoord - Returns the upper left corner as column and row given geometric X and Y (longitude and latitude)
    or a point geometry expressed in the spatial reference coordinate system of the raster.
    • ST_WorldToRasterCoordX - Returns the column in the raster of the point geometry (pt) or a X and Y world coordinate (xw,
    yw) represented in world spatial reference system of raster.
    • ST_WorldToRasterCoordY - Returns the row in the raster of the point geometry (pt) or a X and Y world coordinate (xw, yw)
    represented in world spatial reference system of raster.
    • UpdateRasterSRID - Change the SRID of all rasters in the user-specified column and table.
    14.6 PostGIS Geometry / Geography / Raster Dump Functions
    The functions given below are PostGIS functions that take as input or return as output a set of or single geometry_dump or
    geomval data type object.
    • ST_DumpAsPolygons - Returns a set of geomval (geom,val) rows, from a given raster band. If no band number is specified,
    band num defaults to 1.
    • ST_Intersection - Returns a raster or a set of geometry-pixelvalue pairs representing the shared portion of two rasters or the
    geometrical intersection of a vectorization of the raster and a geometry.
    • ST_Dump - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.
    • ST_DumpPoints - Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.
    • ST_DumpRings - Returns a set of geometry_dump rows, representing the exterior and interior rings of a polygon.

你可能感兴趣的:(postgis,postgis函数)