geom processing in postgresql

convert geom to latitude and longitude

SELECT
    st_x ( geom ) AS lon,
    st_y ( geom ) AS lat
FROM
    表名

If it is a geometric figure, an error will be reported

> ERROR:  Argument to ST_X() must have type POINT

At this point we can instead get the latitude and longitude of the center point of the geometry

SELECT
	st_x ( ST_PointOnSurface(geom) ) AS lon,
	st_y ( ST_PointOnSurface(geom) ) AS lat
FROM
	表名; 

Get the center point of the geometry

SELECT ST_PointOnSurface(geom) FROM 表名 ;

convert geom to POINT

SELECT
    ST_asText ( geom ) 
FROM
    表名

 SRID query

SELECT st_srid(geom) FROM 表名;

 SRID conversion, such as 4549 to 4326

SELECT st_astext(
st_transform(
ST_GeomFromText('POINT(521519.84150795196  3070180.2299377914)', 4549 ), 4326) )

Geometry type coordinate system conversion

SELECT  st_transform(geom,4549) FROM 表名 LIMIT 9;

Determine whether two geometry types intersect

SELECT ST_Intersects(geom1, geom2);  

Guess you like

Origin blog.csdn.net/weixin_65243968/article/details/130530248