[R-sig-Geo] sp::overlay problem

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Apr 12 23:27:02 CEST 2011


Piero, why don't you spTransform your points to the CRS of the grid?

On 04/12/2011 03:04 PM, piero campa wrote:
> Dear list,
> I have a SpatialGridDataFrame, whose SRS is EPSG:32632:
> "+init=epsg:32632 +proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m
> +no_defs +towgs84=0,0,0"
> 
> I am willing to overlay these grid values over point locations defined in a
> SpatialPixelsDataFrame with a different SRS using the overlay method
> (overlaying grids over points in the same SRS gave me no problem until now).
> 
> Now instead I need to transform the point locations to EPSG:32632 and then
> overlay: 
>> my.ov <- overlay(my.grid, spTransform(mySpatialPixels,
>> CRS=CRS(proj4string(my.grid))))
> [looking at methods?sp::overlay, transforming the grid to the points SRS
> would coerce the grid itself into points, and then the overlay method would
> not be useful anymore]
> 
> But then the output "my.ov" is filled with NAs only.
> 
> I checked the bbox of the overlay inputs, and they overlap:
>> bbox(my.grid)
>               min     max
> coords.x1  513000  911000
> coords.x2 4844000 5002000
>> bbox(mySpatialPixels)
>         min       max
> x  499880.9  822436.4
> y 4816908.3 5045694.8
> 
> Any hint is appreciated.
> Thank you guys.
> /Piero
> 
> http://r-sig-geo.2731867.n2.nabble.com/file/n6265018/overlay.png 
> 
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/sp-overlay-problem-tp6265018p6265018.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list