Created
August 17, 2021 20:50
-
-
Save pigreco/add15756a2373f43486b1e81f84cbda6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with_variable('andy', | |
array_foreach( array_foreach( | |
generate_series(1,num_geometries(segments_to_lines($geometry))), | |
centroid(geometry_n(segments_to_lines($geometry),@element))), | |
distance(@element, overlay_nearest('roads',$geometry)[0])), | |
/*shortest line*/ | |
shortest_line( | |
array_foreach( | |
generate_series(1, num_geometries( segments_to_lines($geometry))), | |
centroid(geometry_n(segments_to_lines($geometry),@element))) | |
[array_find( @andy,array_min(@andy))], | |
overlay_nearest('roads',$geometry)[0]) | |
) |
Another solution is the following:
- I extract the centroids of the building edges:
collect_geometries (array_foreach (
generate_series (1, num_geometries (segments_to_lines ($geometry)))),
centroid (geometry_n (segments_to_lines ($geometry), @ element))))
- I draw shorter line between centroids and street:
shortest_line ($geometry, overlay_nearest ('roads', $geometry) [0])
verify:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/spatialthoughts/status/1430069916208566274