【问题标题】:how to select a specific region from within a multipoint plane in postgis?如何从postgis的多点平面内选择特定区域?
【发布时间】:2018-11-30 00:39:22
【问题描述】:

以下是一些带有 x y 和 z 值的测试数据(应该代表物理世界中的图像像素位置,但这是一个可以使用的小示例)。

-- create a table wtih geom as the geometry type column    
CREATE TABLE spatial_table (geom geometry);
     -- insert 3d points
    INSERT INTO spatial_table VALUES ('MULTIPOINT(1 0 800, 2 3 152, 1 2 300, 1 5 234234, 5 3 123123)')

现在,我可以使用以下查询从中提取所有点:

      SELECT * from st_x(st_geomfromewkt(SELECT ST_AsText( (ST_Dump(geom)).geom)
FROM spatial_table))

但是假设我想要一个特定区域,我知道该区域的 x 和 y 边界。如何做到这一点?

【问题讨论】:

    标签: python sql postgresql gis postgis


    【解决方案1】:

    利用st_makeenvelope(xmin, ymin, xmax, ymax, srid)

    以下示例:

    SQL 查询:

    select p.id
    from (values (st_geomfromtext('Point (34.5430 48.3706)'),'C'),
    (st_geomfromtext('Point (34.0136 48.4661)'),'B'),
    (st_geomfromtext('Point (33.6983 48.2173)'),'A'),
    (st_geomfromtext('Point (34.0628 48.1450)'),'G'),
    (st_geomfromtext('Point (33.7562 47.8586)'),'F'),
    (st_geomfromtext('Point (34.0686 47.6388)'),'E'),
    (st_geomfromtext('Point (34.4562 47.9599)'),'D'),
    (st_geomfromtext('Point (34.1235 47.8528)'),'H')) p(geom, id)
    where st_within(p.geom, st_makeenvelope(33.9327, 47.7892, 34.6645, 48.2434))
    

    返回 G、D、H

    【讨论】:

      猜你喜欢
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-17
      • 1970-01-01
      • 2017-02-14
      相关资源
      最近更新 更多