Urban Analysis & Spatial Science

Theory, Methods, & Code for Studying Neighborhoods, Cities, & Regions


San Diego State University

Center for Open Geographical Science


May 13, 2023


This text is a work in progress. It covers intermediate quantitative methods in urban and regional research using a series of Python-based computational notebooks. A printed version of the book is under contract with CRC Press and will be published in 2025


This text provides an introduction to the foundations of modern urban analysis with PySAL, geosnap, and the pydata stack. This collection is suitable for applied researchers or graduate students in the urban social sciences looking to increase their technical capacity in urban data science, as well as students from engineering, computer science, and statistics looking for an introduction to the theoretical foundations of urban analytics. The book’s intellectual tradition extends from the classic Readings in Urban Analysis (Lake, 1983), with extensions to current and emerging theories and methods from across the disciplines of urban social science.

In particular, we emphasize the use of formal, spatially-explicit methods and computational statistics for solving classic problems in the urban domain. What distinguishes this volume from similar alternatives like Geographic Data Science with Python (Rey et al., 2023) and Automating GIS Processes with Python is its focus on the application of advanced spatial analysis techniques to a wide variety of urban research questions. Whereas those texts focus on the integration of geospatial thinking into data science, we focus on the application of spatial data science to conduct social scientific research. This approach focuses less on data structures an algorithms and more on the theoretical nexus between research design and spatially-explicit urban scholarship.

By taking readers through the classic theories of urban analysis before presenting applied examples, this volume provides a pathway for constructing thoughtful models using either structural or experimentalist frameworks that are often required for rigorous policy analysis (Gelman et al., 2020; Heckman, 2005, 2008; Heckman & Vytlacil, 2007; Holmes & Sieg, 2015). These formal models help analysts think through causal relationships in complex systems, and they contrast from the prediction-centric modeling frameworks that are the focus of most data science tutorials (although the approaches are not mutually exclusive). Note, this is not a book focused on causal inference or structural estimation1, but rather on the technical skills in spatial analysis and theoretical foundations in urban topics necessary for analysts to build their own models.

As Alves (2022) describes, machine learning models have been both widely adopted and widely abused in recent years, and academia is no exception. As a result, a great deal of research–especially that using georeferenced data–tends to provide dubious evidence for policy recommendations, relying on support from models which were not designed to answer policy questions. Our goal in this volume is not to critique this work; indeed ML and data science have critical roles in spatial analysis and discovery, and we will discuss important frameworks in later chapters. But our central focus on the nexus between urban theory and spatial methods is designed to foster a tighter integration between rigorous methods for policy analysis, and the special considerations necessary to understand spatial data (Anselin, 1989). As such, the content of this volume is, by design, highly interdisciplinary. Although the book is not explicitly billed as a regional science text, our approach extends from the view that urban and regional analysis should be multidisciplinary, applied to contemporary issues in the social sciences, with a critical nexus to policy and practice.

Applied regional science should be problem-driven, not method-driven or theory-driven. It must be more than the storehouse of analytical methods that have been regional science’s main contribution to date… A modest, but very important, initial step is research that gets beyond the formal aspects of the analytical methods to gain a better understanding of their power and limitations within the contexts, purposes, and processes in which they are used (Isserman 1984). Such research should focus “not just on the models and methods per se, but also on their interpretation, use, and abuse in practice” (Anselin 1991a).

Isserman (1995)

To that end, we aim to match the “intellectual core” of urban and spatial science as an interdiscipline, following Isserman’s tenets:

  • Theory dealing with industrial location, migration, spatial competition, regional growth and development, regional differentiation and hierarchies, and spatial interaction,
  • Methods for regional analysis, including economic and demographic models, spatial statistics, and optimization methods
  • Policy areas with a spatial dimension, including economic development, environment, housing, labor markets, social service location, and transportation.

These principles that guide our research bear a strong resemblance to the characterization of analytical sociology advanced by Sampson (2002), who describes “Chicago School” inquiry as

  1. a relentless focus on context (especially place)
  2. a focus on properties of communities and cities as social systems
  3. a relational concern with variability in forms of social organization as opposed to population attributes (or composition)
  4. continual attention to neighborhood change and spatial dynamics (time and space)
  5. an eclectic style of data collection that relies on multiple methods but that always connects to some form of observation
  6. a concern for public affairs and the improvement of community life
  7. an integrating theme of theoretically interpretive empirical research

