Feature request #13814

Updated by Nyall Dawson about 2 years ago

In Processing, when a layer is passed to an R script, it is first written to a shapefile and then read into R as a SpatialDataFrame before running the user script. In this process, attribute names are truncated to 10 characters.



Attribute names provided to the script from the script parameters are the full-length names and so extracting the values from the SpatialDataFrame fails if the attribute names are longer than ten characters.



Fix would seem to be either use Spatialite as an intermediate format (or anything else that can handle longer names) or write the full attribute names to some metadata file, then after the pre-script code loads the shapefile into the SpatialDataFrame, to read that metadata and assign the original names over the possibly munged ones from the shapefile.



The following test script illustrates the problem when called with an attribute name longer than ten chars:



##Vector Processing=group

## showplots

##Layer=vector

##X=Field Layer



print(names(Layer))

if(! X %in% names(Layer)){

message("Error - attribute ",X," not in ",paste(names(Layer),collapse=","))

}

print(X)

hist(Layer[[X]])

Back