Code covered by the BSD License  

Highlights from


4.0 | 1 rating Rate this file 32 Downloads (last 30 days) File Size: 4.24 KB File ID: #39796
image thumbnail




10 Jan 2013 (Updated )

Transform cartesian to curvilinear orthogonal coordinates, e.g. a flow-oriented coordinate system.

| Watch this File

File Information

Analysing or interpolating scattered data that follow a common centerline, like bathymetry data in a river, may require interpreting the data in terms of their position along and distance from that centerline. For example, river bathymetry varies more strongly laterally to the river centerline than longitudinally.

This submission provides two functions, xy2sn and sn2xy, to transform between cartesian (xy) and curvilinear orthogonal (sn) coordinates using a spline representation of a centerline.

It requires the arclength, interparc, and distance2curve functions by John D'Errico. In the distance2curve function, there is a small bug that needs to be corrected in order for xy2sn to work: Line 453 in distance2curve.m should read "if nargout == 3" instead of "if nargout > 3".

The approach is based on Merwade et al (2005) "Geospatial Representation of River Channels", Journal of Hydrological Engineering, 10, 243-251.


Distance2curve, Arclength, and Interparc inspired this file.

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
17 Dec 2013 Juernjakob Dugge

Thanks for the feedback, Jie. I've edited the function to now use a linear approximation of the smoothed pathline, which speeds up the process significantly.

12 Dec 2013 Jie

Hi, Juernjakob, this program is very useful for handling river data. The problem is that the efficiency of this program need to be improved. I tried it for just 150,000 points, and it is not finished for more than half an hour. You know, for most of field applications, data sets with more than one million data points is very common. So, it will be more useful, if the efficiency of this program could be improved in future.

27 Feb 2013

Added check for a bug in "distance2curve.m"

17 Dec 2013

Dramatically increased performance by using a piecewise linear approximation for the smoothed centerline.

Contact us