I a looking to plot out my new garden site for next year and am wondering how far I need to be away from some nearby trees. The trees are a few different types (apple, oak, pine etc.) and anywhere from 20-40 feet tall. I am trying to see if there is a way to tell/guess how far the roots will reach before I start digging and find out the hard way.
The roots of most trees are shallow (i.e., not more than 1' to 1.5' deep), but spread out very wide (see the picture below from here) . Given the height of your trees, they're not very young and you can be sure that the roots spread at least as far out as the tree is tall. Add a factor of half to that for every 10 years of the tree's life. Note that this is only a rough approximation and if you need a better estimate, you'll have to contact an arborist.
However, your trouble is going to be finding out where the roots are. I'm afraid you'll have to find that out only the hard way. In some cases, you can get an indication of which direction the primary roots radiate by looking at the base of the trunk, but not any more.
I've never found a need to leave that much space around a tree. As long as you don't dig too close to the tree, you'll be pretty fine planting stuff like 4-5 feet away from it (if you hit a root, then just dig a little to the side of it). Also, the further out you go, the lesser you'll have to worry about damage to the tree from digging. Trees can easily take a hit in few of their tertiary roots and not even be aware of it.
bstpierre makes a very good point that Oak has a tap root which grows deep downward instead of out (think carrots). In this case, the foot print will be a lot smaller.
Also, another common rule of thumb is that the roots spread out 2-3x times the crown width. This is very true in the fig family and the like, where the trees grow moderately in height, but have a wide canopy like crown. See this page at Iowa State University Extension for more details.
We grow vegetables in an area about 16' square, in raised beds. Several years after we started, the garden became a disaster - we just couldn't get anything to grow well in most of the garden. Eventually, I figured out that some nearby Norway maples had taken over most of the soil - coming up from the bottom of the beds. For several years I kept digging the roots out of the beds, but they just kept coming back.
Eventually, I got the idea to try to keep them out altogether. I now dig around the garden with a pickax every 2-3 years on the bad-tree sides. I get down 9-12 inches. I've been amazed at the size of the roots - some as much as an inch-and-a-half - given how far the trees are. I cut finger-sized roots with pruning shears, and use a pruning saw for the really big ones. Trying to break good-sized roots with a pickax is a great way to hurt your back.
The worst offenders are some mature Norway maples that are about 35 feet away from the edge of the garden. They are downhill from the garden - I wonder if the roots can "smell" the nutrient stream from the garden and go there preferentially. Norway Maples are notorious for aggressive roots.
If you're concerned, you might try trenching with a pickax around the perimeter before you dig the garden. You might just sample a few areas that you're most concerned about. Because the pickax has such a thin blade, it's not too hard - unless you find roots.
I considered trenching and installing some landscape fabric (vertically) that's supposed to deter roots. It's impregnated with copper. I'm concerned about ingesting the copper via the vegetables, so I opted not to use it. Your mileage may differ.
I had a sugar maple in the front yard. It was cut down 2 months ago. The roots of that tree caused me big problems and a lot of work. A 5 inch diam root 2 1/2 feet in the ground grew tight against my basement wall and the pressure of the root buckled the wall, which i am repairing now.
The tree had always been trimmed, so it would be hard to say how big the crown was. The tree trunk on the bottom was 54 inches in diameter. The tree was 30 feet away from the house and now I find it was too close and caused me a lot of damage and work.
My recommendation: never plant trees that close to any building.
I have a raised bed 3' tall. The fig tree 20 feet away grows roots into it and completely takes over the entire bed - and so YES roots grow UP into raised beds in contrast to the assertion made by another post here. I dug 12" trench around it last year and found a 2.5" diameter root. I chopped it off. This spring I find that the whole bed is filled with roots all over again. I dig 12" around and find no roots - so I guess now I have to dig deeper. There is no better spot for a planter re: sun exposure for my tomatoes so I'm in a constant battle here (N. CA)