官术网_书友最值得收藏!

Creating points

This is a very important function, since tabular data with coordinates stored in separate columns is quite abundant. Examples include geocoded address lists, survey results, and telemetry measurements. Such data can be converted to geometry using the ST_MakePoint function:

SELECT ST_MakePoint(391390,5817855);

Given two numbers, it creates a point geometry. To make it clear what the location really is, and make the created geometry suitable for spatial analysis, an SRID must be given. This can be accomplished using a ST_SetSRID function. So the complete example will be:

SELECT ST_SetSRID(ST_MakePoint(391390,5817855),32633);  

The number 32633 is an SRID for UTM coordinates zone 33 north, and in this case, the coordinate pair 391390,5817855 denotes the Hallesches Tor in Berlin.

When the two dimensions aren't enough, a third argument can be added with a Z-coordinate value:

SELECT ST_SetSRID(ST_MakePoint(334216.6,5077675.3,4810),32632); 

This will output a 3D point geometry for Mont Blanc peak in the UTM zone 32 north coordinate system.

For geometries with both Z-coordinates and M-coordinates (M for measure, linear referencing) there are third and fourth arguments, the fourth meaning M-value:

SELECT ST_SetSRID(ST_MakePoint(503612.6,5789004.9,89.5,4.408),32634);  

This will output a 4D point geometry for Warsaw East train station, located at 503612.6,5789004.9 UTM 34N, 89.5 meters above mean sea level and 4.408 kilometers from the beginning of the line at Central Station.

When a point has an M value but no Z, there is a special ST_MakePointM function:

SELECT ST_SetSRID(ST_MakePointM(503612.6,5789004.9,4.408),32634);  

It takes three arguments: XY, and M values.

主站蜘蛛池模板: 博客| 眉山市| 长丰县| 宜昌市| 尼木县| 静海县| 巴彦淖尔市| 惠来县| 通城县| 开阳县| 梁河县| 延长县| 盐亭县| 凤庆县| 高青县| 万全县| 泾阳县| 江门市| 中阳县| 改则县| 什邡市| 新竹市| 安塞县| 招远市| 保定市| 陇西县| 清丰县| 清河县| 崇阳县| 横山县| 杭锦后旗| 堆龙德庆县| 怀化市| 南和县| 砀山县| 望城县| 吴桥县| 宜城市| 平塘县| 西乌| 额济纳旗|