Thanks for the suggestion, although I'm not sure I get how that'd work for this -- jittering is just for separating points with overlapping locations, right?
1 of 1 people found this helpful
In Tableau proper I don't know of a way to do this - you said you have the US Census Zip file - do you know if you have the spatial shapes file or do you have a point file - There may be something in Qgis that can help you here - not certain - on the other hand - could you consider zip codes within a radius of a give zip code centroid to cnetroid - that is doable and is similar to identify all the long/lat within a radius to a start point -
Are you going to TC19 next week?
4 of 4 people found this helpful
A few options that come to mind:
- The pre-processing solution - calculate out a table that documents contiguity of polygons so that every polygon knows what it touches. Join that in to your workbook and use it for the analytics. Granted - with a lot of polygons it's going to end up being a huge table. But...you can probably make this in QGIS or with a good Python spatial library like PySAL, or you could run off the table with PostgreSQL / PostGIS.
- The live and fun SQL solution - throw your data into a PostgreSQL database and do the spatial queries live. I'm just writing up some details on doing this and will have them on my Tableau Community blog some time next week (and will be talking about this type of analysis in my TC19 talk on spatial SQL). Here's an image of the type of analysis that I am thinking about... select a county, highlight the counties that touch (using ST_Touches in PostgreSQL / PostGIS), see the results comparing the selected county to the neighbors. This particular example also includes options to change to buffer-based analyses (e.g., all counties within 100 miles, etc.)
QGIS might be it, this looks promising: https://www.qgistutorials.com/en/docs/find_neighbor_polygons.html Thanks for the suggestion!
I'm not sure the centroids would work because the zip codes' sizes and shapes vary so much. And unfortunately I won't make it to TC19.
Appreciate the help!
It may be - I looked out there and could not find something about common boarders BUT - Sarah is the best at this -
I will be reading here blog next week to see how she would do it - (and sit in on her presentation next week)
hope to learn something
have a good weekend
Looks like the QGIS tutorial is just running a Python script via QGIS. If you're going to write some Python anyway, I'd recommend just using PySAL and calculating the contiguity there. It should be pretty easy if the QGIS tutorial doesn't make it clear enough.
PySAL docs: PySAL — Python Spatial Analysis Library
Here is one tutorial on spatial contiguity with PySAL: Spatial weights in PySAL · Geographic Data Science with PySAL and the pydata stack
Thanks Sarah! I'm pretty new to both QGIS and SQL so it might take me a while but I'll give it a try. I appreciate the help!
Holler if you need some help. I can probably scrape up some time once TC wraps up. Most likely I could run off an adjacency matrix pretty quickly if I have your spatial data to start with. It’ll give me an excuse to write the Python for it and tuck it away on my Github repo for others to enjoy.