Although these perspectives focus on different systems (i.e. spatial markets versus social relationships) and different notions of scale (places versus individuals), both perspectives maintain an emphasis on formal structural analysis of hierarchically-networked systems embedded in space (Sampson, 2011). This is an important parallel because analytical urban sociology and regional science very obviously share common DNA. Indeed, the intellectual tradition and analysis of spatial structure articulated famously by Alonso, Muth, and Mills borrows as much from Park and Burgess as it does from Christaller and Von Thunen (Alonso, 1964b). Despite this similarity, overlap between sociology and regional science has waned over time rather than waxed, and it’s rare for Sampson or Park citations to appear in the Annals of Regional Science, just as it is quite rare to find an Isserman or Tiebout citation in the Annual Review of Sociology.

These links are not unknown, but have been celebrated by regional scientists for decades (Quigley, 2001; Schaefer et al., 2011). Indeed, Sampson won the Alonso Memorial Prize in 2013, and Alonso himself credits Burgess as offering the “clearest statement” of the historical theory of spatial structure (Alonso, 1964b). Although Isard (2001) observed that “the three largest subgroups of regional scientists come from geography, planning, and economics,” he also worked hard to place sociology professors on the Regional Science faculty at Penn, and to organize sessions “on regional analysis at conferences of the American Economic Association, Association of American Geographers, American Sociological Association, American Political Science Association, and others.”. The intentional reach into sociology and political science also helps ratify the call by Bailly & Coffey (2005) to better incorporate the human dimension into urban and spatial science.

Under this rubric, doing sound urban analysis requires a strong foundation not only in the technical methods and different modeling strategies, but also a deep understanding of the ways that markets, social groups, public policies, and political economies intersect and interact with space in complex ways 2. Sometimes we forget that economic geography is rooted in behavioral science… Economic geography grows from human ecology, which grows from psychology (Zipf, 1949).

Since the classic Readings in Urban Analysis, few volumes have attempted to provide such a broad coverage of theoretical perspectives in urban analysis. None have provided both theory and code. Here we emphasize that urban analysis sits at the intersection of spatial analysis and social science (Rey & Franklin, 2022). While regional science has historically been criticized for its obsession with methods and its tenuous relationship with practical utility (as described by Isserman above), analytical sociology has also been criticized for treating research methods in policy analysis without appropriate econometric rigor (Harding et al., 2021; Ludwig et al., 2008; Sampson, 2008). Clearly, then, the synergy of these perspectives has much to offer toward a more holistic analysis of urban systems. Quigley (2001) reiterated the linkages across disciplines and the centrality of regional science more than two decades ago

“During the past decade several of the most exciting intellectual challenges in social science have emerged and been framed in exactly the terms familiar to students of regional science. These specific scientific problems have important policy implications, and they are also central to theoretical inquiry in several core disciplines of economics, political science, sociology, and statistics, for example. It is my contention that, at no time since Von Thunen, have spatial relationships been so important in the social sciences and in the policy implications of social scientific inquiry.”

Despite the centrality of this work in modern social science and policy analysis, developing this interdisciplinary perspective on urban spaces requires traversal of many distinct literatures to acquire the breadth of theoretical and methodological tools. This can lead to an inadequate use of “Big Theory” in the age of Big Data (Franklin, 2023a). The goal of this volume is to help consolidate some of this diverse knowledge into a practical text that offers “a rigorous but nontechnical treatment” of major topics in urban analysis and spatial science (Brueckner, 2011) with examples in Python.

Finally, even when some of the best research weds concepts from across the urban disciplines, the work often happens using point-and-click software creating research pipelines that are more prone to human error and cannot be reproduced. It also tends to make strong assumptions about the form and nature of spatial interaction (i.e. how spatial relationships are included in the model) which are important to scrutinize, test, and extend (Aaronson et al., 2021; Ellen et al., 2013; Harding et al., 2009; Hartley, 2014; Schwartz et al., 2021). We prefer to stand on the shoulders of these giants and build upon their work, rather than reimplement and start from scratch. Toward those goals, this book provides background theory on urban systems, drawn from regional science, urban economics, geography, urban planning, and sociology, and demonstrates how to carry out common research tasks in urban social science using free and open source tooling.

By making these tools and their historical development more accessible, we hope to provide some scaffolding toward bridging the gap between theory and practice, with the goal of making cities better for everyone. In our view, this should be the goal of the discipline, as Batty (2019) describes

