October 26, 2026
Socio-spatial segmentation of Valinhos by clustering census data
Regiane Aparecida Rodrigues Calixto; Lauro Marques Vicari
DOI: 10.22167/2675-6528-202603395
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
The understanding of intra-urban inequalities proved relevant for territorial planning and the formulation of public policies. Groupings of census tracts in the municipality of Valinhos were identified and characterized, based on income, literacy, and urban infrastructure indicators. A quantitative approach was adopted, using secondary data organized by census tract. The data were integrated into a single analytical base, subjected to processing, standardization by the Z-score method, and cluster analysis using the K-means algorithm. The definition of the number of groups was supported by the Elbow method, complemented by internal validation metrics and analysis of variance. The results indicated the formation of five territorially distinct clusters, revealing socio-spatial heterogeneity in the municipality. Basic sanitation, especially sewage disposal, showed greater power of discrimination between groups, followed by access to water, literacy, and income. The coexistence of areas with more favorable conditions and sectors marked by specific vulnerabilities was observed, reinforcing the multidimensional nature of urban inequality. The application of data science techniques to census tracts allowed for the production of a more refined territorial diagnosis, useful for supporting more focused public decisions that are coherent with local needs.
Keywords: Clustering; Socio-spatial inequality; Urban infrastructure; Territorial planning; Census tracts.
1. Introduction
The understanding of territorial inequalities plays a central role in the debate on urban planning, local development, and public policy formulation. In municipal contexts, differences in income, schooling, and access to basic infrastructure are not homogeneously distributed in urban space, which requires analytical approaches capable of identifying territorial patterns and supporting more precise decisions (Cunha, 2006; Torres, 2003).
In Brazil, this discussion is particularly relevant because aggregate indicators at the municipal level can hide pockets of deprivation and significant intra-urban contrasts, especially in cities integrated into metropolitan dynamics and marked by selective urbanization (Maricato, 2015; Taschner, 2004). In this direction, the use of census tracts expands the capacity to read the territory, as it corresponds to the smallest spatial unit for collecting and disseminating the Demographic Census, allowing for the capture of heterogeneities that would tend to disappear at more aggregated scales (IBGE, 2024).
The analysis of this study dialogues with the multidimensional approach to social vulnerability, consolidated by the Social Vulnerability Index (SVI), developed by the Institute of Applied Economic Research (IPEA). From this perspective, phenomena such as poverty, exclusion, and deprivation do not arise solely from income insufficiency, but from the combination of assets available to families and the structure of opportunities offered by the territory, including urban infrastructure, human capital, and conditions for social and economic integration (Kaztman, 2000; Costa et al., 2015; Costa, 2018). This reference is especially important because it allows us to understand the accumulation of disadvantages as a relational and territorialized phenomenon, and not as a simple isolated monetary lack.
Among the most recurrent factors in the characterization of territorial inequality, household income, literacy levels, and basic sanitation indicators, such as access to water, sewage disposal, and waste collection, stand out (IPEA, 2015; Costa et al., 2015). The selection of these variables (income, education, and sanitation) comprises the tripod of vulnerability, as established by the Social Vulnerability Index (IPEA, 2015; Costa et al., 2015). This structure makes it possible to identify distinct territorial profiles and interpret socio-spatial inequality in an empirically consistent way.
From a methodological point of view, cluster analysis has proven to be an essential tool for investigating structures in multivariate databases, allowing the formation of internally similar and externally distinct groups. Clustering is defined as an unsupervised classification procedure aimed at organizing observations into groups based on similarity measures, being particularly useful in exploratory studies with a large volume of information (Jain et al., 1999). In the applied field, the use of the K-means clustering algorithm, together with dimensionality reduction by Principal Component Analysis (PCA), allows for the stratification of territories based on socioeconomic and infrastructure indicators. The robustness of these solutions, however, depends on the theoretically justified selection of variables, the careful definition of the number of groups, and the use of internal and comparative validation metrics (Halkidi et al., 2001).
On an empirical level, Valinhos is a pertinent object for this type of analysis as it brings together characteristics associated with both good average indicators and relevant internal contrasts. Located in the Metropolitan Region of Campinas, the municipality combines a dynamic of urban expansion, the presence of valued areas, and pockets of precariousness. Valinhos offers adequate conditions to investigate how intra-urban inequalities remain hidden when only the municipal average is observed. This condition reflects the configuration of the cities in the interior of São Paulo, marked by social fragmentation where aggregated indicators smooth out critical disparities, requiring analyses that reach the intra-municipal scale to reveal the heterogeneity of the territory (Cunha, 2006).
Given this context, the objective of this work was to identify and characterize census tract clusters in the municipality of Valinhos based on income, literacy, and urban infrastructure indicators, through clustering techniques, in order to highlight territorial patterns of socio-spatial differentiation and generate analytical subsidies for local planning and public policy formulation.
2. Material and Methods
The research was designed with a quantitative approach, of an applied nature, and was characterized as descriptive and exploratory regarding its objectives. This classification was based on the pursuit of generating knowledge with potential for practical use in urban planning and public policy formulation, identifying and describing existing patterns in the data without establishing causal relationships (Gil, 2019; Vergara, 2016). The study used secondary numerical data and applied statistical and computational techniques for analysis (Marconi & Lakatos, 2017).
The design adopted was a case study, focused on the municipality of Valinhos, located in the Metropolitan Region of Campinas (RMC), in the interior of the state of São Paulo. This choice allowed for an in-depth investigation of the phenomenon in its real context, examining how intra-urban inequalities manifest in a municipality with favorable average indicators, but with relevant internal contrasts (Yin, 2015).
The central unit of analysis was the census tracts of the Brazilian Institute of Geography and Statistics (IBGE), totaling 228 tracts that make up the territory of Valinhos. The adoption of this micro-territorial scale proved compatible with the nature of the applied techniques, allowing the identification of patterns in the municipal reality that would be obscured at broader levels of aggregation, such as neighborhoods or districts.
For the construction of the analytical base, secondary data from the 2022 Demographic Census were used, aggregated by census tract and from spreadsheets of the IBGE census universe (IBGE, 2022). The active variables selected for the formation of the clusters were: RENDA_MEDIA (average nominal monthly income of household heads), TAXA_ALFAB (literacy rate of people aged 15 or over), TAXA_AGUA (rate of households with general network water supply), TAXA_ESGOTO (rate of households with sewage disposal via general network, rainwater, or septic tank) and TAXA_LIXO (rate of households with direct collection or dumpster collection).
The selection of these variables was guided by references that address urban inequality as a multidimensional phenomenon, prioritizing indicators that express economic capacity, basic population qualification, and access to essential urban services (Kaztman, 2000; Costa et al., 2015; Costa, 2018). Additionally, supplementary variables were considered for the interpretation of the groups, such as SEM_BANHEIRO (proportion of residents in households without a bathroom or toilet), SEM_AGUA_ENC (proportion of residents in households without piped water), and TAXA_CORTICO (proportion of households classified as tenements).
The treatment and integration of the data were carried out in a Python environment and comprised five stages: extraction of the 228 census tracts, renaming of columns to intelligible analytical names, conversion of fields to numeric format (float or int), verification of inconsistencies, and integration of tables through the census tract code. In the consistency stage, 14 records with missing or insufficient values were removed from the final analytical base, aiming to ensure the integrity and comparability between observations (Hair et al., 2014).
After integration and processing, the active variables were standardized using the Z-score method. This procedure consisted of transforming the variables so that they presented a mean equal to zero and a standard deviation equal to one, preventing variables with greater magnitude from disproportionately influencing the clustering process, since algorithms such as K-means are sensitive to data scale (Jain et al., 1999).
For the identification of territorial groupings, the K-means algorithm was used, an unsupervised clustering technique widely disseminated in the literature of multivariate analysis and data mining (Jain et al., 1999; Hair et al., 2014). The algorithm distributes observations into K mutually exclusive groups, seeking to minimize the internal variability of the clusters, that is, the sum of the squares of the distances between each observation and the centroid of the group to which it was assigned.
The execution of K-means was iterative, with the definition of initial centroids, assignment of observations to the nearest centroid, and recalculation of centroids until the objective function stabilized. To reduce the method’s sensitivity to initialization, repetition procedures and randomness control were adopted (Hastie et al., 2009; James et al., 2021). The definition of the number of clusters was supported by the Elbow method, which consists of analyzing the variation of the within-cluster sum of squares as a function of the number of groups, identifying the inflection point of the curve where additional gains become marginal (Halkidi et al., 2001).
The statistical validation of the groupings was performed through Analysis of Variance (ANOVA) to verify if the means of the variables differed significantly between the formed groups, evaluating the discriminant power of the variables (Hair et al., 2014). Subsequently, the groupings were subjected to Principal Component Analysis (PCA), a technique that allowed for the reduction of the dataset’s dimensionality and the visualization of the census tracts in a two-dimensional plane (Hair et al., 2014).
The obtained clusters were interpreted from the means of the variables in each group, allowing the characterization of territorial profiles. This stage sought to associate the quantitative results with substantive interpretations, relating the identified patterns to the socioeconomic and infrastructure conditions of the census tracts, according to the multivariate analysis literature (Hair et al., 2014). The spatialization of the clusters was carried out using QGIS software, integrating the analytical base with the geographic mesh.
3. Results and Discussion
The analysis of census data from the municipality of Valinhos, using the K-means clustering technique, revealed the existence of distinct territorial patterns, confirming intra-urban socio-spatial heterogeneity. Initially, the definition of the number of clusters was guided by the Elbow method, which indicated the formation of five clusters as the most balanced solution. This inflection point in the inertia curve, which represents the sum of squared errors within clusters, showed a sharp reduction in error up to K=5, with marginal gains thereafter. This result provided a robust empirical justification for the choice, reconciling statistical rigor with applicability in urban planning, according to the literature on clustering (Halkidi et al., 2001).
The interpretation of the solution with five groups represented a satisfactory balance between reducing the internal heterogeneity of the clusters and maintaining an analytically interpretable structure. The choice of K=5 was not an arbitrary decision, but resulted from the convergence between the evidence from the Elbow method and the substantive reading of the emerging territorial profiles. This methodological approach strengthened the robustness of the segmentation, preventing the formation of groups from being perceived as a mere product of mechanical decisions (Hair et al., 2014). The visualization of the census tracts on the plane of the first two principal components, obtained through Principal Component Analysis (PCA), also corroborated the separation and spatial coherence of the groups, synthesizing the variability of the indicators.
The distribution of census tracts among the obtained groups demonstrated that the clusters were not formed by an artificial division of the data, but reflected effective patterns of similarity and differentiation. This configuration reinforced the interpretation that the municipality of Valinhos has relevant intra-urban heterogeneity, with the coexistence of relatively similar areas and others with more unique attributes. This finding corroborates the hypothesis that indicators aggregated at the municipal level tend to hide internal contrasts, justifying the adoption of the census tract as the unit of analysis for a more refined diagnosis (Cunha, 2006; Maricato, 2015).
The analysis of the quantitative distribution of census tracts by cluster revealed a segmentation with unequal sizes, which is consistent with the structure of the Valinhos territory. Cluster 3 concentrated the largest part of the sectors, with 144 units, representing 67.29% of the total analyzed, configuring the predominant profile in the municipality. The other clusters, 1, 2, 4, and 0, gathered, respectively, 31 sectors (14.49%), 23 sectors (10.75%), 12 sectors (5.61%), and 4 sectors (1.87%). This distribution indicates that most of the municipality shares relatively similar conditions, while smaller groups express more specific situations, including patterns of greater relative vulnerability, demanding disproportionate attention in public policies.
The characterization of each cluster, based on the means and standard deviations of socioeconomic and infrastructure indicators, allowed for an in-depth understanding of the territorial profiles. Cluster 1 stood out for its higher average income, reaching R$ 13,891.82, and a practically universal literacy rate of 99.47%, in addition to high infrastructure levels. This grouping can be interpreted as representative of territories with high socio-spatial insertion, reflecting areas with more favorable living conditions and access to urban services, in line with the literature on consolidated urban development (Costa, 2018).
Cluster 3, which encompassed most of the census tracts, presented an intermediate average income of R$ 4,397.97, combined with high indicators of literacy, access to water, sanitation, and waste collection. This profile suggests territories with a consolidated urban structure, where the supply of basic services is widely established. The predominance of this cluster in the municipality indicates that, although Valinhos presents good average indicators, homogeneity is not absolute, and there are important nuances that clustering managed to reveal.
In contrast, Cluster 2 revealed the worst results in basic sanitation, with only 28.78% access to piped water and 9.13% to sewage, in addition to a waste collection rate of 89.19%. This cluster also presented the highest supplementary rates of households without piped water (0.28%) and tenements (1.88%), configuring the group with the greatest sanitary vulnerability. Interestingly, the average income of this cluster, R$ 5,334.86, was higher than that of other groupings, reinforcing the idea that inequality in Valinhos cannot be measured solely by families’ monetary power, but by the combination of different deprivations, as pointed out by IPEA (2008) regarding multidimensional social vulnerability.
Cluster 0, although numerically small with only four sectors, presented the lowest average income (R$ 2,723.60) and the lowest literacy rate (82.25%). This profile suggests a fragility more associated with human capital and socioeconomic insertion than with basic sanitation infrastructure. Cluster 4, on the other hand, stood out for a specific deficit in waste collection, with an average of 42.48%, despite presenting good indicators in other dimensions. These findings demonstrate that social vulnerability takes on diverse and specific forms in the territory, requiring differentiated and focused public policies.
From an applied point of view, the developed cluster typology allows associating each group with distinct priorities for public intervention. For territories with health vulnerability (Cluster 2), recommended actions include the expansion and regularization of access to water and sanitation. In territories with educational and socioeconomic fragility (Cluster 0), policies for school reinforcement, active search, and expansion of qualification programs are relevant. For territories with deficiencies in urban cleaning (Cluster 4), priorities fall on the reorganization of collection, inspection, and operational improvement.
The territories with consolidated urban structure (Cluster 3) and high socio-spatial insertion (Cluster 1) can be treated as areas for maintaining service standards, preventive monitoring, and support for the municipality’s territorial balance. This differentiation of territorial profiles in Valinhos showed that inequality is not expressed uniformly but takes on distinct forms depending on the combination of income, human capital, and urban infrastructure. This result is consistent with the perspective of the Social Vulnerability Index (SVI/Ipea), which understands vulnerability as the overlap of fragilities in different dimensions and the unequal distribution of opportunities in the territory (Kaztman, 2000; Costa et al., 2015; Costa, 2018).
To verify the statistical support for the observed differences between groups, an analysis of variance (ANOVA) was performed. The results indicated that all variables – income, literacy rate, water rate, sewage rate, and waste rate – showed statistically significant differences between the clusters, with p-values below 0.001. The sewage rate registered the highest F statistic (731.51) and a partial eta squared of 0.933, evidencing its high discriminant power in differentiating the groups. This reinforced the interpretation that the segmentation captured effective structural contrasts of the territory, rather than random variations.
The ANOVA analysis allowed us to conclude that basic sanitation, especially sewage disposal, was the dimension that most differentiated the census tract clusters in Valinhos. This finding has substantive relevance, as it suggests that intra-urban inequality is not organized solely around economic attributes, but is strongly associated with urban infrastructure and the concrete conditions for the reproduction of daily life. The presence of high effects for literacy and income also indicated that the segmentation pattern was multidimensional, articulating material deprivation, human capital, and access to services, in line with the literature on multidimensional vulnerability (OECD, 2020).
The spatialization of the clusters, carried out through the integration between the analytical base and the geographic mesh, revealed clear territorial patterns in Valinhos. The concentration of Cluster 3 was observed in central areas, characterized by better infrastructure, socioeconomic conditions, and greater access to services. In contrast, Cluster 2 was distributed in peripheral regions, marked by low basic sanitation coverage, lower average income, and limitations in access to essential urban services. This pattern highlights intra-urban inequalities associated with the unequal distribution of urban infrastructure and sociospatial segregation, showing how urbanization can reproduce these inequalities in the territory.
The results obtained from the application of the clustering technique evidenced the existence of distinct territorial patterns in the municipality of Valinhos, confirming the hypothesis that intra-urban inequalities are not homogeneously distributed in space. The identification of five clusters with differentiated characteristics reinforces the relevance of using multivariate analysis methods in the investigation of complex socio-spatial phenomena, as highlighted by Hair et al. (2014). The predominance of an intermediate cluster, which concentrated more than two-thirds of the census tracts, suggests that a large part of the municipal territory presents relatively homogeneous conditions in terms of access to infrastructure.
However, the presence of smaller clusters, but with specific vulnerability characteristics, reveals that the aggregated analysis at the municipal level tends to mask relevant inequalities, reinforcing the importance of micro-territorial scale approaches (Costa, 2018; IBGE, 2022). The cluster identified as most vulnerable presented low levels of access to water and sanitation, evidencing that basic sanitation constitutes one of the main axes of territorial differentiation in the municipality. This finding is consistent with recent studies that highlight the centrality of urban infrastructure in the reproduction of socio-spatial inequalities (OECD, 2020).
Another relevant aspect concerns the identification of clusters with specific vulnerabilities, such as those associated with lower literacy rates or problems in solid waste collection. These results corroborate the perspective of multidimensional vulnerability, according to which different territories may present distinct combinations of deprivations, making it impossible to reduce inequality to a single explanatory variable (Costa, 2018; OECD, 2020). In this sense, the typology constructed in this study allowed us to highlight that vulnerability can take diverse forms, requiring differentiated approaches within public policies.
From the perspective of public management, the findings indicate the need for territorialized strategies, focusing on the expansion of the sanitation and water supply network in Cluster 2. For Cluster 0, strengthening educational and qualification policies is crucial. In Cluster 3, the maintenance and qualification of urban services are priorities, while in Cluster 4, the improvement of waste collection and management is fundamental. For Cluster 1, sustainable urban management policies and long-term planning are recommended, aiming at preserving the quality of services and reducing structural inequalities.
In summary, the application of clustering techniques to census data constituted an effective approach for identifying territorial patterns and understanding intra-urban inequalities in Valinhos. The results obtained evidenced the existence of distinct profiles in the municipality, characterized by different combinations of income, education, and access to infrastructure. This analysis contributed to a more in-depth reading of the territory and provided relevant analytical subsidies for local public management, allowing for a more refined and useful territorial diagnosis to support more focused and coherent public decisions aligned with local needs.
4. Conclusion
This study sought to identify and characterize clusters of census tracts in the municipality of Valinhos based on indicators of income, literacy, and urban infrastructure, using clustering techniques. The formation of five territorially distinct clusters was verified, which revealed significant socio-spatial heterogeneity in the municipality. It was observed that basic sanitation, particularly sewage disposal, exerted the greatest discriminatory power among the groups, followed by access to water, literacy, and income. The coexistence of areas with more favorable socio-spatial conditions and sectors marked by specific vulnerabilities was identified, such as Cluster 2, which presented the worst results in basic sanitation, and Cluster 0, with the lowest average income and literacy rate. This differentiation showed that intra-urban inequality in Valinhos does not manifest uniformly but assumes multiple dimensions, articulating material deprivation, human capital, and access to services.
The application of data science techniques to census tracts allowed for a more refined territorial diagnosis of Valinhos, offering analytical subsidies for urban planning and the formulation of more focused public policies. The cluster typology developed suggests distinct intervention priorities for each group, such as the expansion of sanitation in Cluster 2 and the strengthening of educational policies in Cluster 0. However, it is recognized that the research used secondary data and adopted an exploratory approach, which limits the inference of causal relationships between the analyzed variables. The results also depend on the selection of indicators and the methodological decisions employed, despite the validation procedures. For future studies, it is recommended to expand the set of variables, including health and urban mobility, in addition to applying other clustering techniques and comparative spatial analyses with other municipalities, aiming to deepen the understanding of inequality patterns and broaden the generalization of the findings.
Bibliographic References
Costa, M. A. (2018). Vulnerabilidade social no Brasil: conceitos, métodos e primeiros resultados para municípios e regiões metropolitanas brasileiras. Instituto de Pesquisa Econômica Aplicada (Ipea).
Costa, M. A.; Marguti, B. O.; Pirani, N.; Pinto, C. V. S. (2015). Atlas da vulnerabilidade social nos municípios brasileiros: Índice de Vulnerabilidade Social – IVS. Instituto de Pesquisa Econômica Aplicada (Ipea).
Cunha, J. M. P. da. (2006). Segregação socioespacial e contextos de vulnerabilidade. Núcleo de Estudos de População, Universidade Estadual de Campinas.
Gil, A. C. (2019). Métodos e técnicas de pesquisa social (7ª ed.). Atlas.
Hair, J. F.; Black, W. C.; Babin, B. J.; Anderson, R. E. (2014). Multivariate data analysis (7th ed.). Pearson.
Halkidi, M.; Batistakis, Y.; Vazirgiannis, M. (2001). On clustering validation techniques. Journal of Intelligent Information Systems, 17(2-3), 107-145. https://doi.org/10.1023/A:1012801612483
Hastie, T.; Tibshirani, R.; Friedman, J. (2009). The elements of statistical learning: Data mining, inference, and prediction (2nd ed.). Springer.
Instituto Brasileiro de Geografia e Estatística. [IBGE]. (2022). Censo demográfico 2022: Agregados por setores censitários. https://www.ibge.gov.br
Instituto Brasileiro de Geografia e Estatística. [IBGE]. (2024). Agregados por setores censitários: resultados do universo: nota metodológica n. 06. https://biblioteca.ibge.gov.br/visualizacao/livros/liv102136.pdf
IPEA, 2008 [Referência completa não encontrada no documento original]
IPEA, 2015 [Referência completa não encontrada no documento original]
Jain, A. K.; Murty, M. N.; Flynn, P. J. (1999). Data clustering: A review. ACM Computing Surveys, 31(3), 264-323. https://doi.org/10.1145/331499.331504
James, G.; Witten, D.; Hastie, T.; Tibshirani, R. (2021). An introduction to statistical learning: With applications in R (2nd ed.). Springer.
Kaztman, R. (2000). Notas sobre la medición de la vulnerabilidade social. Comisión Económica para América Latina y el Caribe (CEPAL).
Marconi, M. A.; Lakatos, E. M. (2017). Fundamentos de metodologia científica (8ª ed.). Atlas.
Maricato, E. (2015). Para entender a crise urbana. Expressão Popular.
Organisation for Economic Co-operation and Development. (2020). Understanding the multidimensional nature of poverty. OECD Publishing. https://www.oecd.org
Taschner, S. P. (2004). Desenhando os espaços da pobreza. Cadernos de Pesquisa do LAP, 39, 1-26.
Torres, H. G. (2003). Pobreza e espaço: Padrões de segregação em São Paulo. Estudos Avançados, 17(47), 97-128. https://doi.org/10.1590/S0103-40142003000100006
Vergara, S. C. (2016). Projetos e relatórios de pesquisa em administração (16ª ed.). Atlas.
Yin, R. K. (2015). Estudo de caso: Planejamento e métodos (5ª ed.). Bookman.
Article originating from the Final Course Project of the Specialization in Data Science and Analytics of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform