I'm using GQIS 2.2 and PostGIS on Postgresql 9.3.
I have 5 regions in the contiguous United States. Each region has states, and each state has counties. I would like to think that the data I'm given has each region, state, and county line up cleanly, but one can never be sure.
Here is an example:
I'm at the point in the project where I need to select all counties within a region. Success is getting all the counties within a given region (say, the Upper Midwest). None of my attempts at QGIS or PostGIS give me the results I want. It may either be because my queries are poor (I'm a beginner), or because my data is dirty, or both.
Here's what I've done so far:I've created PostGIS queries and also tried using QGIS's interface.
ST_Within:
Using QGIS's interface, we can see that ST_Within misses the border counties.
ST_Touches:
Touches seems to fail pretty badly - none of the counties are actually the counties that I want. They seem to be outside the selection! This is what leads me to think that I may have to clean my data somehow.
ST_Intersects:
Intersects is another step in the right direction, but it overselects.
I also tried to get fancy using centroids, but I hit a few interesting edge cases involving centroids falling outside of county polygons and islands.
I'm open to any advice. Of course, I could always, you know, just use manual selection, but I've had far too much coffee today to just walk away from an interesting problem. If the problem is just of selection, then fine. But I think the real problem is that my data is off. I'm open to any data cleaning techniques you have. I assume that I'm missing a general technique. I've read How to select by polygon in PostGIS with misaligned layers, and while the solution was indeed very cunning, it doesn't strike me as solving the underlying problem
However, I am open to any suggestions. Thank you for reading.
أكثر...
I have 5 regions in the contiguous United States. Each region has states, and each state has counties. I would like to think that the data I'm given has each region, state, and county line up cleanly, but one can never be sure.
Here is an example:

I'm at the point in the project where I need to select all counties within a region. Success is getting all the counties within a given region (say, the Upper Midwest). None of my attempts at QGIS or PostGIS give me the results I want. It may either be because my queries are poor (I'm a beginner), or because my data is dirty, or both.

Here's what I've done so far:I've created PostGIS queries and also tried using QGIS's interface.
ST_Within:

ST_Touches:

ST_Intersects:

I also tried to get fancy using centroids, but I hit a few interesting edge cases involving centroids falling outside of county polygons and islands.

I'm open to any advice. Of course, I could always, you know, just use manual selection, but I've had far too much coffee today to just walk away from an interesting problem. If the problem is just of selection, then fine. But I think the real problem is that my data is off. I'm open to any data cleaning techniques you have. I assume that I'm missing a general technique. I've read How to select by polygon in PostGIS with misaligned layers, and while the solution was indeed very cunning, it doesn't strike me as solving the underlying problem
أكثر...