I'm trying to filter a transect, window size is 5 and filter individual baselines is set to 0. I select the transect shapefile, then the inner baseline shapefile and it gives me this error.

Error in SpatialLinesDataFrame(shape.prep2, trandata) : row.names of data and 
Lines IDs do not match.

I did everything correct up to this point, add fields to shapefiles, construct transects, stuck on filter transects. Anyone know how to fix this error or knows what it means?

The syntax for SpatialLinesDataFrame is

function (sl, data, match.ID = TRUE)
if (is.character(match.ID)) {
    row.names(data) = data[, match.ID[1]]
    match.ID = TRUE
if (match.ID) {
    Sl_IDs <- sapply(slot(sl, "lines"), function(x) slot(x, 
    data_IDs <- row.names(data)
    mtch <- match(Sl_IDs, data_IDs)
    if (any(is.na(mtch))) 
        stop("row.names of data and Lines IDs do not match")
    if (length(unique(mtch)) != length(Sl_IDs)) 
        stop("row.names of data and Lines IDs do not match")
    data <- data[mtch, , drop = FALSE]
if (nrow(data) != length(sl@lines)) 
    stop("length of data.frame does not match number of Lines elements")
new("SpatialLinesDataFrame", sl, data = data)
<environment: namespace:sp>

not too familiar with code sorry. The error is happening because one of those if statements. Looking at the documentation on the R website I see that shape.prep2 is the object in SpatialLines class and trandata is an object in the data.frame class. "object of class data.frame; the number of rows in data should equal the number of Lines elements in sl." It must be something wrong with one of the shapefiles.

  • show your code plz. Aug 22, 2013 at 14:14
  • There really isn't any code I just load the ambur package then type > library(ambur) > ambur.gui() and the rest is done in the gui with the error popping up in the console
    – user21320
    Aug 22, 2013 at 14:18
  • Contact me at [email protected] and I can help!
    – user21343
    Aug 23, 2013 at 5:42

1 Answer 1


I don't know, if this question is still open, but the error should be fixed by simply setting match.ID to FALSE.

SpatialLinesDataFrame(sl, data, match.ID = FALSE)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.