The coordinates are the X and Y coordinate of the terrain, not the world position. The lower-left corner of the terrain is coordinate 0, 0.
World position to terrain coordinate is usually something like this:
int x = Round( (pos.x - terrain->resolution.x / 2) / terrain->scale.x );
int y = Round( (pos.z - terrain->resolution.y / 2) / terrain->scale.z );
x = Clamp(x, 0, terrain->resolution.x - 1);
y = Clamp(y, 0, terrain->resolution.y - 1);