…There is a bigger role in thinking about a theory of the urban – we have called it city science – that embraces the new data and provides a clear testbed for applications to problems relating to the big questions of our time, inequality, aging, the future of work and so on, all of which have enormous spatial as well as temporal variations that need to be understood and explained. And last but not least, urban analytics should deal with Environment and Planning, the main title of this journal still, for therein lies the motivations for developing these ideas in the first place, so we can provide more sustainable and liveable cities than anything we have achieved or even attempted so far.

Space for Urban Analysis

There are lots of good, open courses, syllabi, and books related to urban data science (or similar nomenclature) today, and many of them are written by my close colleagues. All of those materials are good. Still, I think this book fills a particular void that reflects my own view on urban social science. Having trained with sociologists, economists, geographers, and planners, I think there is a clear need for a book that weds today’s computational analytical toolkit with an interdisciplinary perspective on urban studies. In its best form, that’s what regional science is supposed to be (Alonso, 1971; Isard, 1975) :

  • more theory than geography
  • more space than economics or sociology
  • more computation than urban planning or policy

Maybe that categorization will raise eyebrows from my colleagues in each of those respective disciplines, but I’m more than prepared to defend this hill. Perhaps it’s a contrarian position, but there is an important lesson from the long arc of history in quantitative spatial analysis that is underappreciated today 3. Thirty years ago, Berry (1995) in (direct response to (Isserman, 1993, 1995), but indirect) response to widespread hand wringing about the future of the discipline, wrote about his dissatisfaction with regional science, and the way it had drifted from a group of highly motivated scholars breaking new ground in spatial analysis to a “a hardcore group of technocrats who subscribed to Lord Kelvin’s dictum that if it could not be done mathematically it was not worth doing.” By that time, regional science had developed an external stigma that most of its practitioners were doing little more than playing with numbers and mapping the results, without producing any value for understanding how cities work. That perception had merit.

Fifteen years ago, however4, Berry et al. (2008) wrote about the endless promise of the newly emerging “Geospatial Science… a spatially integrated social–environmental science that is transcending older disciplinary attachments, boundaries, and constraints”. In their view, the combination of GIS and more powerful spatial statistical modeling techniques amounted to a fundamentally new science–“geospatial” this time, not “regional”. But they questioned “whether the result [would] be a new discipline or an integrative interdisciplinary pursuit that fosters the broader development of spatially integrated human-environmental inquiry.” The answer was neither.

While GIS has made simple mapping and geo-data processing more accessible in a wider variety of fields, the tighter integration between geography and computer science has weakened tethers to the social sciences, and pushed spatial analysis further into the technocratic bubble Berry so loathed. Lots of ‘urban computing’ labs, are packed with computer scientists clamoring to offer opinions about urban analytics; none of them are trained to understand cities5. Thus we end up with fancy hexagonal gridding systems, like Uber’s H3, without even a nod to Christaller (1937), Lösch (1940), Central Places, or Market Areas.

Uber’s H3 Globe

Losch’s Economic Globe

Global Grids, Now and Then

Uber H3 System

Christaller-ian System

Hexagonal Systems, Now and Then

Today, many scholars of my era are making bold claims about the fundamentally transformative power of spatial data science (another new “science”) and “GeoAI” that will revolutionize the planet–despite clear calls from leaders in the discipline to please incorporate some social theory (Franklin, 2023a). And while we do have some nice new methods to use, not many seem to realize that we’ve been here (a few times) before. Whither regional science indeed (Berry, 1995). That history (and a longer one I could eat much more space with) leads me to an admittedly very opinionated take on spatial analysis in the social sciences.

Demarcating Urban Analysis and Spatial Science

The field continues to re-brand and segment itself, and while there is strength in numbers, there is weakness in diffusion (Franklin, 2023b). With few exceptions, RSUE is the domain of economists, EPB is the domain of geographers, and Urban Studies is the domain of sociologists. We don’t even engage with Urban Affairs. What maintains through the division is the strength of spatial analytical approaches, and the scholars who know their topical domains well enough to extract meaning from the application of these methods. Toward that end, spatial analysis and urban analysis are not synonymous. Spatial analysis is a tool in the urban analytical toolkit. Urban analysis (and regional/spatial science), in my view, is the application of quantitative methods to the study of neighborhoods, cities, and regions; the goal of urban analysis is to understand (at least a piece of) how these places are shaped by histories, markets, social processes, and political economies that operate within and around them.

