It can be a home-based job if that's what you want it to be. You can have a home office space that you use for writing, just like the majority of book authors.
Some big-name screenwriters may have a separate office that they go to do writing and take meetings, so that they can keep their home life separate (spouse, kids playing, etc.). These are the writers making six and seven figures. You've read about them, no doubt.
Some of these A-list writers may also be credited as a producer or executive producer on the production and their screenwriting identity in contracts might be the name of their production company, which also is done for legal and tax reasons (sole proprietor vs corporation status).
WGA contracts may allow the screenwriter, at the producers' expense, to visit the set during production and make changes if called upon to do so. Again, such writers may more likely also have an additional credit, or they may have a good working relationship with the producers or director from past films and the writer's/s' presence is appreciated and useful. Also, the production might be shooting locally, so a visit might be easy, as opposed to 5,000 miles away.
If you are just a spec writer typing out low budget indie stuff, and can communicate online directly to the production quickly if needed, then you can live anywhere these days and you needn't worry about having to take time off, and possibly be fired from, your REAL job to be on the set during shooting. No one's going to pay maybe up to or over a thousand dollars to fly a writer out and house him/her if all they're paying for the script is low to-mid thousands in the first place. Stay put and all will communicate via online.
There's only so much research you can do online for a story, so you may have to physically leave your home to visit libraries or locations in some instances, or interview people, just like book authors do.