[R-sig-Geo] 'nowrapSpatialPolygons' doesn't remove horizontal scratches

Roger Bivand Roger.Bivand at nhh.no
Fri Jan 7 20:21:13 CET 2011


On Fri, 7 Jan 2011, Kevin Ummel wrote:

> Hello,
>
> I have a shapefile with polygons located in Oceania, some of which straddle longitude =-180/0. When plotted, horizontal scratches result. I assumed that use of 'nowrapSpatialPolygons' would do the trick, but the plot looks the same before and after. Clearly, I'm not utilizing it properly. Could someone look at the example code below Ultimately, I need to successfully rasterize the data onto a -180/180 grid, so maybe another solution exists...
>
> Thanks!
> Kevin
>
> The folder (WDPA Oceania) with the example shapefile can be downloaded here: http://dl.dropbox.com/u/14314000/WDPA%20Oceania.zip
>
> orig=readShapeSpatial("sql_statement",CRS("+proj=longlat"))
>
> plot(orig)
>
> out=nowrapSpatialPolygons(orig,offset=180)

No, you mean:

out <- recenter(orig)
out1 <- SpatialPolygonsDataFrame(out, data=slot(orig, "data"))
plot(out1, axes=TRUE)

If you need to merge the input polygons that were split by 180 degrees, 
and now appear as touching polygons, you'll need to identify them somehow.

Hope this helps,

Roger

>
> plot(out)
>
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list