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

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.

主站蜘蛛池模板: 合阳县| 阿合奇县| 淄博市| 彭山县| 武隆县| 荆门市| 大丰市| 乌兰县| 宣汉县| 安吉县| 炉霍县| 青海省| 昭平县| 固原市| 安仁县| 龙胜| 濮阳县| 金塔县| 北宁市| 治县。| 德惠市| 竹山县| 普安县| 磴口县| 漳州市| 奎屯市| 永吉县| 苍山县| 玉树县| 墨江| 杭锦后旗| 平和县| 牙克石市| 武邑县| 娄烦县| 达孜县| 科技| 石嘴山市| 兴义市| 谷城县| 金湖县|