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

# Re: st: Spline interpolation of spatial data

 From Stas Kolenikov To statalist@hsphsun2.harvard.edu Subject Re: st: Spline interpolation of spatial data Date Tue, 10 Jan 2012 07:16:53 -0600

```I wrote a thin plate splines package some 10 years ago, if that helps.
These are the types of splines appropriate for 2D, as they are the
generalization of the 1D cubic splines, in the sense of being
solutions to the respective optimization problems that give the
smoothest possible solution.

I believe that the expressions for an integral of a spatial field over
2D region (especially as simple as a rectangular cell) are available
in books on spatial statistics. So if I were doing this, I would fit a
variogram to the temperature field, compute my variogram-based
integrals over the census-defined grid, and weight these integrals
with the known population totals. Trying to smooth the population with
this approach will likely be pointless, as the population-generating
process have much finer scales of variability than temperatures do,
and assuming that the temperature is constant over the 30 arc-second
grid cell is a much better assumption than any assumption we can make

Overall, Stata is not the best package to work with spatial data. Of
course you can program anything into Mata, and I believe the examples
of Fortran to Mata translation were given by Bill Gould in his "Mata
Matters" series in Stata Journal.

On Tue, Jan 10, 2012 at 6:02 AM, Gordon Hughes <G.A.Hughes@ed.ac.uk> 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?

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```