“Older regional scientists may recall that in 1953-1954, the designation spatial science (Alonso’s Raumforschung) was considered the most appropriate.”

Isard (2001)

That has always been the goal of regional science (Isard, 1956, 1960), though, I prefer Alonso’s original term “spatial science,” first because I do not have a preferred scale (region vs neighborhood), and second because spatial econometrics provide the discipline’s most foundational tool. ‘Urban analytics’, then (the plural noun), is akin to Raudenbush & Sampson (1999)’s “ecometrics”, or the broader field of psychometrics from which it’s inspired: a measurement science devoted to developing theoretically-informed, policy relevant scales, indicators, or variables that can be used to understand cities and formally evaluate policy measures (Irwing, 2018; Larimian & Sadeghi, 2021). Although articulated differently, Wolf (2023) makes a similar case for city science.

Together then, urban analytics provide a set of metrics for interpreting places, and spatial science provides a formal theoretical and modeling framework for studying their effects. This is a social science view of the world, not a data science one. Data science is deeply useful for our goal of understanding cities, but its role is instrumental. I think that is a clear distinction between the material in this book and the way other similar volumes are presented. Few students learning spatial data science today have been introduced to location theory, which dramatically limits their ability to apply and interpret spatial analyses (Alonso, 1964a; Isard, 1949).

We know why retail establishments outbid residential dwellings for land near employment centers (Alonso, 1964a), why most transportation trips are a short distance (Hansen, 1959; Zipf, 1949), why race matters for understanding the spatial economy (Glaeser et al., 2004; Kain, 1968; Schelling, 1971) and why some people can opt into quality school systems supported by a strong municipal tax base (Tiebout, 1956), while others remain stuck in place (Sharkey, 2013). Further, we know that people, firms, and places interact with one another in space (Anselin, 1988; Cliff & Ord, 1969) rendering many traditional quantitative methods unusable for statistical inference. Those lasting insights should be the foundation that urban analysis builds upon.6 With due respect to Batty (2022) (another hero of mine), this is a different endeavor from the architect’s quest to define ‘the city’. In architecture and urban design it may be true that

“Throughout history, cities had been considered first and foremost as physical forms whose functioning might be improved by physical planning. It took the rest of the last century to transform this notion of planning into the social rather than the physical organisation and even now, there is much left to do to enable this transformation and to integrate both perspectives.”

But in urban social science, that notion is absurd. By the time city planning was devised in the early 20th century, the theoretical foundations of regional science were already 100 years old (von Thünen, 1826). Thus in urban economics, ‘the city’ has a clear, if imperfect definition based on the demand for land: ‘the city’ is any place that the residential rent gradient exceeds the agricultural rent gradient (because that demand is what leads to development and density). And while that definition is simplistic and sometimes contested (even egregious on occasion), it provides a formal, quantifiable definition rooted in behavioral theory. In this sense, cities have been viewed by regional scientists first as social constructs since at least Von Thunen’s time–more than a century prior to Mumford’s–where the physical layout of urban form follows as a consequence of social interaction (e.g., transporting goods to the marketplace). Further, by the time Mumford penned The City in History, The Chicago School sociologists were also decades into their research program and their own (social) definition of The City, with Park et al. (1925) already more than 40 years old.

Following, there is a distinct difference in the study of ‘spatial bundles’ (Arribas-Bel & Fleischmann, 2023) versus the study of processes that give rise to them, and interrogating why particular kinds of spatial bundles occur. The proverbial Geographer to which Arribas-Bel & Fleischmann (2023) appeal sounds identical to the Little Prince’s Geographer from which Berry (1995) desperately wanted to differentiate; it is for the Geographers, in their view, to define ‘bundles’ using their computers and algorithms, while the Explorers are left to interrogate what the bundles mean, and why they are there. While Dani and Martin are two of my closest colleagues and collaborators, I would argue city science requires a perspective different from bundles7 and a coalition far broader than Geography (and if you can’t argue with your friends, who can you argue with?). We can’t understand cities without the tradition of Zorbaugh & Chudacoff (1983), McFadden (1978), or Ellen (2023).

