I'm working with a global shapefile in R that is latlong projected. I'd like to reproject it into the appropriate UTM projection for individual zones. But, I'd like to chop it up into those zones before reprojection, instead of having multiple global reprojections into UTM most of which have meaningless coordinates. Also, computational efficiency. So, how would I split a latlong shapefile into areas corresponding to UTM zones before the reprojection (and a little overhang is fine)?
You can use
raster to crop to a defined extent, in this case your UTM zone approximate boundary.
So I have a world map shapefile:
> w class : SpatialPolygons features : 1 extent : -179.9997, 180, -89.9999, 83.2479 (xmin, xmax, ymin, ymax) coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
And some xy coordinates of a box to crop to:
> xy $x  -4.386177 28.181688 $y  78.54324 -86.03500
You might want to tweak the latitude limits depending on how near the poles your world shapefile goes. Set the longitude (x) to your UTM zone.
> library(raster) > wc = crop(w, extent(SpatialPoints(data.frame(xy)))) > plot(w) > plot(wc, add=TRUE,col="red",lwd=2)
Note you better not have any odd geometry problems in your world shapefile...