PostGIS计算缓冲区内点的个数

    技术2022-07-11  96

    sql语句:

    select count(id) AS total from t_point where st_within(ST_Transform (geom, 3857), ST_Buffer(ST_Transform(ST_GeomFromText('POINT(116 40)', 4326), 4326), 1000)) # 半径为1000米

    sqlalchemy:

    from sqlalchemy import func condition = func.ST_within(func.ST_Transform(ST_GeomFromText('POINT(116 40)', 4326), 3857), func.ST_Buffer(func.ST_Transform(Tpoint.the_geom, 3857), 1000)) count = db.session.query(func.count(Ship.id)).filter(condition).scalar()
    Processed: 0.010, SQL: 9