Good Afternoon:
I have spent a good part of today searching the discussion list and reading
"Applied Spatial Data Analysis with R" and can't seem to find how to do the
following:
One of my colleague's grad students has two shapefiles. The first shapefile
contains local polygons with associated local attribute data. The second
shapefile consists of US county polygons and attribute data for each county.
The first shapefile's polygon boundaries do not correspond to county boundaries
i.e. the local polygon be a subset of one county or may overlay more than one
county. The student's immediate needs are to be able to compute how many
square miles each local polygon has in each county. For example local polygon
1 might have 10, 5, and 2.5 square miles in counties 12,15, and 24
respectively.
This brings me to my larger question. Does anyone have R code or know of an R
package that would allow us to merge the polygons from the two shapefiles into
a new set of polygons (and eventually create a new shapefile) that preserves
all the polygon boundaries of both original shapefiles? We would also like to
have an associated attribute data file that preserves all the original
attribute data.
Suppose that attribute data for the first and second shapefiles looks like:
shapefile1 (plots of land):
polygon, name
1, A
2, B
3, C
....
shapefile2 (California counties):
polygon, sfips, cfips, name
1, 6, 06051, Mono
2, 6, 06019, Fresno
3, 6, 06107, Tulare
4, 6, 06027, Inyo
â¦.
I want to merge or overlay shapefile 1 onto shapefile2
Assume that plot A's land is a subset of Mono county, plot B has land in Mono,
Fresno, and Inyo counties in California as well as land in Nevada that does not
overlay any of my California shapes. Plot C has land in Inyo and Tulare
counties. I would like to have a new shapefile with merged polygons and with
merged attribute data like:
polygon, polygon.x, name.x, polygon.y, sfips.y, cfips.y, name.y
1, 1, A, 1, 6,
06051, Mono
2, 2, B, 1, 6,
06051, Mono
3, 2, B, 2, 6,
06019, Fresno
4, 2, B, 4, 6,
06027, Inyo
5, 2, B, NA, NA,
NA, NA
6, 3, C, 3, 6,
06107, Tulare
7, 3, C, 4, 6,
06027, Inyo
â¦.
If I can create and save the such a new shapefile, I know how to use the
geosphere package to calculate the areas of each of my new polygons and hence
can compute the area that each local polygon has in any given county.
Does anyone know how I can merge the two shapefiles like this?
Thanks
Joe
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo