I want to subset out a shapefile (the .shp and associated files are here) into another one bounded by a set of coordinates, say between longs [80,90] and lats [20,30], and t
I know this has been answered, but I think you can do exactly what you want using PBSmapping
. PBSmapping
has a function to clip Polysets (for polygon and lines data) so you can try:
df <- importShapefile("/path/asia_rivers.shp")
df_sub <- clipLines(df, xlim = c(80 , 90) , ylim = c(20 , 30), keepExtra = TRUE )
dfSL <- PolySet2SpatialLines( df_sub )
The keep extra allows you to keep non-standard columns when you do the clipping (I assume for attribute data).