In a similar vein, urban science is not environmental science (Haining, 2003). A common difficulty in teaching spatial analysis is attempting to cater to too many audiences . But while I have taken an ambitious swing with this book, the goal is to speak to a unified set of social scientists who share common theories and models of human behavior. This distinction is important because the kinds of data we use (i.e. vector vs raster) and the kinds of models we build (i.e. discrete choice vs kriging) are designed for fundamentally different systems. Hurricanes, icebergs, and mineral deposits are all strongly influenced by space, but do not make utility-maximizing decisions, mimic each other, or develop rational expectations. I think this is a longstanding but ill-addressed distinction between geographers and economists in regional science, and is partly responsible for the factioning among “spatial data scientists;” while I think environmental science is a complementary discipline, I disagree with the idea of an integrated “social-environmental” science described by Berry et al. (2008)— and what’s more, that concept was already 30 years old (Isard, 1972)… As Isserman (1996) liked to say: “it’s obvious, it’s wrong, and anyway, they said it years ago.”

Now, having spent the last several paragraphs lauding the importance of economic formalization, I’d be remiss if I didn’t point out that everyone agrees economists are the worst8. If there is a discipline that believes the entire domain of urban studies is theirs by exclusive right, it’s economics. They believe that about every domain. And that same haughty, exclusionary attitude and religious adherence to formalization (at the cost of ridiculous abstraction) is why there are no more Regional Science departments. The world decided it was not useful to prove that demand curves are downward sloping and that land prices fall with distance to amenities.

So to be clear, urban science is not urban economics. Urban economists, including some of the best econometricians on the planet, are still publishing papers that don’t account for spatial dependence of any kind (no, clustering your standard error or including a unit fixed effect–or both–won’t save you.) (Aaronson et al., 2021; Quast et al., 2017; Voith et al., 2022). Elsewhere, they disagree with the notion of spatial spillovers specified by theory (Gibbons & Overman, 2012), but vehemently defend models built atop a house of cards… (Redding, 2023; Redding & Rossi-Hansberg, 2017)

We need a broader coalition than Econ as well. Again, part of the problem is nobody bothers to publish in the other fields’ journals. So while the economists will surely tell me how wrong I am about everything in this book, at least it will have baited them into the conversation. (If you can’t tell I’m joking, this is all intended as good fun. Cities are great, but this material can be dense, so lets enjoy a few laughs when we can. Although seriously, economists are the worst.)

The Cast of Urban Scholars

And now that everyone has been insulted, I can reiterate that my point is: we’re all studying cities together and each discipline brings a necessary but insufficient set of strengths to the table. Lets work together and do Urban Science again :). I will do my best to cover what each of these fields has taught me about the most important ways to conduct urban scholarship, but by definition that means I can’t do any single perspective justice.


It is worth pointing out that, like Isserman (1995), I have a distinctly American perspective on urban studies. While I am confident the methods and lessons in this book are transferrable anywhere on the globe, I am trained to understand cities through the specific history of institutionalized racism that has shaped housing, land-use, transportation, education, and other urban policy decisions both explicitly and implicitly since the country’s founding. In the U.S., neighborhood scholarship and the understanding of social inequality is inextricably linked to housing policy and racial segregation (Charles, 2003; Galster, 1988; Galster & Keeney, 1988). The sociospatial structure of American cities is not a random spatial process, but an expression of racialized public policy decisions that persist today (Kain, 1968; Kain, 1992; Sampson, 2013; Wilson, 1987, 1996). Galster & Killen (1995)‘s famous “geography of opportunity” is a reference to the American irony that the fabled and oft marketed ’land of opportunity’ is not, in fact, equally accessible, or distributed randomly in space. Instead, ‘opportunity’ seems to follow a remarkably stable spatial structure maintained by urban policy measures.

Here, space and land policy have been used by both private and public institutions as instruments for hoarding privilege, requiring decades of legal action to help ensure adequate protection under the law. The Fair Housing Act is an explicit recognition that housing is a major driver of social inequality (and that it requires legal protection to ensure equal access to opportunity), and there is an important legal tradition the U.S., (led by the NAACP and the ACLU) of challenging government policies under the equal protection clause. These court cases have resulted in some of the most important and well-known housing demonstration projects ever carried out, like the Gautreaux program in Chicago (Keels et al., 2005; Mendenhall et al., 2006; Rosenbaum & Deluca, 2008), and the five city Moving to Opportunity (MTO) project (Dawkins et al., 2015; Feins & Shroder, 2005; Leventhal & Brooks-Gunn, 2003; Ludwig et al., 2013), and made clear that policy decisions, like the siting of public housing were (and are) at least partly responsible for the demarcating the geography for opportunity and determining who has access to it.

I was lucky study the MTO microdata early in my graduate career (Pendall et al., 2015), and the methodological framework I developed (Knaap, 2017) and applied in my dissertation is the core of the federal evaluation of the Baltimore Housing Mobility Program that resulted from the Thompson v. HUD decision. Some of my favorite scholars like Stefanie DeLuca and Camille Zubrinsky Charles testified9 in the Thompson trial, subjecting analyses to a level of scientific rigor that must literally stand up to cross-examination in a federal courtroom. That strict scrutiny is partly why there has always been a careful emphasis on methods, causality, and interpretation in the MTO literature specifically, and the neighborhood effects literature more generally (Clampet-Lundquist & Massey, 2008; Harding et al., 2021; Ludwig et al., 2008; Manski, 1993). In these cases, “the algorithm fits the data” does not suffice.

“A true regional scientist is concerned with acquiring knowledge. First, he wants to satisfy his curiosity and eagerness to understand phenomena; second, he wants to attack social problems. Hence, although he may want to study the city and region abstractly and as an intellectual pursuit, he should also seek to attain knowledge that leads to wiser policies helping to mitigate urban and regional problems. It necessarily follows that before a scholar or practitioner can do anything about a pressing social problem, he should know at least something about his subject matter.”

Isard (1975)

My familiarity with this history and experience developing methods for evaluating Fair Housing programs gives me a particular view on the use and abuse of urban analytics, and the relationship between theory, methods, and policy. Toward that end, while there are good books on urban economics (Arnott & McMillen, 2006; Brueckner, 2011; Mills & Hamilton, 1994), housing policy (Clark, 2021; Green & Malpezzi, 2003; Myers, 1990), segregation (Musterd, 2020; Schelling, 1978), analytical sociology (Hedström, 2011) spatial analysis (Rey et al., 2023), spatial statistics (Rogerson, 2021) regional science (Henderson & Thisse, 2008) or Python programming (Downey, 2016) there are none that try to weave these themes together. I’m going to give that a shot here. The style I’m shooting for is Think Stats (Downey, 2014) meets Lectures in Urban Economics10 (Brueckner, 2011), which means technical but accessible, and expressed using more computation and demonstration than math (though equations are presented frequently to help formalize and define each model and its assumptions).

The goal of this volume is to promote open urban science, and the content is structured as a series of computational notebooks. The concept behind this style of presentation is that it exposes the full “life cycle” of a research project on each topic. You may disagree with my perspective, but in each chapter I lay out the logic and application of a particular method of urban analysis that is both canon, and has been applied in my own work. This situates the analysis in the context of a particular theory or policy domain, but exposes the entire computational pipeline, so that if you find my assumptions or my theoretical framing contentious, you can easily translate the method into your preferred application—as long as you show all the breadcrumbs, as I have :). If you think I got something fundamentally wrong, I also welcome discussion and Pull Requests. In both science and public policy, we often shoot for consensus through debate, and exposing all the ugly bits for scrutiny is the point of open science11 (Rey, 2009, 2017; Wolf, 2023).

Data, Measurements, and Models

Many constructs in urban social science are unobservable. The amount of ‘utility’ each family receives from the home it occupies, the extent of the ‘neighborhood’ each child traverses, the level of ‘accessibility’ each worker enjoys, the amount of ‘segregation’ experienced by each ethnic group, and the level of ‘spatial spillover’ attributable to some public policy are all unobservable quantities that are immeasurable directly. But all of them are critical to understand how cities, neighborhoods and regions affect the lives of their residents. Sometimes these concepts themselves stem from unobservable social processes like ‘gentrification’, ‘disorder’, ‘opportunity’, or ‘collective efficacy’, all of which require a set of assumptions and models to approximate.

In that sense, the notion of “the neighborhood” or “the city” is both very real and present, but also abstract and intangible. There is a strong parallel between notions of place in spatial science and the concept of self in social psychology (Goffman, 1959; Mead, 1934); both take on multiple meanings dependent on context, both can be “measured” in many ways, both are shaped and defined by external and internal perceptions, and the way one is defined at any given point has direct and indirect influences on the way it functions. “The self” is distinct from a person (with a passport) just as “the neighborhood/city” is distinct from administrative zone (with a taxation boundary). For that reason, urban analytics has much to gain from psychometrics because both fields depend on a critical feedback between theory and measurement (and psychometricians have been working on these problems for far longer).

