I want to multiply the shapefile (.shp and related files here ) into another, limited by a set of coordinates, say between long [80,90] and armor [20,30], and then write this as another shapefile. If I use the maptools
package:
df = readShapeLines("/path/asia_rivers.shp")
and then look at the file structure using as.data.frame(df)
, I cannot find an obvious way to subset the coordinates. I can use the PBSmapping
package for a subset:
df = importShapefile("/path/asia_rivers.shp") df_sub = subset(df, X>=80 & X<=90 & Y >=20 & Y <=30)
but then I canβt get him to force it to a SpatialLines
data SpatialLines
, which can be exported via writeSpatialShape()
to maptools
. I keep getting this error: Error in PolySet2SpatialLines(df_sub) : unknown coordinate reference system
. Of course, I'm missing something very basic and should there be an easy way to subset geodata by geo-coordinates?
source share