Geometry Output These functions convert geometry objects into various textual or binary formats.
Well-Known Text (WKT) ST_AsEWKT Return the Well-Known Text (WKT) representation of the geometry with SRID meta data. text ST_AsEWKT geometry g1 text ST_AsEWKT geometry g1 integer maxdecimaldigits=15 text ST_AsEWKT geography g1 text ST_AsEWKT geography g1 integer maxdecimaldigits=15 Description Returns the Well-Known Text representation of the geometry prefixed with the SRID. The optional maxdecimaldigits argument may be used to reduce the maximum number of decimal digits after floating point used in output (defaults to 15). To perform the inverse conversion of EWKT representation to PostGIS geometry use . Using the maxdecimaldigits parameter can cause output geometry to become invalid. To avoid this use with a suitable gridsize first. The WKT spec does not include the SRID. To get the OGC WKT format use . WKT format does not maintain precision so to prevent floating truncation, use or format for transport. Enhanced: 3.1.0 support for optional precision parameter. Enhanced: 2.0.0 support for Geography, Polyhedral surfaces, Triangles and TIN was introduced. &Z_support; &curve_support; &P_support; &T_support; Examples SELECT ST_AsEWKT('0103000020e61000000100000005000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f000000000000f03f000000000000000000000000000000000000000000000000'::geometry); SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0)) SELECT ST_AsEWKT('0108000080030000000000000060E30A4100000000785C0241000000000000F03F0000000018E20A4100000000485F024100000000000000400000000018E20A4100000000305C02410000000000000840'); CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3) See Also , , , ST_AsText Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata. text ST_AsText geometry g1 text ST_AsText geometry g1 integer maxdecimaldigits = 15 text ST_AsText geography g1 text ST_AsText geography g1 integer maxdecimaldigits = 15 Description Returns the OGC Well-Known Text (WKT) representation of the geometry/geography. The optional maxdecimaldigits argument may be used to limit the number of digits after the decimal point in output ordinates (defaults to 15). To perform the inverse conversion of WKT representation to PostGIS geometry use . The standard OGC WKT representation does not include the SRID. To include the SRID as part of the output representation, use the non-standard PostGIS function The textual representation of numbers in WKT may not maintain full floating-point precision. To ensure full accuracy for data storage or transport it is best to use Well-Known Binary (WKB) format (see and maxdecimaldigits). Using the maxdecimaldigits parameter can cause output geometry to become invalid. To avoid this use with a suitable gridsize first. Availability: 1.5 - support for geography was introduced. Enhanced: 2.5 - optional parameter precision introduced. &sfs_compliant; s2.1.1.1 &sqlmm_compliant; SQL-MM 3: 5.1.25 &curve_support; Examples SELECT ST_AsText('01030000000100000005000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f000000000000f03f000000000000000000000000000000000000000000000000'); POLYGON((0 0,0 1,1 1,1 0,0 0)) Full precision output is the default. SELECT ST_AsText('POINT(111.1111111 1.1111111)'::geometry); POINT(111.1111111 1.1111111) The maxdecimaldigits argument can be used to limit output precision. SELECT ST_AsText('POINT(111.1111111 1.1111111)'::geometry, 2); POINT(111.11 1.11) See Also , , ,
Well-Known Binary (WKB) ST_AsBinary Return the OGC/ISO Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data. bytea ST_AsBinary geometry g1 bytea ST_AsBinary geometry g1 text NDR_or_XDR bytea ST_AsBinary geography g1 bytea ST_AsBinary geography g1 text NDR_or_XDR Description Returns the OGC/ISO Well-Known Binary (WKB) representation of the geometry. The first function variant defaults to encoding using server machine endian. The second function variant takes a text argument specifying the endian encoding: either 'NDR' for little-endian; or 'XDR' for big-endian. Supplying unknown arguments will result in little-endian output. WKB format is useful to read geometry data from the database and maintaining full numeric precision. This avoids the precision rounding that can happen with text formats such as WKT. To perform the inverse conversion of WKB to PostGIS geometry use . The OGC/ISO WKB format does not include the SRID. To get the EWKB format which does include the SRID use PostgreSQL outputs bytea values in hex encoding by default. If your GUI tools require the old behavior, then SET bytea_output='escape' in your database. Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced. Enhanced: 2.0.0 support for higher coordinate dimensions was introduced. Enhanced: 2.0.0 support for specifying endian with geography was introduced. Availability: 1.5.0 geography support was introduced. Changed: 2.0.0 Inputs to this function can not be unknown -- must be geometry. Constructs such as ST_AsBinary('POINT(1 2)') are no longer valid and you will get an n ST_AsBinary(unknown) is not unique error. Code like that needs to be changed to ST_AsBinary('POINT(1 2)'::geometry);. If that is not possible, then install legacy.sql. &sfs_compliant; s2.1.1.1 &sqlmm_compliant; SQL-MM 3: 5.1.37 &curve_support; &P_support; &T_support; &Z_support; Examples SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326)); \x01030000000100000005000000000000000000000000000000000000000000000000000000000000 000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000000000000 00000000000000000000000000 SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326), 'XDR'); \x000000000300000001000000050000000000000000000000000000000000000000000000003ff000 00000000003ff00000000000003ff00000000000003ff00000000000000000000000000000000000 00000000000000000000000000 Use the PostgreSQL encode function to produce a hexadecimal WKB string without the \x prefix used for bytea display. Specifying NDR makes the byte order deterministic. SELECT encode( ST_AsBinary('POINT(15.123 21.456)'::geometry, 'NDR'), 'hex' ) AS wkb_hex; 0101000000e5d022dbf93e2e40dbf97e6abc743540 See Also , , , , ST_AsEWKB Return the Extended Well-Known Binary (EWKB) representation of the geometry with SRID meta data. bytea ST_AsEWKB geometry g1 bytea ST_AsEWKB geometry g1 text NDR_or_XDR Description Returns the Extended Well-Known Binary (EWKB) representation of the geometry with SRID metadata. The first function variant defaults to encoding using server machine endian. The second function variant takes a text argument specifying the endian encoding: either 'NDR' for little-endian; or 'XDR' for big-endian. Supplying unknown arguments will result in little-endian output. WKB format is useful to read geometry data from the database and maintaining full numeric precision. This avoids the precision rounding that can happen with text formats such as WKT. To perform the inverse conversion of EWKB to PostGIS geometry use . To get the OGC/ISO WKB format use . Note that OGC/ISO WKB format does not include the SRID. Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced. &Z_support; &curve_support; &P_support; &T_support; Examples SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326)); \x0103000020e610000001000000050000000000000000000000000000000000000000000000000000 00000000000000f03f000000000000f03f000000000000f03f000000000000f03f00000000000000 0000000000000000000000000000000000 SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326), 'XDR'); \x0020000003000010e600000001000000050000000000000000000000000000000000000000000000 003ff00000000000003ff00000000000003ff00000000000003ff000000000000000000000000000 0000000000000000000000000000000000 See Also , , ST_AsHEXEWKB Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding. text ST_AsHEXEWKB geometry g1 text NDRorXDR text ST_AsHEXEWKB geometry g1 Description Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding. If no encoding is specified, then NDR is used. Availability: 1.2.2 &Z_support; &curve_support; Examples SELECT ST_AsHEXEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326)); 0103000020E6100000010000000500 00000000000000000000000000000000 00000000000000000000000000000000F03F 000000000000F03F000000000000F03F000000000000F03 F000000000000000000000000000000000000000000000000 Which gives the same answer as: SELECT ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326)::text;
Other Formats ST_AsEncodedPolyline Returns an Encoded Polyline from a LineString geometry. text ST_AsEncodedPolyline geometry geom integer precision=5 Description Returns the geometry in the Encoded Polyline Algorithm Format. The format stores latitude and longitude deltas as integers after multiplying coordinates by 10 raised to the requested precision. The informal names polyline5 and polyline6 refer to the same encoding with precision 5 and 6. The precision must match when encoding and decoding; otherwise the coordinates are scaled incorrectly. The input geometry must use SRID 4326, with longitude as X and latitude as Y. Use to transform geometries in other coordinate systems before encoding. The OSRM API returns precision 5 for geometries=polyline and precision 6 for geometries=polyline6. Decode the resulting route.geometry with using the matching precision. Availability: 2.2.0 Examples Encode the same WGS 84 LineString using precision 5 and 6. polyline5 | polyline6 -----------------------------+---------------------------------- _p~iF~ps|U_ulLnnqC_mqNvxq`@ | _izlhA~rlgdF_{geC~ywl@_kwzCn`{nI Decode an OSRM route.geometry returned with geometries=polyline6. SRID=4326;LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252) The Google Maps JavaScript Geometry library decodes precision-5 strings. This browser example assumes that map is an initialized Google map. ]]> See Also , ST_AsFlatGeobuf Return a FlatGeobuf representation of a set of rows. bytea ST_AsFlatGeobuf anyelement set row bytea ST_AsFlatGeobuf anyelement row bool index bytea ST_AsFlatGeobuf anyelement row bool index text geom_name Description Return a FlatGeobuf representation (http://flatgeobuf.org) of a set of rows corresponding to a FeatureCollection. NOTE: PostgreSQL bytea cannot exceed 1GB. row row data with at least a geometry column. index toggle spatial index creation. Default is false. geom_name is the name of the geometry column in the row data. If NULL it will default to the first found geometry column. Availability: 3.2.0 ST_AsGeobuf Return a Geobuf representation of a set of rows. bytea ST_AsGeobuf anyelement set row bytea ST_AsGeobuf anyelement row text geom_name Description Return a Geobuf representation (https://github.com/mapbox/geobuf) of a set of rows corresponding to a FeatureCollection. Every input geometry is analyzed to determine maximum precision for optimal storage. Note that Geobuf in its current form cannot be streamed so the full output will be assembled in memory. row row data with at least a geometry column. geom_name is the name of the geometry column in the row data. If NULL it will default to the first found geometry column. Availability: 2.4.0 Examples SELECT encode(ST_AsGeobuf(q, 'geom'), 'base64') FROM (SELECT 'POLYGON((0 0,0 1,1 1,1 0,0 0))'::geometry AS geom) AS q; GAAiEAoOCgwIBBoIAAAAAgIAAAE= ST_AsGeoJSON Return a geometry or feature in GeoJSON format. text ST_AsGeoJSON record feature text geom_column="" integer maxdecimaldigits=9 boolean pretty_bool=false text id_column='' text ST_AsGeoJSON geometry geom integer maxdecimaldigits=9 integer options=8 text ST_AsGeoJSON geography geog integer maxdecimaldigits=9 integer options=0 Description Returns a geometry as a GeoJSON "geometry" object, or a row as a GeoJSON "feature" object. The resulting GeoJSON geometry and feature representations conform with the GeoJSON specifications RFC 7946, except when the parsed geometries are referenced with a CRS other than WGS84 longitude and latitude (EPSG:4326, urn:ogc:def:crs:OGC::CRS84); the GeoJSON geometry object will then have a short CRS SRID identifier attached by default. 2D and 3D Geometries are both supported. GeoJSON only supports SFS 1.1 geometry types (no curve support for example). The geom_column parameter is used to distinguish between multiple geometry columns. If omitted, the first geometry column in the record will be determined. Conversely, passing the parameter will save column type lookups. The maxdecimaldigits argument may be used to reduce the maximum number of decimal places used in output (defaults to 9). If you are using EPSG:4326 and are outputting the geometry only for display, maxdecimaldigits=6 can be a good choice for many maps. Using the maxdecimaldigits parameter can cause output geometry to become invalid. To avoid this use with a suitable gridsize first. The options argument can be used to add BBOX or CRS in GeoJSON output: 0: means no option 1: GeoJSON BBOX 2: GeoJSON Short CRS (e.g EPSG:4326) 4: GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326) 8: GeoJSON Short CRS if not EPSG:4326 (default) The id_column parameter is used to set the "id" member of the returned GeoJSON features. As per GeoJSON RFC, this SHOULD be used whenever a feature has a commonly used identifier, such as a primary key. When not specified, the produced features will not get an "id" member and any columns other than the geometry, including any potential keys, will just end up inside the feature’s "properties" member. When the input record includes duplicate column names, the resulting "properties" object will contain repeated keys. ST_AsGeoJSON raises a warning in that case because PostgreSQL jsonb keeps only the last value for duplicate keys. The GeoJSON specification states that polygons are oriented using the Right-Hand Rule, and some clients require this orientation. This can be ensured by using . The specification also requires that geometry be in the WGS84 coordinate system (SRID = 4326). If necessary geometry can be projected into WGS84 using : ST_Transform(geom, 4326 ). GeoJSON can be tested and viewed online at geojson.io and geojsonlint.com. It is widely supported by web mapping frameworks: OpenLayers GeoJSON Example Leaflet GeoJSON Example Mapbox GL GeoJSON Example Availability: 1.3.4 Availability: 1.5.0 geography support was introduced. Changed: 2.0.0 support default args and named args. Changed: 3.0.0 support records as input Changed: 3.0.0 output SRID if not EPSG:4326. Changed: 3.5.0 allow specifying the column containing the feature id Changed: 3.7.0 added warning about duplicate keys &Z_support; Examples Generate a FeatureCollection: SELECT json_build_object( 'type', 'FeatureCollection', 'features', json_agg(ST_AsGeoJSON(t.*, id_column => 'id')::json) ) FROM ( VALUES (1, 'one', 'POINT(1 1)'::geometry), (2, 'two', 'POINT(2 2)'), (3, 'three', 'POINT(3 3)') ) as t(id, name, geom); {"type" : "FeatureCollection", "features" : [{"type": "Feature", "geometry": {"type":"Point","coordinates":[1,1]}, "id": 1, "properties": {"name": "one"}}, {"type": "Feature", "geometry": {"type":"Point","coordinates":[2,2]}, "id": 2, "properties": {"name": "two"}}, {"type": "Feature", "geometry": {"type":"Point","coordinates":[3,3]}, "id": 3, "properties": {"name": "three"}}]} Generate a Feature: SELECT ST_AsGeoJSON(t.*, id_column => 'id') FROM (VALUES (1, 'one', 'POINT(1 1)'::geometry)) AS t(id, name, geom); {"type": "Feature", "geometry": {"type":"Point","coordinates":[1,1]}, "id": 1, "properties": {"name": "one"}} Don't forget to transform your data to WGS84 longitude, latitude to conform with the GeoJSON specification: SELECT ST_AsGeoJSON(ST_Transform(geom, 4326)) FROM fe_edges LIMIT 1; {"type":"MultiLineString","coordinates":[[[-89.734634999999997,31.492072000000000], [-89.734955999999997,31.492237999999997]]]} 3D geometries are supported: SELECT ST_AsGeoJSON('LINESTRING(1 2 3,4 5 6)'); {"type":"LineString","coordinates":[[1,2,3],[4,5,6]]} Options argument can be used to add BBOX and CRS in GeoJSON output: SELECT ST_AsGeoJSON(ST_SetSRID('POINT(1 1)'::geometry, 4326), 9, 4|1); {"type":"Point","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::4326"}},"bbox":[1.000000000,1.000000000,1.000000000,1.000000000],"coordinates":[1,1]} See Also , , ST_AsGML Return the geometry as a GML version 2 or 3 element. text ST_AsGML geometry geom integer maxdecimaldigits=15 integer options=0 text ST_AsGML geography geog integer maxdecimaldigits=15 integer options=0 text nprefix=null text id=null text ST_AsGML integer version geometry geom integer maxdecimaldigits=15 integer options=0 text nprefix=null text id=null text ST_AsGML integer version geography geog integer maxdecimaldigits=15 integer options=0 text nprefix=null text id=null Description Return the geometry as a Geography Markup Language (GML) element. The version parameter, if specified, may be either 2 or 3. If no version parameter is specified then the default is assumed to be 2. The maxdecimaldigits argument may be used to reduce the maximum number of decimal places used in output (defaults to 15). Using the maxdecimaldigits parameter can cause output geometry to become invalid. To avoid this use with a suitable gridsize first. GML 2 refer to 2.1.2 version, GML 3 to 3.1.1 version The 'options' argument is a bitfield. It could be used to define CRS output type in GML output, and to declare data as lat/lon: 0: GML Short CRS (e.g EPSG:4326), default value 1: GML Long CRS (e.g urn:ogc:def:crs:EPSG::4326) 2: For GML 3 only, remove srsDimension attribute from output. 4: For GML 3 only, use <LineString> rather than <Curve> tag for lines. 16: Declare that data are lat/lon (e.g srid=4326). Default is to assume that data are planars. This option is useful for GML 3.1.1 output only, related to axis order. So if you set it, it will swap the coordinates so order is lat lon instead of database lon lat. 32: Output the box of the geometry (envelope). The 'namespace prefix' argument may be used to specify a custom namespace prefix or no prefix (if empty). If null or omitted 'gml' prefix is used Availability: 1.3.2 Availability: 1.5.0 geography support was introduced. Enhanced: 2.0.0 prefix support was introduced. Option 4 for GML3 was introduced to allow using LineString instead of Curve tag for lines. GML3 Support for Polyhedral surfaces and TINS was introduced. Option 32 was introduced to output the box. Changed: 2.0.0 use default named args Enhanced: 2.1.0 id support was introduced, for GML 3. Only version 3+ of ST_AsGML supports Polyhedral Surfaces and TINS. &sqlmm_compliant; SQL-MM IEC 13249-3: 17.2 &Z_support; &P_support; &T_support; Examples Version 2. SELECT ST_AsGML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326)); 0,0 0,1 1,1 1,0 0,0]]> Version 3. Flip coordinates and output extended EPSG (16 | 1) SELECT ST_AsGML(3, ST_GeomFromText('POINT(5.234234233242 6.34534534534)', 4326), 5, 17); 6.34535 5.23423]]> Output the envelope (32). 1 210 20]]> Output the envelope (32), reverse (lat lon instead of lon lat) (16), long srs (1) = 32 | 16 | 1 = 49. 2 120 10]]> This example uses a PolyhedralSurface. 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 0 0 1 1 1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 0 0 1 ]]> See Also ST_AsKML Return the geometry as a KML element. text ST_AsKML geometry geom integer maxdecimaldigits=15 text nprefix=NULL text ST_AsKML geography geog integer maxdecimaldigits=15 text nprefix=NULL Description Return the geometry as a Keyhole Markup Language (KML) element. default maximum number of decimal places is 15, default namespace is no prefix. Using the maxdecimaldigits parameter can cause output geometry to become invalid. To avoid this use with a suitable gridsize first. Availability: 1.2.2 - later variants that include version param came in 1.3.2 Enhanced: 2.0.0 - Add prefix namespace, use default and named args Changed: 3.0.0 - Removed the "versioned" variant signature Requires PostGIS be compiled with Proj support. Use to confirm you have proj support compiled in. AsKML output will not work with geometries that do not have an SRID &Z_support; Examples SELECT ST_AsKML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))', 4326)); 0,0 0,1 1,1 1,0 0,0]]> This example outputs a 3D LineString. SELECT ST_AsKML('SRID=4326;LINESTRING(1 2 3,4 5 6)'); 1,2,3 4,5,6]]> See Also , ST_AsLatLonText Return the Degrees, Minutes, Seconds representation of the given point. text ST_AsLatLonText geometry pt text format='' Description Returns the Degrees, Minutes, Seconds representation of the point. It is assumed the point is in a lat/lon projection. The X (lon) and Y (lat) coordinates are normalized in the output to the "normal" range (-180 to +180 for lon, -90 to +90 for lat). The text parameter is a format string containing the format for the resulting text, similar to a date format string. Valid tokens are "D" for degrees, "M" for minutes, "S" for seconds, and "C" for cardinal direction (NSEW). DMS tokens may be repeated to indicate desired width and precision ("SSS.SSSS" means " 1.0023"). "M", "S", and "C" are optional. If "C" is omitted, degrees are shown with a "-" sign if south or west. If "S" is omitted, minutes will be shown as decimal with as many digits of precision as you specify. If "M" is also omitted, degrees are shown as decimal with as many digits precision as you specify. If the format string is omitted (or zero-length) a default format will be used. Availability: 2.0 Examples Default format. SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)')); 2°19'29.928"S 3°14'3.243"W Providing a format (same as the default). SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D°M''S.SSS"C')); 2°19'29.928"S 3°14'3.243"W Characters other than D, M, S, C and . are just passed through. SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D degrees, M minutes, S seconds to the C')); 2 degrees, 19 minutes, 30 seconds to the S 3 degrees, 14 minutes, 3 seconds to the W Signed degrees instead of cardinal directions. SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D°M''S.SSS"')); -2°19'29.928" -3°14'3.243" Decimal degrees. SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D.DDDD degrees C')); 2.3250 degrees S 3.2342 degrees W To convert parsed degree, minute, and second components to decimal degrees, apply the cardinal-direction sign explicitly. Excessively large values are normalized. SELECT (ST_AsLatLonText('POINT (-302.2342342 -792.32498)')); 72°19'29.928"S 57°45'56.757"E ST_AsMARC21 Returns geometry as a MARC21/XML record with a geographic datafield (034). text ST_AsMARC21 geometry geom text format='hdddmmss' Description This function returns a MARC21/XML record with Coded Cartographic Mathematical Data representing the bounding box of a given geometry. The format parameter allows to encode the coordinates in subfields $d,$e,$f and $g in all formats supported by the MARC21/XML standard. Valid formats are: cardinal direction, degrees, minutes and seconds (default): hdddmmss decimal degrees with cardinal direction: hddd.dddddd decimal degrees without cardinal direction: ddd.dddddd decimal minutes with cardinal direction: hdddmm.mmmm decimal minutes without cardinal direction: dddmm.mmmm decimal seconds with cardinal direction: hdddmmss.sss The decimal sign may be also a comma, e.g. hdddmm,mmmm. The precision of decimal formats can be limited by the number of characters after the decimal sign, e.g. hdddmm.mm for decimal minutes with a precision of two decimals. This function ignores the Z and M dimensions. LOC MARC21/XML versions supported: MARC21/XML 1.1 Availability: 3.3.0 This function does not support non lon/lat geometries, as they are not supported by the MARC21/XML standard (Coded Cartographic Mathematical Data). The MARC21/XML Standard does not provide any means to annotate the spatial reference system for Coded Cartographic Mathematical Data, which means that this information will be lost after conversion to MARC21/XML. Examples Converting a POINT to MARC21/XML formatted as hdddmmss (default) a W0043015 W0043015 N0541512 N0541512 ]]> Converting a POLYGON to MARC21/XML formatted in decimal degrees a W004.5792 W004.5466 N054.1970 N054.1817 ]]> Converting a GEOMETRYCOLLECTION to MARC21/XML formatted in decimal minutes. The geometries order in the MARC21/XML output correspond to their order in the collection. a E01307.0000 E01331.0000 N05240.0000 N05224.0000 a W00430.0000 W00430.0000 N05415.0000 N05415.0000 ]]> See Also ST_AsMVTGeom Transforms a geometry into the coordinate space of a MVT tile. geometry ST_AsMVTGeom geometry geom box2d bounds integer extent=4096 integer buffer=256 boolean clip_geom=true Description Transforms a geometry into the coordinate space of a MVT (Mapbox Vector Tile) tile, clipping it to the tile bounds if required. The geometry must be in the coordinate system of the target map (using if needed). Commonly this is Web Mercator (SRID:3857). The function attempts to preserve geometry validity, and corrects it if needed. This may cause the result geometry to collapse to a lower dimension. The function performs geometry simplification appropriate to the integer tile coordinate space. After transforming to tile coordinates it snaps coordinates to the integer grid, removes repeated points, and removes points that lie on straight lines. It does not perform general-purpose, scale-dependent simplification such as . To reduce detail before tile conversion, simplify the geometry in map coordinates before calling ST_AsMVTGeom. The rectangular bounds of the tile in the target map coordinate space must be provided, so the geometry can be transformed, and clipped if required. The bounds can be generated using . This function is used to convert geometry into the tile coordinate space required by . geom is the geometry to transform, in the coordinate system of the target map. bounds is the rectangular bounds of the tile in map coordinate space, with no buffer. extent is the tile extent size in tile coordinate space as defined by the MVT specification. Defaults to 4096. buffer is the buffer size in tile coordinate space for geometry clippig. Defaults to 256. clip_geom is a boolean to control if geometries are clipped or encoded as-is. Defaults to true. Availability: 2.4.0 From 3.0, Wagyu can be chosen at configure time to clip and validate MVT polygons. This library is faster and produces more correct results than the GEOS default, but it might drop small polygons. Examples SELECT ST_AsMVTGeom('POLYGON ((0 0,10 0,10 5,0 -5,0 0))', ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false); MULTIPOLYGON(((5 4096,10 4091,10 4096,5 4096)),((5 4096,0 4101,0 4096,5 4096))) Canonical example for a Web Mercator tile using a computed tile bounds to query and clip geometry. This assumes the data.geom column has srid of 4326. 4096, buffer => 64) AS geom FROM data WHERE geom && ST_Transform(ST_TileEnvelope(12, 513, 412, margin => (64.0 / 4096)), 4326) ]]> See Also , , ST_AsMVT Aggregate function returning a MVT representation of a set of rows. bytea ST_AsMVT anyelement set row bytea ST_AsMVT anyelement row text name bytea ST_AsMVT anyelement row text name integer extent bytea ST_AsMVT anyelement row text name integer extent text geom_name bytea ST_AsMVT anyelement row text name integer extent text geom_name text feature_id_name Description An aggregate function which returns a binary Mapbox Vector Tile representation of a set of rows corresponding to a tile layer. The rows must contain a geometry column which will be encoded as a feature geometry. The geometry must be in tile coordinate space and valid as per the MVT specification. can be used to transform geometry into tile coordinate space. Other row columns are encoded as feature attributes. The Mapbox Vector Tile format can store features with varying sets of attributes. To use this capability supply a JSONB column in the row data containing Json objects one level deep. The keys and values in the JSONB values will be encoded as feature attributes. Tiles with multiple layers can be created by concatenating multiple calls to this function using || or STRING_AGG. Do not call with a GEOMETRYCOLLECTION as an element in the row. However you can use to prepare a geometry collection for inclusion. row row data with at least a geometry column. name is the name of the layer. Default is the string "default". extent is the tile extent in screen space as defined by the specification. Default is 4096. geom_name is the name of the geometry column in the row data. Default is the first geometry column. Note that PostgreSQL by default automatically folds unquoted identifiers to lower case, which means that unless the geometry column is quoted, e.g. "MyMVTGeom", this parameter must be provided as lowercase. feature_id_name is the name of the Feature ID column in the row data. If NULL or negative the Feature ID is not set. The first column matching name and valid type (smallint, integer, bigint) will be used as Feature ID, and any subsequent column will be added as a property. JSON properties are not supported. Enhanced: 3.0 - added support for Feature ID. Enhanced: 2.5.0 - added support parallel query. Availability: 2.4.0 Examples 4096, buffer => 64) AS geom, name, description FROM points_of_interest WHERE geom && ST_TileEnvelope(12, 513, 412, margin => (64.0 / 4096)) ) SELECT ST_AsMVT(mvtgeom.*) FROM mvtgeom; ]]> See Also , ST_AsSVG Returns SVG path data for a geometry. text ST_AsSVG geometry geom integer rel=0 integer maxdecimaldigits=15 text ST_AsSVG geography geog integer rel=0 integer maxdecimaldigits=15 Description Return the geometry as Scalar Vector Graphics (SVG) path data. Use 1 as second argument to have the path data implemented in terms of relative moves, the default (or 0) uses absolute moves. Third argument may be used to reduce the maximum number of decimal digits used in output (defaults to 15). Point geometries will be rendered as cx/cy when 'rel' arg is 0, x/y when 'rel' is 1. Multipoint geometries are delimited by commas (","), GeometryCollection geometries are delimited by semicolons (";"). For working with PostGIS SVG graphics, checkout pg_svg library which provides plpgsql functions for working with outputs from ST_AsSVG. Enhanced: 3.4.0 to support all curve types Changed: 2.0.0 to use default args and support named args Availability: 1.2.2. Availability: 1.4.0 Changed in PostGIS 1.4.0 to include L command in absolute path to conform to http://www.w3.org/TR/SVG/paths.html#PathDataBNF &curve_support; Examples SELECT ST_AsSVG('POLYGON((0 0,0 1,1 1,1 0,0 0))'::geometry); M 0 0 L 0 -1 1 -1 1 0 Z Circular string SELECT ST_AsSVG('CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)'::geometry); M -2 0 A 2 2 0 0 1 2 0 A 2 2 0 0 1 2 -4 Multi-curve SELECT ST_AsSVG('MULTICURVE((5 5,3 5,3 3,0 3), CIRCULARSTRING(0 0,2 1,2 2))'::geometry, 0, 0); M 5 -5 L 3 -5 3 -3 0 -3 M 0 0 A 2 2 0 0 0 2 -2 Multi-surface SELECT ST_AsSVG('MULTISURFACE( CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0), (-1 0,0 0.5,1 0,0 1,-1 0)), ((7 8,10 10,6 14,4 11,7 8)))'::geometry, 0, 2); M -2 0 A 1 1 0 0 0 0 0 A 1 1 0 0 0 2 0 A 2 2 0 0 0 -2 0 Z M -1 0 L 0 -0.5 1 0 0 -1 -1 0 Z M 7 -8 L 10 -10 6 -14 4 -11 Z ST_AsTWKB Returns the geometry as TWKB, aka "Tiny Well-Known Binary" bytea ST_AsTWKB geometry geom integer prec=0 integer prec_z=0 integer prec_m=0 boolean with_sizes=false boolean with_boxes=false bytea ST_AsTWKB geometry[] geom bigint[] ids integer prec=0 integer prec_z=0 integer prec_m=0 boolean with_sizes=false boolean with_boxes=false Description Returns the geometry in TWKB (Tiny Well-Known Binary) format. TWKB is a compressed binary format with a focus on minimizing the size of the output. The decimal digits parameters control how much precision is stored in the output. By default, values are rounded to the nearest unit before encoding. If you want to transfer more precision, increase the number. For example, a value of 1 implies that the first digit to the right of the decimal point will be preserved. The sizes and bounding boxes parameters control whether optional information about the encoded length of the object and the bounds of the object are included in the output. By default they are not. Do not turn them on unless your client software has a use for them, as they just use up space (and saving space is the point of TWKB). The array-input form of the function is used to convert a collection of geometries and unique identifiers into a TWKB collection that preserves the identifiers. This is useful for clients that expect to unpack a collection and then access further information about the objects inside. You can create the arrays using the array_agg function. The other parameters operate the same as for the simple form of the function. The format specification is available online at https://github.com/TWKB/Specification, and code for building a JavaScript client can be found at https://github.com/TWKB/twkb.js. Enhanced: 2.4.0 memory and speed improvements. Availability: 2.2.0 Examples SELECT ST_AsTWKB('LINESTRING(1 1,5 5)'::geometry); \x02000202020808 To create an aggregate TWKB object including identifiers aggregate the desired geometries and objects first, using "array_agg()", then call the appropriate TWKB function. SELECT ST_AsTWKB(array_agg(geom), array_agg(gid)) FROM mytable; \x040402020400000202 See Also , , , , ST_AsX3D Returns a Geometry in X3D xml node element format: ISO-IEC-19776-1.2-X3DEncodings-XML text ST_AsX3D geometry g1 integer maxdecimaldigits=15 integer options=0 Description Returns a geometry as an X3D xml formatted node element http://www.web3d.org/standards/number/19776-1. If maxdecimaldigits (precision) is not specified then defaults to 15. There are various options for translating PostGIS geometries to X3D since X3D geometry types don't map directly to PostGIS geometry types and some newer X3D types that might be better mappings we have avoided since most rendering tools don't currently support them. These are the mappings we have settled on. Feel free to post a bug ticket if you have thoughts on the idea or ways we can allow people to denote their preferred mappings. Below is how we currently map PostGIS 2D/3D types to X3D types The 'options' argument is a bitfield that denotes whether to represent coordinates with the X3D GeoCoordinates geospatial node and whether to flip the x/y axis. By default, ST_AsX3D outputs in database form (long,lat or X,Y), but the X3D default of lat/lon, y/x may be preferred. 0: X/Y in database order (e.g. long/lat = X,Y is standard database order), default value, and non-spatial coordinates (just regular old Coordinate tag). 1: Flip X and Y. If used in conjunction with the GeoCoordinate option switch, then output will be default "latitude_first" and coordinates will be flipped as well. 2: Output coordinates in GeoSpatial GeoCoordinates. This option will throw an error if geometries are not in WGS 84 long lat (srid: 4326). This is currently the only GeoCoordinate type supported. Refer to X3D specs specifying a spatial reference system.. Default output will be GeoCoordinate geoSystem='"GD" "WE" "longitude_first"'. If you prefer the X3D default of GeoCoordinate geoSystem='"GD" "WE" "latitude_first"' use (2 + 1) = 3 PostGIS Type 2D X3D Type 3D X3D Type LINESTRING LineSet (coordinates are promoted to 3D) LineSet MULTILINESTRING IndexedLineSet (coordinates are promoted to 3D) IndexedLineSet MULTIPOINT Polypoint2D PointSet POINT outputs the space delimited coordinates outputs the space delimited coordinates (MULTI) POLYGON, POLYHEDRALSURFACE IndexedFaceSet (coordinates are promoted to 3D; inner rings currently output as another faceset) IndexedFaceSet (inner rings currently output as another faceset) TIN TriangleSet2D (Not Yet Implemented) IndexedTriangleSet CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE, MULTISURFACE linearized, then emitted with the linear geometry mapping linearized, then emitted with the linear geometry mapping NURBSCURVE NurbsCurve with controlPoint, knot, weight, and order fields NurbsCurve with controlPoint, knot, weight, and order fields 2D geometry support not yet complete. Inner rings currently just drawn as separate polygons. We are working on these. M coordinates are not represented in X3D output. Lots of advancements happening in 3D space particularly with X3D Integration with HTML5 There is also a nice open source X3D viewer you can use to view rendered geometries. Free Wrl http://freewrl.sourceforge.net/ binaries available for Mac, Linux, and Windows. Use the FreeWRL_Launcher packaged to view the geometries. Also check out PostGIS minimalist X3D viewer that utilizes this function and x3dDom html/js open source toolkit. Availability: 2.0.0: ISO-IEC-19776-1.2-X3DEncodings-XML Enhanced: 2.2.0: Support for GeoCoordinates and axis (x/y, long/lat) flipping. Look at options for details. Enhanced: 3.7.0: Support for curve geometries. NURBSCURVE is emitted as X3D NurbsCurve; other curve types are linearized before output. &Z_support; &P_support; &T_support; Examples Create a complete X3D document containing a cube that is viewable in FreeWRL and other X3D viewers. ' || ST_AsX3D(ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)), ((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )')) || ' ' As x3ddoc; ]]> ]]> PostGIS buildings. Copy and paste the output of this query to x3d scene viewer and click Show ' || ST_AsX3D(CG_Extrude(geom, 0,0, i*0.5)) || ' ', '') FROM ST_Subdivide(ST_Letters('PostGIS'),20) WITH ORDINALITY AS f(geom,i); ]]> The following preview shows the extruded geometry generated from a simplified version of the same source lettering. It is a geometry preview, not X3D markup; use the preceding ST_AsX3D query output in an X3D viewer to inspect the native X3D scene. SELECT CG_Extrude( ST_SimplifyPreserveTopology(ST_Letters('PostGIS'), 2), 0, 0, 10 ) AS buildings; GEOMETRYCOLLECTION Z (POLYHEDRALSURFACE Z (((42.6 39.2 0,36.3 24.5 0,17 20.3 0,17.9 0 0,0 0 0,0 73.8 0,27.3 73.6 0,36.3 70 0,41.8 61.6 0,42.6 39.2 0),(26.5 55.7 0,17 58.8 0,17 35.3 0,25.6 36.2 0,26.5 55.7 0)),((42.6 39.2 10,41.8 61.6 10,36.3 70 10,27.3 73.6 10,0 73.8 10,0 0 10,17.9 0 10,17 20.3 10,36.3 24.5 10,42.6 39.2 10),(26.5 55.7 10,25.6 36.2 10,17 35.3 10,17 58.8 10,26.5 55.7 10)),((42.6 39.2 0,42.6 39.2 10,36.3 24.5 10,36.3 24.5 0,42.6 39.2 0)),((36.3 24.5 0,36.3 24.5 10,17 20.3 10,17 20.3 0,36.3 24.5 0)),((17 20.3 0,17 20.3 10,17.9 0 10,17.9 0 0,17 20.3 0)),((17.9 0 0,17.9 0 10,0 0 10,0 0 0,17.9 0 0)),((0 0 0,0 0 10,0 73.8 10,0 73.8 0,0 0 0)),((0 73.8 0,0 73.8 10,27.3 73.6 10,27.3 73.6 0,0 73.8 0)),((27.3 73.6 0,27.3 73.6 10,36.3 70 10,36.3 70 0,27.3 73.6 0)),((36.3 70 0,36.3 70 10,41.8 61.6 10,41.8 61.6 0,36.3 70 0)),((41.8 61.6 0,41.8 61.6 10,42.6 39.2 10,42.6 39.2 0,41.8 61.6 0)),((26.5 55.7 0,26.5 55.7 10,17 58.8 10,17 58.8 0,26.5 55.7 0)),((17 58.8 0,17 58.8 10,17 35.3 10,17 35.3 0,17 58.8 0)),((17 35.3 0,17 35.3 10,25.6 36.2 10,25.6 36.2 0,17 35.3 0)),((25.6 36.2 0,25.6 36.2 10,26.5 55.7 10,26.5 55.7 0,25.6 36.2 0))),POLYHEDRALSURFACE Z (((69.01 58 0,84.51 52.5 0,89.71 39.9 0,87.81 9.7 0,81.71 2.9 0,71.31 -0.5 0,54.91 3.9 0,48.31 17.8 0,50.61 48.7 0,58.01 55.6 0,69.01 58 0),(73.91 38.9 0,69.11 42.6 0,64.21 38.9 0,64.21 18.9 0,68.91 15.2 0,73.91 18.9 0,73.91 38.9 0)),((69.01 58 10,58.01 55.6 10,50.61 48.7 10,48.31 17.8 10,54.91 3.9 10,71.31 -0.5 10,81.71 2.9 10,87.81 9.7 10,89.71 39.9 10,84.51 52.5 10,69.01 58 10),(73.91 38.9 10,73.91 18.9 10,68.91 15.2 10,64.21 18.9 10,64.21 38.9 10,69.11 42.6 10,73.91 38.9 10)),((69.01 58 0,69.01 58 10,84.51 52.5 10,84.51 52.5 0,69.01 58 0)),((84.51 52.5 0,84.51 52.5 10,89.71 39.9 10,89.71 39.9 0,84.51 52.5 0)),((89.71 39.9 0,89.71 39.9 10,87.81 9.7 10,87.81 9.7 0,89.71 39.9 0)),((87.81 9.7 0,87.81 9.7 10,81.71 2.9 10,81.71 2.9 0,87.81 9.7 0)),((81.71 2.9 0,81.71 2.9 10,71.31 -0.5 10,71.31 -0.5 0,81.71 2.9 0)),((71.31 -0.5 0,71.31 -0.5 10,54.91 3.9 10,54.91 3.9 0,71.31 -0.5 0)),((54.91 3.9 0,54.91 3.9 10,48.31 17.8 10,48.31 17.8 0,54.91 3.9 0)),((48.31 17.8 0,48.31 17.8 10,50.61 48.7 10,50.61 48.7 0,48.31 17.8 0)),((50.61 48.7 0,50.61 48.7 10,58.01 55.6 10,58.01 55.6 0,50.61 48.7 0)),((58.01 55.6 0,58.01 55.6 10,69.01 58 10,69.01 58 0,58.01 55.6 0)),((73.91 38.9 0,73.91 38.9 10,69.11 42.6 10,69.11 42.6 0,73.91 38.9 0)),((69.11 42.6 0,69.11 42.6 10,64.21 38.9 10,64.21 38.9 0,69.11 42.6 0)),((64.21 38.9 0,64.21 38.9 10,64.21 18.9 10,64.21 18.9 0,64.21 38.9 0)),((64.21 18.9 0,64.21 18.9 10,68.91 15.2 10,68.91 15.2 0,64.21 18.9 0)),((68.91 15.2 0,68.91 15.2 10,73.91 18.9 10,73.91 18.9 0,68.91 15.2 0)),((73.91 18.9 0,73.91 18.9 10,73.91 38.9 10,73.91 38.9 0,73.91 18.9 0))),POLYHEDRALSURFACE Z (((111.02 37.6 0,123.92 31.1 0,130.72 20.8 0,126.82 5.3 0,116.02 -0.3 0,94.02 3.7 0,98.82 18.9 0,112.52 15.3 0,115.02 17.6 0,98.72 29.6 0,96.12 45.4 0,100.52 53 0,107.32 57.1 0,128.92 54.7 0,122.72 39.9 0,112.02 42.1 0,111.02 37.6 0)),((111.02 37.6 10,112.02 42.1 10,122.72 39.9 10,128.92 54.7 10,107.32 57.1 10,100.52 53 10,96.12 45.4 10,98.72 29.6 10,115.02 17.6 10,112.52 15.3 10,98.82 18.9 10,94.02 3.7 10,116.02 -0.3 10,126.82 5.3 10,130.72 20.8 10,123.92 31.1 10,111.02 37.6 10)),((111.02 37.6 0,111.02 37.6 10,123.92 31.1 10,123.92 31.1 0,111.02 37.6 0)),((123.92 31.1 0,123.92 31.1 10,130.72 20.8 10,130.72 20.8 0,123.92 31.1 0)),((130.72 20.8 0,130.72 20.8 10,126.82 5.3 10,126.82 5.3 0,130.72 20.8 0)),((126.82 5.3 0,126.82 5.3 10,116.02 -0.3 10,116.02 -0.3 0,126.82 5.3 0)),((116.02 -0.3 0,116.02 -0.3 10,94.02 3.7 10,94.02 3.7 0,116.02 -0.3 0)),((94.02 3.7 0,94.02 3.7 10,98.82 18.9 10,98.82 18.9 0,94.02 3.7 0)),((98.82 18.9 0,98.82 18.9 10,112.52 15.3 10,112.52 15.3 0,98.82 18.9 0)),((112.52 15.3 0,112.52 15.3 10,115.02 17.6 10,115.02 17.6 0,112.52 15.3 0)),((115.02 17.6 0,115.02 17.6 10,98.72 29.6 10,98.72 29.6 0,115.02 17.6 0)),((98.72 29.6 0,98.72 29.6 10,96.12 45.4 10,96.12 45.4 0,98.72 29.6 0)),((96.12 45.4 0,96.12 45.4 10,100.52 53 10,100.52 53 0,96.12 45.4 0)),((100.52 53 0,100.52 53 10,107.32 57.1 10,107.32 57.1 0,100.52 53 0)),((107.32 57.1 0,107.32 57.1 10,128.92 54.7 10,128.92 54.7 0,107.32 57.1 0)),((128.92 54.7 0,128.92 54.7 10,122.72 39.9 10,122.72 39.9 0,128.92 54.7 0)),((122.72 39.9 0,122.72 39.9 10,112.02 42.1 10,112.02 42.1 0,122.72 39.9 0)),((112.02 42.1 0,112.02 42.1 10,111.02 37.6 10,111.02 37.6 0,112.02 42.1 0))),POLYHEDRALSURFACE Z (((156.82 17.7 0,167.02 16 0,167.02 -0.9 0,149.22 2 0,141.42 11.3 0,141.12 42.7 0,134.62 41.8 0,134.62 58.9 0,141.12 57.9 0,140.02 75.4 0,157.92 75.4 0,156.82 57.9 0,166.02 58.9 0,166.02 41.8 0,156.82 42.7 0,156.82 17.7 0)),((156.82 17.7 10,156.82 42.7 10,166.02 41.8 10,166.02 58.9 10,156.82 57.9 10,157.92 75.4 10,140.02 75.4 10,141.12 57.9 10,134.62 58.9 10,134.62 41.8 10,141.12 42.7 10,141.42 11.3 10,149.22 2 10,167.02 -0.9 10,167.02 16 10,156.82 17.7 10)),((156.82 17.7 0,156.82 17.7 10,167.02 16 10,167.02 16 0,156.82 17.7 0)),((167.02 16 0,167.02 16 10,167.02 -0.9 10,167.02 -0.9 0,167.02 16 0)),((167.02 -0.9 0,167.02 -0.9 10,149.22 2 10,149.22 2 0,167.02 -0.9 0)),((149.22 2 0,149.22 2 10,141.42 11.3 10,141.42 11.3 0,149.22 2 0)),((141.42 11.3 0,141.42 11.3 10,141.12 42.7 10,141.12 42.7 0,141.42 11.3 0)),((141.12 42.7 0,141.12 42.7 10,134.62 41.8 10,134.62 41.8 0,141.12 42.7 0)),((134.62 41.8 0,134.62 41.8 10,134.62 58.9 10,134.62 58.9 0,134.62 41.8 0)),((134.62 58.9 0,134.62 58.9 10,141.12 57.9 10,141.12 57.9 0,134.62 58.9 0)),((141.12 57.9 0,141.12 57.9 10,140.02 75.4 10,140.02 75.4 0,141.12 57.9 0)),((140.02 75.4 0,140.02 75.4 10,157.92 75.4 10,157.92 75.4 0,140.02 75.4 0)),((157.92 75.4 0,157.92 75.4 10,156.82 57.9 10,156.82 57.9 0,157.92 75.4 0)),((156.82 57.9 0,156.82 57.9 10,166.02 58.9 10,166.02 58.9 0,156.82 57.9 0)),((166.02 58.9 0,166.02 58.9 10,166.02 41.8 10,166.02 41.8 0,166.02 58.9 0)),((166.02 41.8 0,166.02 41.8 10,156.82 42.7 10,156.82 42.7 0,166.02 41.8 0)),((156.82 42.7 0,156.82 42.7 10,156.82 17.7 10,156.82 17.7 0,156.82 42.7 0))),POLYHEDRALSURFACE Z (((213.81 13.2 0,208.11 4.2 0,198.51 -0.3 0,184.21 0.9 0,174.91 8.8 0,172.61 57.4 0,175.21 66.1 0,180.91 71.6 0,209.81 74 0,209.81 58.4 0,189.11 56.8 0,188.61 18.7 0,193.81 14.8 0,199.11 16.5 0,199.11 32.2 0,193.41 32.2 0,193.41 46.4 0,213.81 46.4 0,213.81 13.2 0)),((213.81 13.2 10,213.81 46.4 10,193.41 46.4 10,193.41 32.2 10,199.11 32.2 10,199.11 16.5 10,193.81 14.8 10,188.61 18.7 10,189.11 56.8 10,209.81 58.4 10,209.81 74 10,180.91 71.6 10,175.21 66.1 10,172.61 57.4 10,174.91 8.8 10,184.21 0.9 10,198.51 -0.3 10,208.11 4.2 10,213.81 13.2 10)),((213.81 13.2 0,213.81 13.2 10,208.11 4.2 10,208.11 4.2 0,213.81 13.2 0)),((208.11 4.2 0,208.11 4.2 10,198.51 -0.3 10,198.51 -0.3 0,208.11 4.2 0)),((198.51 -0.3 0,198.51 -0.3 10,184.21 0.9 10,184.21 0.9 0,198.51 -0.3 0)),((184.21 0.9 0,184.21 0.9 10,174.91 8.8 10,174.91 8.8 0,184.21 0.9 0)),((174.91 8.8 0,174.91 8.8 10,172.61 57.4 10,172.61 57.4 0,174.91 8.8 0)),((172.61 57.4 0,172.61 57.4 10,175.21 66.1 10,175.21 66.1 0,172.61 57.4 0)),((175.21 66.1 0,175.21 66.1 10,180.91 71.6 10,180.91 71.6 0,175.21 66.1 0)),((180.91 71.6 0,180.91 71.6 10,209.81 74 10,209.81 74 0,180.91 71.6 0)),((209.81 74 0,209.81 74 10,209.81 58.4 10,209.81 58.4 0,209.81 74 0)),((209.81 58.4 0,209.81 58.4 10,189.11 56.8 10,189.11 56.8 0,209.81 58.4 0)),((189.11 56.8 0,189.11 56.8 10,188.61 18.7 10,188.61 18.7 0,189.11 56.8 0)),((188.61 18.7 0,188.61 18.7 10,193.81 14.8 10,193.81 14.8 0,188.61 18.7 0)),((193.81 14.8 0,193.81 14.8 10,199.11 16.5 10,199.11 16.5 0,193.81 14.8 0)),((199.11 16.5 0,199.11 16.5 10,199.11 32.2 10,199.11 32.2 0,199.11 16.5 0)),((199.11 32.2 0,199.11 32.2 10,193.41 32.2 10,193.41 32.2 0,199.11 32.2 0)),((193.41 32.2 0,193.41 32.2 10,193.41 46.4 10,193.41 46.4 0,193.41 32.2 0)),((193.41 46.4 0,193.41 46.4 10,213.81 46.4 10,213.81 46.4 0,193.41 46.4 0)),((213.81 46.4 0,213.81 46.4 10,213.81 13.2 10,213.81 13.2 0,213.81 46.4 0))),POLYHEDRALSURFACE Z (((235.82 72.9 0,236.82 0 0,218.52 0 0,218.52 73.8 0,235.82 72.9 0)),((235.82 72.9 10,218.52 73.8 10,218.52 0 10,236.82 0 10,235.82 72.9 10)),((235.82 72.9 0,235.82 72.9 10,236.82 0 10,236.82 0 0,235.82 72.9 0)),((236.82 0 0,236.82 0 10,218.52 0 10,218.52 0 0,236.82 0 0)),((218.52 0 0,218.52 0 10,218.52 73.8 10,218.52 73.8 0,218.52 0 0)),((218.52 73.8 0,218.52 73.8 10,235.82 72.9 10,235.82 72.9 0,218.52 73.8 0))),POLYHEDRALSURFACE Z (((258.33 49.5 0,279.93 34.6 0,283.43 25.9 0,282.53 15.4 0,277.93 6.8 0,270.73 1.6 0,252.33 0.5 0,241.53 4.9 0,246.43 20.6 0,260.73 16.4 0,266.23 18.7 0,267.43 23.2 0,245.63 39.4 0,242.03 48.6 0,242.83 59.6 0,247.53 67.3 0,257.53 73.2 0,280.43 70.8 0,275.23 56.4 0,264.53 58.3 0,258.73 55.1 0,258.33 49.5 0)),((258.33 49.5 10,258.73 55.1 10,264.53 58.3 10,275.23 56.4 10,280.43 70.8 10,257.53 73.2 10,247.53 67.3 10,242.83 59.6 10,242.03 48.6 10,245.63 39.4 10,267.43 23.2 10,266.23 18.7 10,260.73 16.4 10,246.43 20.6 10,241.53 4.9 10,252.33 0.5 10,270.73 1.6 10,277.93 6.8 10,282.53 15.4 10,283.43 25.9 10,279.93 34.6 10,258.33 49.5 10)),((258.33 49.5 0,258.33 49.5 10,279.93 34.6 10,279.93 34.6 0,258.33 49.5 0)),((279.93 34.6 0,279.93 34.6 10,283.43 25.9 10,283.43 25.9 0,279.93 34.6 0)),((283.43 25.9 0,283.43 25.9 10,282.53 15.4 10,282.53 15.4 0,283.43 25.9 0)),((282.53 15.4 0,282.53 15.4 10,277.93 6.8 10,277.93 6.8 0,282.53 15.4 0)),((277.93 6.8 0,277.93 6.8 10,270.73 1.6 10,270.73 1.6 0,277.93 6.8 0)),((270.73 1.6 0,270.73 1.6 10,252.33 0.5 10,252.33 0.5 0,270.73 1.6 0)),((252.33 0.5 0,252.33 0.5 10,241.53 4.9 10,241.53 4.9 0,252.33 0.5 0)),((241.53 4.9 0,241.53 4.9 10,246.43 20.6 10,246.43 20.6 0,241.53 4.9 0)),((246.43 20.6 0,246.43 20.6 10,260.73 16.4 10,260.73 16.4 0,246.43 20.6 0)),((260.73 16.4 0,260.73 16.4 10,266.23 18.7 10,266.23 18.7 0,260.73 16.4 0)),((266.23 18.7 0,266.23 18.7 10,267.43 23.2 10,267.43 23.2 0,266.23 18.7 0)),((267.43 23.2 0,267.43 23.2 10,245.63 39.4 10,245.63 39.4 0,267.43 23.2 0)),((245.63 39.4 0,245.63 39.4 10,242.03 48.6 10,242.03 48.6 0,245.63 39.4 0)),((242.03 48.6 0,242.03 48.6 10,242.83 59.6 10,242.83 59.6 0,242.03 48.6 0)),((242.83 59.6 0,242.83 59.6 10,247.53 67.3 10,247.53 67.3 0,242.83 59.6 0)),((247.53 67.3 0,247.53 67.3 10,257.53 73.2 10,257.53 73.2 0,247.53 67.3 0)),((257.53 73.2 0,257.53 73.2 10,280.43 70.8 10,280.43 70.8 0,257.53 73.2 0)),((280.43 70.8 0,280.43 70.8 10,275.23 56.4 10,275.23 56.4 0,280.43 70.8 0)),((275.23 56.4 0,275.23 56.4 10,264.53 58.3 10,264.53 58.3 0,275.23 56.4 0)),((264.53 58.3 0,264.53 58.3 10,258.73 55.1 10,258.73 55.1 0,264.53 58.3 0)),((258.73 55.1 0,258.73 55.1 10,258.33 49.5 10,258.33 49.5 0,258.73 55.1 0)))) An Octagon elevated 3 Units and decimal precision of 6. ]]> TIN. ]]> Closed multilinestring (the boundary of a polygon with holes). ]]> ST_GeoHash Return a GeoHash representation of the geometry. text ST_GeoHash geometry geom integer maxchars=full_precision_of_point Description Computes a GeoHash representation of a geometry. A GeoHash encodes a geographic Point into a text form that is sortable and searchable based on prefixing. A shorter GeoHash is a less precise representation of a point. It can be thought of as a box that contains the point. Non-point geometry values with non-zero extent can also be mapped to GeoHash codes. The precision of the code depends on the geographic extent of the geometry. If maxchars is not specified, the returned GeoHash code is for the smallest cell containing the input geometry. Points return a GeoHash with 20 characters of precision (about enough to hold the full double precision of the input). Other geometric types may return a GeoHash with less precision, depending on the extent of the geometry. Larger geometries are represented with less precision, smaller ones with more precision. The box determined by the GeoHash code always contains the input feature. If maxchars is specified the returned GeoHash code has at most that many characters. It maps to a (possibly) lower precision representation of the input geometry. For non-points, the starting point of the calculation is the center of the bounding box of the geometry. Availability: 1.4.0 ST_GeoHash requires input geometry to be in geographic (lon/lat) coordinates. &curve_support; Examples SELECT ST_GeoHash(ST_Point(-126, 48)); c0w3hf1s70w3hf1s70w3 SELECT ST_GeoHash(ST_Point(-126, 48), 5); c0w3h This example shows that the GeoHash for a line containing a point is a prefix of the point code. SELECT ST_GeoHash('LINESTRING(-126 48,-126.1 48.1)'::geometry); c0w3 See Also , ,