The Spatial Organization of Agriculture: Theory with Applications to Agricultural Research, Trade with China and Deforestation in Brazil