Arc features the TREND function with linear interpolation up to 12th order. Is there an equivalent approach in R (preferably) or python?

I'm trying to de-trend a raster surface using polynomial regression. Unfortunately, spatialEco::raster.deviation() is limited to 2nd order, and I'd ideally like to use 12th, so it isn't feasible here.

Edit: I've found a method that begins to approach my goal: the surf.ls function in R's spatial library. raster::rasterToPoints() gets you to the class you need for surf.ls. However, this method is still limited to 6th-order polynomials so I'm going to leave the question unresolved in the event that a more complete TREND equivalent exists.


Take a look at the spatial::surf.ls function although, I would seriously question the use of a 12th order polynomial. At that point you should be using a more robust interpolator and as far as de-trending, with a 12th order fit you have no idea as to what spatial process you are actually de-trending. Plausibly, you could end up with an exact adherence to the input observations and functionally negate the real values and not anything resembling a spatial trend.

A de-trending approach should really be limited to a large-scale spatial process, removing 1st order (global), and not local, autocorrelation. If it was that easy to remove higher-order autocorrelation, as I am assuming you are attempting with a 12th order polynomial, we would not tolerate exploratory application of methods such as GWR in dealing with nonstationarity. Besides, the very nature of nonstationarity is at the observational level and not sample or population. This basically negates the idea of removing local autocorrelaion at the scale an extremely high-level polynomial, or other curve fitting function, would infer.

  • 1
    It might be worth pointing out that a model that is polynomial in x and y up to degree 12 has 91 coefficients. – Spacedman Dec 21 '18 at 15:32
  • Ok, thanks both. In that case, what is the utility in ArcGIS offering a 12th order polynomial? – JepsonNomad Dec 21 '18 at 19:50
  • 2
    @JepsonNomad I don't know for sure, but maybe the competing GIS only had 11th order polynomial fitting. – Spacedman Dec 22 '18 at 11:33

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.