I have no idea whether this has any connection whatever, but when Francisco Pizarro's underfed and sickly fellows wanted to get back to Panama rather than keep trying to find a new empire to conquer, he actually drew a line in the sand (in the beach of Isla del Gallo) an said more or less, 'on this side (south = on to Peru) you'll find toil, hunger, nakedness, and storms, and death; on the other (north = back to Panama) ease and pleasure (...) por aquí se ba à Panamá à ser pobres, por alla al Perú à ser ricos. Now choose as a brave Castilian should. For me, I'll go southward'. (Montesinos, Annales, MS. year 1527)
As to the meaning, according to the current Webster,
draw the line or draw a line 1 : to fix an arbitrary boundary between things that tend to intermingle 2 : to fix a boundary excluding what one will not tolerate or engage in
in other several other languages there are similar expressions, usually restricted to "cross this line (that is, ignore what I'm telling you) and you'll have to pay for it"