A hot spot dashboard
Hot spots are the small places where crime gathers. Here the assistant finds them with crimepy's weighted DBSCAN: a hot spot is a place where at least a set number of crimes lie within a set distance of each other, measured on the ground. It draws them over crimes counted in grid cells of about 500 feet, and lists them. The data is a library of crimes reported in Durham, NC, from the city's open data; a data connection's lakehouse works the same way.
Follow along: download dashboards.zip (4.7 MB) and unzip it. Add the files in its data folder to a library, then include the library in a project.
1. Put the data in a library
Add the data files to a library: each becomes a table in the library's DuckDB file, with a profile the assistant reads. Here, Durham crime: the city's crimes, calls for service, and outline. A data connection's lakehouse works the same way. Then include it in a project with the Explorer's + Library.
Expand2. Let the assistant work
Open the project and press Sandbox locked. Turn on Accept assistant edits automatically, so it can write the dashboard's files, and Assistant-run Python, so it can look at the data first.
Expand3. Ask for the dashboard
Say what to show and from which data. Here: "Make a dashboard of property crime hot spots in Durham from the Durham crime library: find the hot spots with DBSCAN, places where many crimes lie within 1,000 feet of each other, and draw them over grid cells of about 500 feet colored by their counts. Let me choose the kinds of crime and the year, and change the hot spot settings. List the hot spots in a table I can click to zoom the map to one." The dashboards skill gives the assistant the method and a whole example to work from.
Expand4. Read what it made
It writes the page (an HTML file with its styles and its JavaScript) in a folder under dashboards. After each write the app opens the page in its tab and sends the assistant what failed and a picture of how it looks, so it fixes what it sees before it finishes. Then it says what each part shows.
Expand5. Open the dashboard
The page is index.html in the Explorer. It opens as a live dashboard: the page runs its SQL on the DuckDB file in the app, so the data never leaves this computer.
Expand6. Undock it
Press the arrow on the file's tab to move the dashboard into a window of its own, then maximize it or drag it to another screen.
Expand7. Choose the crimes
Tick or untick kinds of crime: the cells, the table, and the hot spots, found again, show only those ticked.
Expand8. Zoom to a hot spot
Click a row of the table to zoom the map to that hot spot.
ExpandGood to know
- The hot spots are the ones crimepy's geo.db_hotspots finds: the dashboard's DBSCAN (vv.hotspots in the app) is tested against it. Each is its core crimes buffered by the distance, and hot spots whose buffers touch are merged.
- A weight can stand for harm: ask for robberies to count 2 and assaults 1, or for each place to count its crimes.
- Each run is a little different: the assistant writes its own page each time, so yours will not look exactly like this one.
- The dashboard is drawn on this computer, in a sandboxed page that reads only the project's files, the app's own copies of D3, Leaflet, and DuckDB, and Esri's map tiles. It cannot send anything anywhere.
- With a data connection, the page opens the connection's lakehouse by its name, and the connection's scheduled update keeps it fresh: Reload shows the new data.
- After the assistant writes the page, the app opens it in its tab, tells the assistant what failed or drew nothing, and, for a model that reads images, sends it a picture of the tab. The picture is the app's own screenshot of its window, cut to the dashboard: nothing else on the screen is in it.
- The crimes come from the City of Durham's open data portal.