I'm a new users of spatial analyses packages in R. I have created a SpatialPolygonsDataFrame which contains a number of rectangular polygons that i named "Square1" to "Square64". Until now there is no problem i can plot these polygons on a map. The problem is that i have a data.frame that contains the number of vesels in each "Square_i" (i=1 to 64) polygon, but i don't know how to relate each polygons in my SpatialPolygonsDataFrame object to the data.

Can anyone help me?

  • Can you post your data? Or at least the structure of your SpatialPolygonsDataFrame?
    – cengel
    Jul 28, 2015 at 23:27

1 Answer 1


In a SpatialPolygonsDataFrame, the polygons and the dataframe should automatically link up through the names of the polygons or the row.names of the dataframe. Assuming your SpatialPolygonsDataFrame is called spdf take a look at:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.