You can iterate through tiles in a tile layer in one of two ways.
for tile in map.layer[x].<iterator name>() do
-- Do something to object
end
layer.tilesInRange(x, y, w, h): Iterates through tiles in a chunk with its left and top coordinates at (x, y), and (width, height) (w, h).layer.tilesInRect(x, y, hw, hh): Iterates through tiles in a rectangle centered at (x, y), and (width, height) as (2hw, 2hh). This means that hw and hh work as a sort of "radius" for the rectangle.