Reputation: 133
I'm facing the following task in ArcGIS - I'm using ArcMap 10.2 I have a polygon shapefile with counties of (say) a state in US. From this shapefile, I create a layer which marks all counties in which there is at least 1 city of more than 50000 inhabitants (I think of this as the treatment condition). Then I'm creating buffers around the polygons in my layer of counties with those large cities, i.e. I'm drawing a buffer of say 100km around every county that has at least one city with more than 50000 inhabitants. So far so good!
The final step of this exercise should be to create a count for every polygon with the number of buffers that are touching this polygon. For instance, the buffers around counties B, C and D all touch county A. However county A doesn't have a city of more than 50000 inhabitants. Hence, I want the count for city A to be 3 (it's touched by B, C and D). I created the union of all my buffers but I simply can't find the right way to create this count for every polygon. I've done an extensive Google search and I'm apologize if I overlooked the obvious solution.
Any help is appreciated!
Michael Kaiser [Staff Research Assistant UCSD]
Upvotes: 0
Views: 330
Reputation: 3373
If I understand what you want correctly, then creating the union of buffers won't help you - as it leaves you with a single object and you need the count of all buffered objects intersecting against every object in the original table.
In SQL I would join the original (all counties) layer to your new (filtered, buffered) layer using the STIntersects()
method. Something like the following:
DECLARE @original TABLE
(
[Original_Id] INT NOT NULL,
[Original_Geom] GEOGRAPHY NOT NULL
);
DECLARE @filtered TABLE
(
[Buffered_Id] INT NOT NULL,
[Buffered_Geom] GEOGRAPHY NOT NULL
);
-- We'll pretend the above tables are filled with data
SELECT
ORIGINAL.[Original_Id],
COUNT(FILTERED.[Filtered_Id]) AS [NumberOfIntersections]
FROM
@original AS ORIGINAL
JOIN
@filtered AS FILTERED ON (ORIGINAL.[Original_Geom].STIntersects(FILTERED.[Filtered_Geom] = 1)
GROUP BY
ORIGINAL.[Original_Id]
Explanation:
In this example, the @original table would contain all of your counties in your given state - as they were before you buffered them. [Original_Id] would contain something that you can relate to or use to relate back to your data and [Original_Geometry] would contain the county's boundary.
The @filtered table would contain a subset of @original - in your case only those with at least 1 city of 50,000 inhabitants. The [Buffered_Id] would match records in [Original_Id] (as an example Orange County may have Id 32) and [Buffered_Geometry] would contain the county's boundary, buffered by (as in your example) 100km.
Using my example exactly, you need to get the required data out of your tables and in to mine, but you should be able to use your tables and adjust as necessary to reference them.
NOTE: If you do not wish "Orange County" to count "Orange County (Buffered)" in the above query, you will need to add a WHERE clause to filter them out.
I haven't the data to hand to test this, but it should be mostly there. Hope it helps.
Upvotes: 0