[R-sig-Geo] Intersect shapefiles

Roger Bivand Roger.Bivand at nhh.no
Thu Feb 18 20:00:45 CET 2016


On Thu, 18 Feb 2016, Worrall, James -FS wrote:

> Such a clear and simple explanation - thank you.  I wish the function 
> documentation was written like that.

Please feel free to contribute; the description section shall be short, 
what you seem to want is in the details a little further down the page:

"Returns an sp object with intersecting geometries merged. If geometries 
do not intersect then both are returned as distinct subgeometries."

Note that gUnion is a binary operator (union of two objects) while 
gUnaryUnion is a unary operator with an id argument to map input 
subgeometries to output subgeometries.

I guess this is easier to grasp than the JTS original describing the 
binary union operator: "Computes a Geometry representing all the points in 
this Geometry and other" at

http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#union%28com.vividsolutions.jts.geom.Geometry%29

Roger

>
> -----Original Message-----
> From: Alex Mandel [mailto:tech_dev at wildintellect.com]
> Sent: Thursday, February 18, 2016 9:59 AM
> To: Worrall, James -FS <jworrall at fs.fed.us>; chris english <englishchristophera at gmail.com>; A. Marcia BARBOSA <barbosa at uevora.pt>
> Cc: Help R-Sig_Geo <r-sig-geo at r-project.org>
> Subject: Re: [R-sig-Geo] Intersect shapefiles
>
> Union creates a merged shape including all parts of input objects.
>
> Intersection creates a shape of the overlapping portions of input objects.
>
> I'm not clear on the goal from the initial email so I don't know which is better in this case.
>
> Enjoy,
> Alex
>
> On 02/18/2016 07:55 AM, Worrall, James -FS wrote:
>>
>> I would have thought gUnaryUnion, but then I can't understand from the documentation what the difference is between that and gIntersection.
>>
>> -----Original Message-----
>> From: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of
>> chris english
>> Sent: Thursday, February 18, 2016 7:24 AM
>>
>> John,
>>
>> As Loic suggests, rgeos::gIntersection will get you there. Look closely at his naming of objects and your example code using spTransform. With his approach, each object has its own name; whereas your approach overwrites Rain_poly_merge the second and third time and the final object (third) is the 2008 maize yield. So read your shapefiles into differently named objects and use Loic's approach.
>>
>> Chris
>>
>>
>>
>>
>>
>> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
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
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412



More information about the R-sig-Geo mailing list