EDIT: I've solved the problem, the resolution was simply not high enough to properly show the lines in the plot. My code now looks like this and works fine:
r <- raster(ncol=1000, nrow=1000, extent(sa))
res(r) <- 20
rivers <- rasterize(lines, r)
I've been trying (for two days now), to rasterize a SpatialLines .shp file in R, but every time I load the new raster, I get points instead of lines. I've tried gdal_rasterize and different values and fields, but nothing seems to work. This is a croped version of what it should look like with my DEM underneath:
But instead, it looks like this:
This is my code:
sa <- raster("studyarea.tif")
lines <- readOGR("Gewässer_Uckermark/gewnet25_bb_a.shp")
r <- raster(ncol=1000, nrow=1000, extent(sa))
rivers <- rasterize(lines, r)
rivers[!(is.na(rivers))] <- 1
You can get the .shp file from here: https://geobroker.geobasis-bb.de/gbss.php?MODE=GetProductInformation&PRODUCTID=B9D461F1-99A1-4C10-97B4-9C36C0BD40B9