Flashing factory image - all data still present I've just flashed my Nexus5 with Android 5.1 factory image using this how to:

http://www.droid-life.com/2013/11/05/how-to-flash-nexus-5-factory-images/

I've made a complete backup off all my data since I was sure I'll loose it.
Also the how to states:


  "*Flashing factory images wipes your phone completely clean, leaving
  it at a factory, out-of-the-box state."


This also happened after flashing my Note 4 with Android 5 withe the rom downloaded from sammobile.com. (flashed via Odin)

So - why is all my data (photos, apps, calendar/contacts) still present after flashing the new rom?
The apps and user data (everything that gets erased by factory reset) are contained within the /data partition (in fact, "factory reset" simply formats the /data partition). This partition is independent of other partitions. Android system is located on the /system partition. That means that, as long you don't wipe your /data partition, your apps and data will stay in the phone even when you change your Android version.

It is, however, recommended to wipe your /data partition when moving from one Android version to another, due to incompatibility issues.