[Qgis-user] Closest Distance of a point within a polygon to the closest part of that polygon and the name of the adjacent polygon with the common boarder

Reginald Reginald.Carlier at ingelmunster.be
Fri Jul 10 06:13:32 PDT 2020


Hi,

Yes the easiest way is to densify your polygons. With the desify algo you
can do this and specify how dense you want them to be.
processing.run("native:densifygeometries",
{'INPUT':'C:\\Users\\reginaldc\\Documents\\testdensify.gpkg|layername=testdensify','VERTICES':1000,'OUTPUT':'TEMPORARY_OUTPUT'})
Next you can create a line from your polygon. This line will contain the
same amount of vertexes as your polygon.
processing.run("native:polygonstolines",
{'INPUT':'memory://Polygon?crs=EPSG:31370&field=fid:long(0,0)&uid={8ed5e288-ec55-4630-aaf8-8f26a1e1c5cc}','OUTPUT':'TEMPORARY_OUTPUT'})
Next you create points from your line.
processing.run("native:extractvertices",
{'INPUT':'memory://MultiLineString?crs=EPSG:31370&field=fid:long(0,0)&uid={1b672349-4d50-44b6-b4b4-98bb6218d3ce}','OUTPUT':'TEMPORARY_OUTPUT'})
Then you look for the distance of the closest vertex
processing.run("qgis:distancetonearesthubpoints",
{'INPUT':'C:\\Users\\reginaldc\\Documents\\testdensify.gpkg|layername=testpunten','HUBS':'memory://Point?crs=EPSG:31370&field=fid:long(0,0)&field=vertex_index:integer(10,0)&field=vertex_part:integer(10,0)&field=vertex_part_index:integer(10,0)&field=distance:double(20,14)&field=angle:double(20,14)&uid={629995db-9019-47f2-9c4b-72523ff6fc9e}','FIELD':'vertex_index','UNIT':0,'OUTPUT':'TEMPORARY_OUTPUT'})
Finally you make a buffer a little bit greater than this distance in the
direction of the closest vertex (angle is also in the attribute table.

Regards,




--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html


More information about the Qgis-user mailing list