How can I programmatically stretch a Terrain?

I’m attempting to achieve a low-resolution terrain by importing a small (32x32) heightmap into a TerrainData via the SetHeights() function and then somehow scaling the resulting terrain so that it covers more area (256x256) with the same number of vertices. I need to do this programmatically rather than in the editor because the landscape must be procedurally-generated at runtime.

I’ve attempted to do this by setting the TerrainData HeightmapResolution and size to 33 initially, then setting the size again after calling SetHeights(). This seems to cause the edges of adjacent terrain tiles to no longer line up, so I must be doing something wrong here.

Any advice on this would be greatly appreciated, even if it requires an entirely new approach.

Edit: Better description.

I figured out why the edges weren’t matching up. It’s peculiar, but in order to scale a terrain you must do it AFTER the the terrain gameobject is enabled.