Terrain.SetAlphamaps Question

I am having trouble understanding the SetAlphamaps usage, I currently have a script that changes the texture of the terrain surrounding an object. see bellow;

public Terrain myTerrain;
private TerrainData myTerrainData;
public GameObject test;
public int ranage = 1;

void Start ()
{
	myTerrainData = myTerrain.terrainData;

	int mapx = (int)(((test.transform.position.x - myTerrain.transform.position.x) / myTerrainData.size.x) * myTerrainData.alphamapWidth);
	int mapz = (int)(((test.transform.position.z - myTerrain.transform.position.z) / myTerrainData.size.z) * myTerrainData.alphamapHeight);

	float[,,] map = new float[myTerrainData.alphamapWidth, myTerrainData.alphamapHeight, 3];

	for (int y = mapx - ranage; y < mapx + ranage; y++)
	{
		for (int x = mapz - ranage; x < mapz + ranage; x++)
		{
			map[x, y, 0] = 0;
			map[x, y, 1] = 1;
		}
	}
	myTerrainData.SetAlphamaps(0, 0, map);
}

result:

I would like this code to leave all the black zone as the default texture, even better would be to only change the yellow zone and not compute the rest of the terrain for efficiency sake. I have red the unit docs but its rather small and not understandable.

Any help or pointing in the right direction would be a massive help, thank you!

Huzza! After quite some time i have figured this terrain stuff out, here is the code for any one who wants it.

public Terrain myTerrain;
public GameObject test;
private TerrainData myTerrainData;

void Start()
{
	myTerrainData = myTerrain.terrainData;

	int mapMaxX = 20;
	int mapMaxZ = 20;

	float[,,] map = new float[mapMaxX, mapMaxZ, 3];

	// For each point on the alphamap...
	for (var y = 0; y < mapMaxZ; y++)
	{
		for (var x = 0; x < mapMaxX; x++)
		{
			map[x, y, 1] = 0;
			map[x, y, 1] = 1;
		}
	}

	int mapX = (int)(((test.transform.position.x - myTerrain.transform.position.x) / myTerrainData.size.x) * myTerrainData.alphamapWidth);
	int mapY = (int)(((test.transform.position.z - myTerrain.transform.position.z) / myTerrainData.size.z) * myTerrainData.alphamapHeight);

	myTerrainData.SetAlphamaps(mapX, mapY, map);
}

result: