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

Kevin Ummel kevinummel at gmail.com
Fri Jan 7 23:38:39 CET 2011


Thanks, Roger. I still need the extent of 'out1' to match the extent of 'orig'. i.e. I need to subtract 360 from each out1 x-coordinate greater than 180, but is there an easy way to directly access and overwrite the polygon coordinates? Indexing through the structure -- at least judging by str(out1) -- looks potentially messy.

> extent(orig)
class       : Extent 
xmin        : -180 
xmax        : 180 
ymin        : -68.65256 
ymax        : 22.47224 

> extent(out1)
class       : Extent 
xmin        : 60.87917 
xmax        : 221.1910 
ymin        : -68.65256 
ymax        : 22.47224 

On Jan 7, 2011, at 7:21 PM, Roger Bivand wrote:

> 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