Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Spline interpolation of spatial data

From   "Roger B. Newson" <>
Subject   Re: st: Spline interpolation of spatial data
Date   Tue, 10 Jan 2012 13:11:22 +0000

One possible method is to use reference spline bases, which can be generated using the -bspline- package, downloadable from SSC. A reference spline basis has the feature that the corresponding parameters are simply the values of the spline at reference points on the X-axis, or differences between the values of the spline at the reference points and values of the spline at a base reference point. So, reference splines play the role for continuous factors that dummy variables play for discrete factors. And they can be combined in a similar way to the multivariate case by defining product bases, whose corresponding parameters are values of the spline at combinations of values of the multiple X-variables.

The -bspline- package has a manual -bspline.pdf-, distributed with the package on SSC as an ancillary file. And you can find out more about the -flexcurv- module of the -bspline- package in Newson (2011).

I hope this helps.

Best wishes



Newson R. B. Sensible parameters for polynomials and other splines. Presented at the 17th UK Stata User Meeting, 15-16 September, 2011. Download from

Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Web page:
Departmental Web page:

Opinions expressed are those of the author, not of the institution.

On 10/01/2012 12:02, Gordon Hughes wrote:
Dear Statalist,

I would be grateful for suggestions about whether there are any routines
in Stata - or other software - to carry out a rather specific form of
spline surface interpolation. The context is fairly common with GIS
raster data: I have multiple sets of spatial data at different grid
resolutions which I want to combine to form weighted averages. Assuming
a uniform distribution over the coarser grid units may introduce errors
of unknown magnitude that I would like to examine.

As a concrete example, I have average temperatures for 1 deg grid cells
covering the continental US. In addition, I have estimates of total
population by 30 arc-second grid cells for the same area. I want to
calculate estimates of population-weighted temperature exposure by state
and/or county. If population density and/or temperature distribution are
not uniform within each 1 deg grid cell, the simple procedure of summing
the population in each 1 deg cell and then computing population-weighted
average temperatures by state fails to allow for the non-uniform
distribution of population and/or temperature.

A better approach would be to convert each 1 deg grid cell to a 12 x 12
(5 arc-min) mesh and use cubic or some other spline surfaces to
interpolate temperatures over this mesh subject to a constraint on the
average temperature for the whole grid cell and on knots at the boundary
points. This is a non-trivial exercise and I cannot locate any Stata
routines that do anything like this. There are monographs in mathematics
and computational graphics that cover the general topic - notably a
monograph by Paul Dierckx titled 'Curve and surface fitting with
splines' (Clarendon Press, 1993). In addition, there are specialised
algorithms that are used in 3D graphical software, though generally
these focus on interpolation of points rather than averages. Some of
Dierckx's algorithms - originally in Fortran and called FitPack - have
been translated into R and Python, but these are not easy to convert to
Stata or Mata.

Does anyone have any suggestions of routines in either Stata or Matlab
or some other matrix language that might provide a starting point for
spatial interpolation of this kind?

Gordon Hughes
* For searches and help try:
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index