Get height value at specific x and y coordinate via script
Precisely speaking you need some sort of collision detection look at this book and this link for more info.
Roughly speaking ray casting  is a good way; but be careful about optimization.I suggest you to compare x-y bounding boxes of your objects and groundObjects (using bpy.data.objects['Cube'].bound_box
). If they overlap each other do raycasting for each vertex of your objects on the overlapping groundObjects and choose the shortest one.