EDIT : Faster processing direcly with geometries
From :

To :

With (description in the code comments) :
def buffer_dist(lyr_input, distance: int):
"""Create a buffer from the lyr_input at distance"""
result = processing.run(
"native:buffer",
{
"INPUT": lyr_input,
"DISTANCE": distance,
"SEGMENTS": 30,
"END_CAP_STYLE": 0,
"JOIN_STYLE": 0,
"MITER_LIMIT": 2,
"DISSOLVE": False,
"OUTPUT": 'TEMPORARY_OUTPUT'
}
)
return result["OUTPUT"]
def diff(lyr_input, lyr_overlay):
"""Make a diffence between lyr_input and lyr_overlay"""
result = processing.run(
"native:difference",
{
"INPUT": lyr_input,
"OVERLAY": lyr_overlay,
"OUTPUT": "TEMPORARY_OUTPUT"
}
)
return result["OUTPUT"]
# init the start layer, can be points, lines, polygons
# layer named in my QGIS project: "start"
lyr_start = QgsProject.instance().mapLayersByName("start")[0]
# init layer with obstacles, in my case a line layer
# layer named in my QGIS project: "obstacle"
lyr_obstacle = QgsProject.instance().mapLayersByName("obstacle")[0]
# if layer with obstacles is a line layer, create a small buffer around
lyr_obstacle_buffered = buffer_dist(lyr_obstacle, 1)
# set the walking distance
walking_distance = 100
result = lyr_start
# to each loop, add 1 unit until walking_distance
for i in range(walking_distance):
# add a buffer of 1 unit
result = buffer_dist(result, 1)
# make a buffer at 0 units to make the geometry valid
result = buffer_dist(result, 0)
# make a difference between the buffer and the obstacles
result = diff(result, lyr_obstacle_buffered)
# finally, add result in the project
QgsProject.instance().addMapLayer(result)
Fast version :
# init the start layer, can be points, lines, polygons
# layer named in my QGIS project: "start"
lyr_start = QgsProject.instance().mapLayersByName("start")[0]
# init layer with obstacles, in my case a line layer
# layer named in my QGIS project: "obstacle"
lyr_obstacle = QgsProject.instance().mapLayersByName("obstacle")[0]
# set the walking distance
walking_distance = 100
# create a red transparent rubberband to display result
rubber = QgsRubberBand(iface.mapCanvas(), QgsWkbTypes.PolygonGeometry)
rubber.setFillColor(QColor(255, 0, 0, 200))
# create the obstacle buffer
for i, obstacle_feat in enumerate(lyr_obstacle.getFeatures()):
# first loop, create the buffer from first line
if i == 0:
obstacles = obstacle_feat.geometry().buffer(1.1, 30)
# for the next loops, combine the buffer with the previous obstacles geometry
else:
obstacles = obstacles.combine(obstacle_feat.geometry().buffer(1.1, 30))
# iterate over start layer features
for start_feat in lyr_start.getFeatures():
# init walking_buff
walking_buff = start_feat.geometry()
# to each loop, add 1 unit until walking_distance
for j in range(walking_distance):
# add a buffer of 1 unit
walking_buff = walking_buff.buffer(1, 30)
# make the geometry valid
walking_buff = walking_buff.makeValid()
# make a difference between the buffer and the obstacles
walking_buff = walking_buff.difference(obstacles)
# add walking buffer to the rubberband
rubber.addGeometry(walking_buff, lyr_start.crs())