Why my interpolated map created in R is not similar to the one created with Surfer

I would like to map rainfall data. I have to interpolate and then create the map. My problem is that my map created with R is not the same as the one created with Surfer software (of course using the same data). Can any one help how can i produce the same map as Surfer using R.

This is my data and the code used:

library(sp)
library(automap)
library(ggplot2)

#Create data
y<-c(215687.162238248, 238089.822076237, 169586.473794924, 195889.889928256, 205194.373578442,
203242.384734455, 233938.232064, 225888.454169139, 227892.68197848, 228389.845698433,
219493.009778054, 235794.339989575, 215433.810274294, 225144.310519959, 218885.551948723,  
243591.933789792, 257792.197343528, 217037.557117664, 255892.880828147, 255486.459028479,
278591.773470775, 261291.134681867, 260295.145384733, 265443.885999355)

x<-c(194393.587173876, 232138.542602024, 211732.972823955, 258937.28224625, 262389.890041292, 275140.51453176, 277435.541094655, 266482.171556925, 261633.445545259, 286033.757681761, 269635.833751565, 268233.432583096, 261607.625921525, 248286.676386486, 233887.717147903, 254739.22291816, 264985.237911372, 246590.210198199, 232333.235783993, 247634.978556728, 250981.32702818, 266084.042507046, 251387.993501201, 256939.477262534)

z<-c(326.4, 339.2, 254.2, 244.8, 314.1, 131.4, 203.9, 301.3, 316.3, 333.9, 400.2, 203.9, 199.7, 282.8, 390.1, 300.2, 293.8, 170.8, 289.5, 185.6, 277.7, 256.5, 213.5, 311.5)

#Create data frame
my_data<- data.frame("x"=x,"y"=y,"z"=z)

#create box
x.range<-c(148000, 306000)  #Xmin & Xmax
y.range<-c(119700 , 292600) #Ymin & Ymax
grd <- expand.grid(x=seq(from=x.range[1], to=x.range[2], by=500), y=seq(from=y.range[1], to=y.range[2], by=500))
coordinates(grd) <- ~ x+y  #library(sp)
gridded(grd) <- TRUE

coordinates(my_data) <- ~ x+y

# Ordinary kriging
kriging_result = autoKrige(z~1, my_data,grd)

# Universal kriging
#kriging_result = autoKrige(z~x+y, my_data,grd) **# Even suing universal kriging the map is not the same as Surfer**

krg.output=as.data.frame(kriging_result$krige_output)
interpolation.output=as.data.frame(krg.output)

#Plot map with ggplot
names(interpolation.output)[1:3]<-c("x","y","z")

tmp <- interpolation.output$z
interpolation.output$z <- ifelse(tmp <= 200, "100-200", interpolation.output$z)
interpolation.output$z <- ifelse(tmp > 200 & tmp <= 250, "200-250", interpolation.output$z)
interpolation.output$z <- ifelse(tmp > 250 & tmp <= 300, "250-300", interpolation.output$z)
interpolation.output$z <- ifelse(tmp > 300 & tmp <= 350, "300-350", interpolation.output$z)
interpolation.output$z <- ifelse(tmp > 350, "Upper 350", interpolation.output$z)
interpolation.output$z <- factor(interpolation.output$z)

ggplot()+ geom_raster(data=interpolation.output,mapping=aes(x,y,fill=z))+
 geom_path(color="black", linestyle=0.2)+     # draw boundaries
 scale_fill_manual(values = c("darkred","red","yellow","lightblue","blue"))
}

Map created with Surfer: These are options i used in Surfer:
   Gridding method: Kriging
   Kriging Type: Point
   Component type (variograme): Linear (Anisotropy: Ratio=1, Angle=0, Slope=1)
   Drift type: None
   Search: No search (use all data)

Unfortunately, i don't know why the two maps are differents.

Thanks for your help,

I see how the R + ggplot map are created, but how is the surfer map created?

It seems that key changes may be in autoKrige, Surfer could use a different method. And in terms of general look and feel, ggplot has a lot of idiosyncratic theme options that define its look and feel. It's not at all surprising that a plot made with it will look different than one not made with it.

There are a ton of great resources on how to build maps with R and other tools to help you tweak your R output into something more to your liking. Happy to recommend something. I'd be curious what Surfer creates and if you have a reprex for that.

Thanks @EconomiCurtis for your reply.
I can add maps i created.

Thanks again.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.