Many measurable variables in urban spaces (neighborhood composition, access to the urban core, etc.) can be conceived as partial outcomes from an underlying (latent) social process, and the goal is often to understand the social processes rather than the measurable indicators (Knaap, 2017; Raudenbush & Sampson, 1999). This is a “model-based” view of the world, where we propose a conceptual model (of data or process) and test whether the empirical data fit that model (Anselin, 1988). This is distinct from a “data-based” view of the world prominent in data science where the model is based on pure fit; the difference is akin to the distinction between factor analysis and principal component analysis, in which the former is a model of a latent variable and the latter is a model of data. Revelle (n.d.) is a master of describing this style of quantitative research.

“Throughout the book we will propose models of the data and try to evaluate those models in terms of how well they fit. Conceptually, we use the equations

\[ Data = Model + Residual \] to represent the problem of inference. We evaluate how well our models fit by examining Residual as defined as

\[ Residual = Data − Model \]

and evaluate the magnitude of some function of the residual (Judd and McClelland, 1989). These equations would seem to imply a greater quantitative level of measurement precision than is generally the case, and should be treated as abstractions to remind us that we are evaluating models of data and need to continuously ask how appropriate is the model. The distinction between model and residual is not new, for it dates at least to Plato. As discussed by Stigler (1999) the whole of nineteenth century statistical theory was based upon this distinction between physical truth as modeled by Newton and actual observations taken to extend the theories. In statistical analysis, residual is typically treated as error, but by treating our data in terms of what we know (model) and what we don’t know (residual) we recognize that better models can explain some of the residual as well.”

Revelle (n.d.)

Some argue this is the difference between a social scientist’s view of the world and a statistician’s view of the world, but the methodological philosophy matters less. The important point is that we are often more interested in the data-generating process (DGP) than the actual data themselves, and the focus on process means we often make assumptions based on theory or assert testable hypotheses about how the process works. This is like when Stefan Wagner (p. 71) says

Note that, in the social sciences, it is quite common to write down linear relations of the form (9.2) that are intended to describe the structure of a system, but are not to be taken as a short-hand for linear regression. On the other hand, this is largely the opposite of standard practice in applied statistics where, when someone writes (9.2), they often don’t mean anything else than that they intend to run a linear regression of \(Y_i\) on \(W_i\).

When possible in this book, we take the “social sciences approach”, where we generally consider a process (and maybe write down an equation) that we believe governs the DGP, then ask either in combination or sequence

  • what is the best way to estimate the parameters of interest? (implicitly acknowledging that the conceptual/structural equation is not necessarily the estimating equation)
    • are there other DGPs that could generate similar patterns but where the parameters would be mistakenly identified using a particular estimating equation?
  • do the empirical data fit this model? (i.e. should our conceptual model should be rejected by the data?)


The collection of resources for Python-centric spatial analysis is growing rapidly. This book covers intermediate material and presumes basic knowledge of both Python and geoprocessing, ideally with some knowledge of spatial analysis. A natural sequence for students in urban social science or spatial data science might be something like

  1. Geocomputation in Python for an introduction to Python and geoprocessing
  2. Geographic Data Science with Python for an introduction to spatial analysis
  3. Urban Analysis and Spatial Science (this volume) for coverage of intermediate methods and modern applications in research and practice.

