Random Spawn Safe Distance from Player?

Hello,
I have enemies spawning randomly within the scene, occasionally the enemies spawn on or unavoidably close to the player, instant death! I don't think I can randomly spawn the enemies relative to the player as the player can move around most of the scene, thus sometimes enemies would spawn offscreen, which I can't have happen.
So, how can one randomly spawn enemies in the scene a safe distance from the player?
I have enemies spawning randomly within the scene, occasionally the enemies spawn on or unavoidably close to the player, instant death! I don't think I can randomly spawn the enemies relative to the player as the player can move around most of the scene, thus sometimes enemies would spawn offscreen, which I can't have happen.
So, how can one randomly spawn enemies in the scene a safe distance from the player?
Comments
If you want them a safe distance from your player, you might want to divide your screen into quadrants or halves, then spawn in the area your player is not in. Eg:
Rule: if playerPositionX >240
spawn the enemy at x = Random (0, 200)
otherwise
spawn the enemy at x = Random (280, 480)