How to add columns names to a spatialpolygon based on column from a dataframe?

Dummy SpatialPolygon:

      x_coord  y_coord
 [1,] 16.48438 59.73633
 [2,] 17.49512 55.12207
 [3,] 24.74609 55.03418
 [4,] 22.59277 61.14258
 [5,] 16.48438 59.73633

library(sp)
p = Polygon(xym)
ps = Polygons(list(p),1)
sps = SpatialPolygons(list(ps))
plot(sps)

Dummy dataframe:

df <- data.frame (date= c("2021", "2015", "2018"),
                  value= c(100, 147, 25))

Basic question but how can I add the columns names of the dataframe to the spatial polygon (I don't need to add some value, I just want my spatialpolygon to have the field "date" and "value")



from Recent Questions - Stack Overflow https://ift.tt/3KJqAZX
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation