ST_AREA关于坐标系的问题

发布于 2025-02-02 14:37:11 字数 587 浏览 2 评论 0原文

我想选择距离我最初多边形超过350平方公里的区域的所有多边形,并尝试了ST_AREA。但是我的多边形在WKID中:25832(UTM 32N),我读到ST_AREA总是在WGS 84(EPSG 4326)中计算。...

我尝试过这样的尝试,但不起作用。

DROP TABLE IF EXISTS projekt."Final_Selection";
CREATE TABLE projekt."Final_Selection" AS
SELECT (st_area/1000000), geom 
FROM projekt."New_Pot" WHERE st_area>350 ;

像这样:

DROP TABLE IF EXISTS projekt."Final_Selection";
CREATE TABLE projekt."Final_Selection" AS
SELECT (st_area(ST_Transform(geom,25832)))/10000000, geom  
FROM projekt."New_Pot" WHERE st_area>350;

有人对我有建议吗?提前提前!

I want to select all polygons with area more than 350 square kilometers from my initial polygons and tried ST_Area. But my polygons are in WKID: 25832 (UTM 32N) and I read that ST_Area always calculates in WGS 84 (EPSG 4326)....

I tried it like this but did not work.

DROP TABLE IF EXISTS projekt."Final_Selection";
CREATE TABLE projekt."Final_Selection" AS
SELECT (st_area/1000000), geom 
FROM projekt."New_Pot" WHERE st_area>350 ;

and like this:

DROP TABLE IF EXISTS projekt."Final_Selection";
CREATE TABLE projekt."Final_Selection" AS
SELECT (st_area(ST_Transform(geom,25832)))/10000000, geom  
FROM projekt."New_Pot" WHERE st_area>350;

Does anyone have an advice for me? Thx in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁绊已千年 2025-02-09 14:37:11

如果您想在SQM中选择几何形状,则使用使用地理而不是几何

默认情况下的地理类型区域是在平方米单位的球体上确定的。

SELECT * FROM projekt."New_Pot"
WHERE ST_Area(ST_Transform(geom,4326)::geography) >= 350000

注意:请记住,在中使用st_area,其中条款可能会大大减慢您的查询,因为该区域正在查询时间中计算。如果不是一次性查询,请考虑使用预计区域的区域创建索引,例如,

CREATE INDEX idx_geom ON projekt."New_Pot" (ST_Area(ST_Transform(geom,4326)::geography));

请参见:计算多边形的百分比在PostgreSQL中的缓冲区内

如果您想在给定半径内查询多边形:最简单的方法是将您的几何列转换为geagraphy ,从那里使用 st_dwithin ,它将与Geagraghy> Geograke <>地理 计算/code>参数:

SELECT * FROM projekt."New_Pot"
WHERE 
  ST_DWithin(
      ST_Transform(geom,4326)::geography, -- your geometry converted to geography
      ST_MakePoint(1,52)::geography,      -- a given point
      350000)                             -- a 350km buffer

相关帖子:将所有建筑物从指定的坐标范围内占5英里

If you want to select geometries by their size in sqm use ST_Area with geography instead of geometry:

For geography types by default area is determined on a spheroid with units in square meters.

SELECT * FROM projekt."New_Pot"
WHERE ST_Area(ST_Transform(geom,4326)::geography) >= 350000

Note: keep in mind that using ST_Area in the WHERE clause might slow down your query significantly, as the area is being calculated in query time. If it isn't a one time query, consider creating an index with the area pre-calculated, e.g.

CREATE INDEX idx_geom ON projekt."New_Pot" (ST_Area(ST_Transform(geom,4326)::geography));

See also: Calculate the percentage of polygon inside the buffer in postgresql

In case you want to query polygons within a given radius: the easiest way would be to convert your geometry column to geography and from there use ST_DWithin, which will calculate the distance in metres when used with geography parameters:

SELECT * FROM projekt."New_Pot"
WHERE 
  ST_DWithin(
      ST_Transform(geom,4326)::geography, -- your geometry converted to geography
      ST_MakePoint(1,52)::geography,      -- a given point
      350000)                             -- a 350km buffer

Related post: Getting all Buildings in range of 5 miles from specified coordinates

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文