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

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.

主站蜘蛛池模板: 稻城县| 望奎县| 陈巴尔虎旗| 陇南市| 太谷县| 宁陕县| 金堂县| 无棣县| 兴海县| 泾源县| 德庆县| 剑川县| 瑞昌市| 云浮市| 河西区| 宁河县| 右玉县| 沂源县| 德兴市| 文安县| 云安县| 盘山县| 久治县| 三江| 玉田县| 七台河市| 汉寿县| 吉首市| 古蔺县| 丰县| 大悟县| 唐河县| 黄石市| 巢湖市| 崇义县| 烟台市| 泗阳县| 永吉县| 双江| 萝北县| 桐乡市|