When in geography one reconstructs individual behavior starting from aggregated data through ecological inference, a crucial aspect is the spatial variation of individual behavior. Basic ecological inference methods treat areas as if they were all exchangeable, which in geographical applications is questionable due to the existence of contextual effects that relate to area location and induce spatial dependence. Here that assumption is avoided by basing ecological inference on a model that simultaneously does a cluster analysis, grouping together areas with similar individual behavior, and an ecological inference analysis in each cluster, estimating the individual behavior in the areas of each group. That allows one to capture most of the spatial dependence and summarize the individual behavior at a local level through the behavior estimated for each cluster. This approach is used to investigate vote switching in Catalonia, where voters split across a national allegiance divide on top of the ideological divide. That leads to Catalans having a lot of options to choose from, and to them voting differently depending on whether the election is for the Catalan parliament or for the Spanish parliament. To investigate that, the results in the two most recent pairs of such elections are analyzed by simultaneously clustering areas based on the similarity of their vote and vote switch patterns, and estimating one vote switch pattern for each cluster. As a result, Catalonia is partitioned into four clusters that have a strong spatial structure, with all the areas in the same cluster having similar demographic composition. The estimated vote switch patterns are quite different across clusters but very similar across pairs of elections, and they help assess how the differential voter turnout and the strategic dual vote effects vary in space.