This tutorial walks through the data preparation pipeline for running a space-time cluster analysis on publicly available 311 service request data from the City of San Diego. The data comes from the Homelessness Hub San Diego ArcGIS portal maintained by UC San Diego.
The goal is to take a raw CSV of encampment reports and produce the two input files that SaTScan requires: a case file (.cas) recording when and where reports occurred, and a geography file (.geo) mapping each location ID to its coordinates. Along the way, we will look at the data carefully enough to make defensible modeling decisions — and understand what we can and cannot conclude from the results.
Download the dataset from the 311 Encampment Reports page. Click Download and choose the CSV option. I use the 2024 calendar year — a full year matters for building a clean temporal baseline. If you pull a multi-year file, everything below still applies, but pay attention to the study period at the end.
Each row is one 311 report — not one encampment, and not one person. That distinction matters more than almost anything else here, and we will come back to it. For cluster detection, only three things matter from those 26 columns:
| What SaTScan needs | Column in this dataset |
|---|---|
| When it happened | date_requested |
| Where it happened | lat, lng |
| How many at that place and time | computed by counting |
The other columns — council_district, status, case_age_days
— are useful for exploration and for interpreting results afterward, but they are not model inputs.
Before discarding them, we will use them.
Before writing any modeling code, it's useful to get a feel for what's actually in the dataset — what the columns contain, when reports came in, and where they're concentrated. Catching data issues early tends to be much easier than tracing them back from unexpected results later.
Every row is an Encampment report, so this particular export doesn't need
any type-based filtering. We'll still write the filter explicitly below — if you re-download
this dataset later and the city has folded in additional service types, the code will catch
that rather than quietly including rows we didn't intend.
Now let's look at the temporal distribution.
Reports range from roughly 60 to 1,570 per week — a twenty-six-fold swing within a single year.
Does that mean the number of encampments swung twenty-six-fold? Almost certainly not. Report volume responds to enforcement pushes, media coverage, weather, and outreach campaigns. What we are measuring is reporting behavior, which is related to the underlying phenomenon but is not the same variable. SaTScan will find clusters in whatever you give it — if you feed it reports, it finds clusters of reporting.
Now let's look at the geographic distribution — where are reports coming from?
Downtown accounts for over 20,000 reports — roughly a third of the city's total. Uptown, Mid-City: City Heights, and North Park follow at a distance.
This is worth keeping in mind for when we get to the SaTScan results. Downtown will likely show up as a cluster, partly just because it has so many reports. What SaTScan is actually asking is a more specific question: given how many reports this area typically generates, was there a particular stretch of time where it produced more than expected? That's different from simply having the highest total count — and it's what makes the method useful beyond what a bar chart already tells us.
Subset to encampment reports only, keep the three columns we need, and parse the date.
A subtle point: San Diego is 7–8 hours behind UTC. A report filed at 5 pm local on January 1st
lands at 00:32 UTC on January 2nd, so a handful of reports get assigned to the next day. For
day-resolution analysis over a full year this is negligible — but if you ever move to hourly
analysis, convert to America/Los_Angeles first.
Only 17 records are missing coordinates, so dropping them leaves 59,042. The null-island
filter finds nothing here, but it's a useful habit. Some geocoders return (0, 0)
on failure instead of NaN, which means a broken coordinate can pass a range
check and show up as a point in the Gulf of Guinea. Checking for it explicitly costs nothing.
SaTScan doesn't take a list of raw GPS points. It needs a defined set of locations — each with a stable ID and a single coordinate pair — plus a separate table counting how many cases occurred at each location on each date. So before we can build those files, we need to decide when two reports should be treated as happening at "the same place."
The practical lever is coordinate precision. Decimal degrees of latitude translate to ground distance roughly like this:
| Decimal places | Approx. resolution |
|---|---|
| 6 | ~10 cm |
| 5 | ~1 m |
| 4 | ~11 m |
| 3 | ~110 m |
Let's see what each precision level does to the number of distinct locations.
At 6 decimal places, nearly every report becomes its own unique location. Two calls about the same spot, geocoded a few centimeters apart, get treated as separate places — which means we're throwing away the repeat signals that cluster detection is looking for.
At 3 decimal places, 110 meters covers more than a city block in a dense area like Downtown, so we end up merging distinct locations and inflating counts in ways that aren't really there.
Four decimal places (~11 m, roughly one address width) sits in a reasonable middle: 31,095 locations averaging 1.9 reports each. I'll use 4 here, though it's worth noting this is a modeling choice that affects results, not a fixed rule.
One way to check this: run the full analysis at COORD_PRECISION = 4 and then
again at 3. Clusters that appear at both precisions are more likely to reflect
something real. Clusters that show up at one but not the other are worth flagging as
potentially sensitive to this choice.
Even without a basemap, the shape of San Diego comes through in the point density. The concentrated cluster in the southwest is Downtown; you can also see corridors running east along the I-8 and El Cajon Blvd. The single busiest location had 211 reports over the year — roughly one every 1.7 days, all year, from the same ~11 m patch. That could be a persistently occupied site, or it could be a single frequent caller. It's useful to know which before reading too much into any cluster centered there.
The case file records counts by (location, date). We aggregate all individual reports down to that grain.
55,784 rows covering 59,042 cases. Only 2,636 rows have a count above 1, so same-day repeat reports at the same spot are relatively uncommon.
It's worth pausing on what those multi-case rows represent. If three people call about the same tent on the same afternoon, this aggregation records 3 cases at that location that day, not 1. Whether that's the right framing depends on the research question: three calls could be three independent signals of community concern, or they could be one tent counted three times. There's no universal right answer — just make the choice deliberately and note it.
The geography file is the lookup table: one row per location ID with its coordinates.
Every location referenced in the .cas file must appear here, or SaTScan
will refuse to run.
SaTScan's error messages can be sparse, and some failures are silent — the run completes but the results are wrong. Running a few assertions here is much easier than trying to trace a problem back from a suspicious cluster. Four things should hold: coordinates map one-to-one with location IDs, no ID is duplicated, every location in the case file exists in the geography file, and the total case count survived aggregation without any rows being added or dropped.
366 days — 2024 was a leap year. Note these dates down; you'll enter them manually in SaTScan and it won't warn you if they're wrong.
Download SaTScan free from satscan.org. Create a new session and point it at the two files we produced.
satscan_usable/2024_camps.cassatscan_usable/2024_camps.geoThe Space-Time Permutation model is the right choice here because we have no denominator — no population-at-risk data to convert raw counts into rates. Most SaTScan models require one. Space-Time Permutation sidesteps the issue by using the data as its own control: given how many reports this location produced all year, and given how many reports the whole city produced during this time window, is the count in this place during this window surprising? No external denominator required.
Under Output, enable the Google Earth / KML export to see clusters on a map. The default maximum spatial cluster size (50% of the population) is usually too permissive — try 10% under the Spatial Window tab. Under Temporal Window, 30 days is a reasonable starting point if you're hunting for acute flare-ups rather than season-long shifts.
SaTScan returns a ranked list of clusters — each with a center, radius, date range, observed-to-expected ratio, and p-value. A few things are worth understanding before drawing conclusions from those results.
The p-values come from Monte Carlo simulation. SaTScan repeatedly shuffles the data and measures how often a cluster as extreme as the one found would appear by chance. That's a well-founded approach, but what it's testing is narrow: no space-time interaction, given the observed margins. A low p-value doesn't mean the cluster represents an encampment hotspot — it means the pattern is unlikely under a specific null model applied to whatever data you fed in.
Clusters of reports are not necessarily clusters of encampments. Reporting behavior is shaped by many things beyond encampment presence — outreach campaigns, media coverage, neighborhood organization, and whether residents feel that calling 311 leads to any response. Areas with lower reporting rates may have just as many encampments but less trust in the system, or fewer people who know the service exists.
Some clusters reflect city activity, not underlying conditions. An enforcement sweep in a particular district in March will likely produce a cluster there in March. That's a real pattern in the data — but it's a cluster of city operations. Cross-referencing results with the city's outreach calendar and local news for that period can help distinguish those cases from others.
Space-time cluster analysis is exploratory. It's useful for generating hypotheses and flagging areas that warrant closer attention — not for confirming that something definitively happened. Treating the top-ranked cluster as a conclusion, rather than a starting point for further investigation, tends to overstate what the method can actually show.
It's also worth keeping in mind that this dataset is about unhoused people. The same map could inform services and outreach, or it could be used to direct enforcement. That's not a question the analysis answers — it's a decision about how the results get used.
Once you have baseline results, here are worthwhile directions to push on:
COORD_PRECISION = 3 and 5. Clusters that survive all three are worth reporting; those that don't are worth flagging.status field separates Closed from Referred. Do clusters of referred cases differ geographically from clusters of all cases?