I'm not going to flatly disagree with the age-old, well-worn adage to write what you know. I do, however, want to go out on a thin limb and offer a slight spin on it. We'll call the spin Mughal's Amendment, which states: "Extrapolate and interpolate from what you know."
If I had limited my writing to the original adage of writing what I know, I could not have had a key character in my first novel go through a detailed experience of death. After all, I haven't died so I don't "know" the experience. I've never met a being from outside of earth (as far as I know), but extraterrestrials play a significant role in my second novel. Again, I couldn't create a physical description or the psyche of these characters from what I know.
So what did I do to create these components of my fiction? In the case of a character experiencing death, I extrapolated and interpolated from what I'd read and heard about near death experiences. I coupled these anecdotal data with my understanding of several world religions. To create aliens, I used scientific conjectures regarding extraterrestrials while simultaneously pressing the boundaries of the basic theories of physics, biology, quantum mechanics, astronomy and special and general relativity.
My apologies to the literary orthodoxy for not binding my fiction to the strictures of "write what you know." Indeed, writing fiction is most enjoyable when I'm not writing what I know but when I'm writing from what I know, projecting into new syntheses, those enticing and unproven conjectures that lie both beyond and in between known facts.
To access data beyond known facts, extrapolate.
To access data in between known facts, interpolate.
Hence the amendment: "Extrapolate and interpolate from what you know." The between and the beyond are each an abode of our most interesting intellectual suppositions. And if it's nothing else, your writing must at least be interesting.