[R-sig-Geo] Intended usage of gIntersection ?
Roger.Bivand at nhh.no
Sat Sep 13 21:07:06 CEST 2014
On Sat, 13 Sep 2014, Bernd Vogelgesang wrote:
> Dear list,
> I'm trying to intersect two SpatialPolygonsDataFrames imported from shape
> files. (readOGR)
> The idea is to get the new polygons + the merged attributes of both
> layers, but the outcome is a SpatialPolygon class without a data slot.
Since there are no general matches between intersected spatial objects,
any arbitrary operations on attributes require assumptions about unknown
user intentions. This is why no data slots should be passed through.
If the attributes are just identifiers and the intersection operation used
byid=TRUE or at least one of the byid was TRUE, then they are easy to
retreive using the string value of the ro.names() of the intersection
objects. If they are say counts, or any other aggregate value belonging to
the input objects, until someone decides how to transfer the value, nobody
can know. Say one intersected object looses 75% of its area - should the
numerical attributes be reduced by 75%?
The design of gIntesection() is inentional, because only the user can know
what to do with attributes of entities that have their geometries changed.
Different users may make different assumptions, but there is no general
solution beyond passing through the IDs of the intersecting geometries, as
is done in the row.names() mechanism.
Hope this clarifies,
> Is this the intended behaviour of gIntersection or is there something
> broken in my R-Installation, cause I googled now for 2 days to find a
> solution on that problem, but only found two hits on stackexchange where
> people had similar problems, and no working solution (at least for me),
> nor was I able to find any standard recipt how to join the attributes back
> to the new polygons.
> So obviously only rare people seem to have the need to get also the data
> from an intersection or do I miss some really basic R-capabilities not
> worth to write down in any documentation??
> Hope someone can shed some light
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo