you can find the "infinite terrain" script in samples folder. it places sprites and models onto terrain at random positions in a given qusantity.
if you want to cover only a specific area of the terrain, you should use c_trace with SCAN_TEXTURE to check which texture is hit at given position, or tetxure colour at hit position.