The book is structured as a series of computational notebooks and serves as both a topical and technical reference manual. In each chapter, we introduce the topic and its motivation in the social science literature. We then carry out an analysis using classic and emerging techinques (occasionally both), walking through the construction and analysis in depth. The goal is to provide a concise coding example demonstrating a real-world application, while contextualizing the analysis with citations and background literature that readers may explore for more depth. Each of the topics covered herein could be the focus of its own volume.

  1. Geoprocessing and Visualization: understanding data in space
    • points, lines polygons
    • urban data sets
      • administrative data (census)
      • sensors (EPA/Land Cover)
      • VGI (open street map)
  2. Interpolation and Change of Support: transferring data between spatial representations
    • areal & pycnophylactic interpolation
    • dasymetric interpolation
  3. ESDA and Spatial Weights: formalizing spatial relationships
    • spatial weights (graphs)
    • global and local spatial autocorrelation
      • Binary Association (join count)
      • Getis-Ord G & Moran’s I
      • Local Spatial Association
    • event clustering
      • global and Local Knox
  4. Accessibility and Exposure: measuring the interaction/consumption “potential” of each location
    • isochrones & “service areas”
    • distance decay &cumulative accessibility
    • “walkscore” & other access measures
  5. Spatial Structure & Agglomeration: spatial concentration & specialization of activities
    • urbanization and localization
    • herfindahl index
    • location quotient
    • shift-share
    • employment centers
  6. Segregation: the spatial separation of social groups
    • single & multigroup measures
    • space and scale
    • dimensionality
    • inference & decomposition
  7. Factor Analysis and Ecometrics: latent factors & social bases of urban differentiation
    • factorial ecology (unsupervised/EFA)
    • ecometrics (supervised/CFA)
  8. Geodemographics and Regionalization: neighborhood composition & spatial extent
    • social area analysis
    • market areas
    • neighborhood types
    • unique neighborhoods
  9. Spatial Dynamics: spatial relationships in models of change
    • spatial Markov models
      • neighborhood change
      • land-use change
    • cellular automata models
  10. Applied Spatial Econometrics: spatial dependence and heterogeneity
    • the hedonic housing price model
    • spatial econometrics (focus on application, not estimation methods per se)
      • cross-section: global and local spillover and diffusion
      • spatial regimes: accounting for heterogeneity (submarkets in this example)
      • spatial panels: adding the time dimension
  11. Location Models: the placement of homes, jobs, and resources
    • locational attainment
    • discrete choice
    • location-allocation


  1. For the former, see other excellent texts like Cunningham (2018), Huntington-Klein (2022), Angrist & Pischke (2008), Pearl (2000), or Pearl & Mackenzie (2018). For the latter, see Manski & McFadden (1981), Train (2001), Heckman & Urzúa (2010), or Holmes & Sieg (2015). Another great resource is Heckman’s slide deck on econometric policy evaluation↩︎

  2. In truth, this is closer to the urban “meta-discipline” approach of Alonso (1971)↩︎

  3. In particular, I can imagine a cadre of British geographers raising a quarrel over this proposition. In their classic text, Fotheringham et al. (2007) argue that “quantitative geography has recently reached a stage of maturation whereby it is no longer a net importer of ideas and techniques from other disciplines but, rather, it is a net exporter.” But their own evidence to support the notion of geographic theory is a small tweak to McFadden’s discrete choice model. While it is true the competing destinations model is an important contribution to urban studies, it is also true that the model is imported from economics.↩︎

  4. To clarify, I am not picking on Brian Berry. Quite the opposite. Berry’s scholarship is legendary, and his citations will appear dozens of times throughout this book. He was a founding member of the ‘quantitative revolution’ in geography that ultimately birthed regional science. He and his contemporaries at the University of Washington including Waldo Tobler, Richard Morrill and Art Getis who studied under faculty like William Garrison and Edward Ullman (to include only a small handful of the most famous names) are among the most prestigious group in spatial analysis (Morrill, 1983). For that reason, Berry’s opinion (including any cognitive dissonance therein) is a valuable indicator of the field’s status↩︎

  5. Seriously, do not trust a computer scientist’s take on cities. They are dying to opine for some reason, but while they are great at math, they aren’t trained in the structure, function, or politics of urban spaces, and they don’t have a clue what they are talking about.↩︎

  6. These are not ‘geographical laws’ like fractal scaling or the ubiquitous ‘near things are more alike than distant things’; they are empirically-robust behavioral theories that explain why humans and markets interact in predictable ways through spatial relationships.↩︎

  7. Indeed, the most intuitive and well-studied “bundle” in urban studies is the housing unit, and one of the discipline’s most important techniques is developing a structural model to decompose the bundle to better understand the influence of its constituent parts (Rosen, 1974).↩︎

  8. If you’re an economist, I apologize. You are the worst 😝.↩︎

  9. Not to mention my colleague and former committee member Rolf Pendall↩︎

  10. Ok, that’s a lofty target, to be conservative. Allen and Jan are both geniuses that have a brilliant ability to convey dense information in remarkably clear and concise ways. I doubt I’ll ever pull that off, it’s a good target to shoot for.↩︎

  11. As a grad student, I learned a lot of Python programming by watching the UDST team (Matt Davis and Fletcher Foti, in particular) build UrbanSim2 (Foti & Waddell, n.d.) in the open, and I was deeply influenced by Fletcher’s take on “exhibitionist source”, which is a philosophy I try to adopt in my own work (and I think we do pretty well over in PySAL also).↩︎