You could try the focalFilter function in the raster package:
install.packages("raster", repos="http://R-Forge.R-project.org";)
with this argument for the Sobel filter:
filter=matrix(c(1,2,1,0,0,0,-1,-2,-1) / 4, nrow=3)
(For using raster this way you should upgrade to R 2.9 first, if you
have not
I'm looking to calculate gradients from oceanographic variables (ie. sea
surface temperature, chlorophyll, etc.) for which I have downloaded in ESRI
grid format (.asc). From some research on gradient analysis, I have found a
few people who have used a Sobel filter to estimate gradients in images (