Structures on a Procedural Landscape

I’m currently working through a course project for school and I’m trying to procedurally generate the ground terrain, which I have working. However, I’d like to establish walls around the ground that line up with the terrain to create an arena and have my structures that make up the map not get “eaten” by the terrain’s undulation on the z axis.

I think I can fix the structures by setting up a line trace from the “corners” of the structures and accept the longest trace and set the location equal to that on the z-axis. This would cause some overlap of the undulation, but would minimize it. However, I can’t seem to figure out how to setup the line trace properly.

The walls, I am unsure of the best method of setting them up, but I suppose I could just find the boundaries of the terrain and just create super big walls in static positions.