使用QGIS(我认为任何版本都可以)和在DB Manager中使用非常简单的SQL语句来实现,这相当简单。但是为此,您必须将其存储在某种空间数据库中(Postgis或spacespaceite)。由于大多数人都更容易使用,因此我假设使用spacespaceite,但是Postgis的SQL语句相同。
- 创建一个新的Spatialite数据库;
- 将点和面图层导入到新数据库中;
- 打开数据库管理器插件,选择数据库并运行以下SQL语句之一:
所有点到所有多边形边界的距离
SELECT
f.point_id,
g.polygon_id,
st_distance(g.geom, f.geom) AS distance
FROM
points_table AS f,
polygons_table AS g
到相关多边形边界的所有点的距离(假设存在一个公共字段)
SELECT
f.point_id,
g.polygon_id,
st_distance(g.geom, f.geom) AS distance
FROM
points_table AS f JOIN
polygons_table AS g ON (g.common_field = f.common_field)
到相关多边形质心的所有点的距离:
SELECT
f.point_id,
g.polygon_id,
st_distance(f.geom, st_centroid(g.geom)) AS distance
FROM
points_table AS f JOIN
polygons_table AS g ON (g.common_field = f.common_field)
注意,您可以将图层中的任何字段添加到结果中:
SELECT
f.point_id,
f.point_number,
g.polygon_id,
g.parcel_name,
st_distance(f.geom, st_centroid(g.geom)) AS distance
FROM
points_table AS f JOIN
polygons_table AS g ON (g.common_field = f.common_field)
甚至所有领域:
SELECT
f.*,
g.*,
st_distance(f.geom, st_centroid(g.geom)) AS distance
FROM
points_table AS f JOIN
polygons_table AS g ON (g.common_field = f.common_field)