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

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.

主站蜘蛛池模板: 尖扎县| 白城市| 托克逊县| 沂水县| 兴安盟| 格尔木市| 永宁县| 额尔古纳市| 称多县| 朔州市| 商洛市| 晋城| 吉隆县| 株洲市| 厦门市| 开鲁县| 伊宁县| 天峻县| 博野县| 界首市| 灵武市| 石渠县| 土默特右旗| 葵青区| 丰台区| 尤溪县| 金寨县| 丹寨县| 温泉县| 万山特区| 侯马市| 安远县| 盐边县| 蓬溪县| 双柏县| 崇左市| 桓仁| 临沭县| 阿图什市| 桓台县| 宜兴市|