Search code examples
rr-rasterr-sp

Turn extraction list to csv file


I have uploaded a raster file and polyline shapefile into R and use the extract function to to extract the data from every pixel along the polyline. How do I turn the list output by extract into a CSV file?


Solution

  • If I understand what it is you're asking, I think you could resolve your situation by using unlist().

    d <- c(1:10)      # creates a sample data frame to use
    
    d <- as.list(d)   # converts the data frame into a list
    
    d <- unlist(d)    # converts the list into a vector