Throughout history, this chestnut has come in and gone out of fashion, for every Mark Twain and Jack London that went West, there's been a Shakespeare and Edmund Spencer.that wrote of the fantastical while sitting at a desk.
Of course today there's a whole genre of Literature of thinly-veiled autobiographies with the serial numbers scrubbed off. These seem to also be the favored sons of several Literature awards.
For a time there was even a vanity publisher website that told prospective customers to avoid any writing advice from genre writers since they know nothing about writing since they had the temerity to break this "cardinal" rule.
You know what happens when you insult an entire industry of writers? Especially one whose livelihood rests on their capacity for excess imagination and creativity?
But why take that advice literally. Seriously, who does that?
That's why good genre writers spend so much time world building and researching.
While they can't visit another planet or an alternate history where "Native American" tribes called on spirits to jettison the colonists, they can research the historical and scientific data to create a exotic and plausible setting.
But an exotic setting, is only but part of a good story.
Beyond just a good setting, it needs to be filled with believable characters that act with an internal consistency. And for that you can always write what you literally know, drawing inspiration and education from the people in your life.
This hits on the paradox of being a good writer. While you've got to sequester yourself away to be a keyboard monkey, you can't write about the human condition, regardless of the reality you're in, unless you meet and interact with people.
So in that case, when it comes to the heart of the story -- regardless of the genre icing on the cake -- then you do need to write the characters you know.