I'm a bit new to R and so this mights seem an easy command for you. I have a shapefile loaded in R with several polygons in it, and I just would like to plot the first polygon. I tried several commands but it's not working.
My aim is to crop a raster with that first element of my shapefile, again I tried several stuff but it's not working..
I hope I'm clear,
Thanks a lot!
Jude
Assuming your polygons are called pols, this should work for you:
plot(pols[1,])
A spatial polygon dataframe is just like any other df in this case, with each row corresponding to a feature. So if you want to subset it, you can use ordinary indexing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With