RCaller: Interpolate Points to Raster Through Kriging

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

The RCaller transformer enables significantly more statistical analysis than the StatisticsCalculator transformer. This example shows how the RCaller can be used to create a raster from points. Kriging, an interpolation method, is used to create an estimated surface from cell signal point data.

Requirements

Required R packages:

  • sqldf
  • geoR
  • sp
  • raster

As of FME 2019.0, you can output an R raster object directly from the RCaller for further use in FME, as shown in the example below. This scenario is ideal for users who want to conduct raster processing with R packages and then continue in an FME workflow. A similar result is technically also possible in earlier versions of FME, but you will not be able to directly output a raster object from RCaller. Instead, you have to write a temporary raster (using e.g. the raster package's writeRaster() function) and then read it back into the workspace using a FeatureReader and a file path attribute.

More information on installing R and R packages.

Source Data

Cell signal point data in CSV format.

Step-by-Step Instructions

1. Read Source Data

Read the DataPoints.csv using a CSV Reader, set the Coord. System to LL84. Open the Parameters dialog and confirm that the longitude and latitude attributes are set to x_coordinate and y_coordinate, respectively. If they are not, change the Attribute Definition to Manual, then manually set.

As of FME 2025.2, the Coordinate System parameter is now configured within the Parameters dialog of each reader/writer format. For more information, including details about the change and affected transformers, please see Coordinate System Parameter Location Change.

For FME 2025.2 and newer, enable Create Point Geometry From Attributes in the Parameters dialog, then set the Coordinate System.

2. Reproject 

Reproject the data from lat/long (degree) to UTM83-10 (meter) using the Reprojector.

3. Extract Coordinate Values

The CoordinateExtractor transformer extracts the x and y coordinate values of the points and adds them as attributes named easting (x) and northing (y). Easting and northing will be used to create a map and for kriging in the RCaller.

4. Add RCaller and R script

Connect an RCaller to the CoordinateExtractor. In the parameters, set the Table to CellSignals, then select Quality, easting, and northing as the Column, set their types to float. 


The R script interpolates points with the Kriging method and creates a RasterLayer object using the raster package. Then the RasterLayer object is added to the fmeOutput data frame in a column called raster (i.e. fmeOutput$raster). For the R script, please specify the following:

# Read in the sp and geoR libraries
library(sp)
library(geoR)

# SpatialPointsDataFrame - create an object of class SpatialPointsDataFrame. 
map = SpatialPointsDataFrame(data=CellSignals, coords=cbind(CellSignals$easting,CellSignals$northing))

pred.grid <- expand.grid(
    seq(min(CellSignals$easting),max(CellSignals$easting),50),seq(min(CellSignals$northing),max(CellSignals$northing),50)
    )
    
# likfit, maximum likelihood (ML) or restricted maximum likelihood (REML) parameter estimation for (transformed) Gaussian random fields
ml=likfit(coords=coordinates(map), data=map$Quality, ini=c(10000,10000), nug=10)

# krige.conv performs spatial prediction for fixed covariance parameters using global neighbourhood
kc <- krige.conv(coords=coordinates(map), data=map$Quality, loc=pred.grid, krige=krige.control(obj.m=ml))

# Create raster using raster package
rasterdata <- cbind(pred.grid, kc$predict)
r <- rasterFromXYZ(rasterdata)

#Specify a value for the NoData cells
NAvalue(r) <- -999

# Put raster object into data.frame as column named raster for FME.
fmeOutput <- data.frame(matrix(ncol=1,nrow=1))
colnames(fmeOutput) <- c("raster")
fmeOutput$raster <- c(r)

Finally, for Attributes to Expose type in Raster. 

5. Reset the Coordinate System

Add a CoordinateSystemSetter to the canvas and connect it to the Output port on the RCaller. In the parameters, reset the coordinate system to UTM83-10, which was lost in the RCaller.

6. View the Result in Visual Preview

Add an Inspector to the CoordinateSystemSetter, then run the workspace. View the output in Visual Preview, where you should have a raster of your data points. 

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.