After reading a lot of posts and websites I can't find out how to create a polygon shapefile from my lon-lat data table. I would like to create maps like this one.
My csv data file contains longitude, latitude and attribute of 1000 points in the Mediterranean. I would like to create shapefiles subsetting data by attribute and then plot with ggplot2 geom_polygon
, filling with attribute.
I have tried this R code (from https://mcmap.net/q/550366/-create-convex-hull-polygon-from-points-and-save-as-shapefile) but without success
library("sp")
library("rgdal")
clust1 <- subset(datos, datos$cluster == 1)
coords<-cbind(clust1$longitud,clust1$latitud)
sp_poly <- SpatialPolygons(list(Polygons(list(Polygon(coords)), ID=1)))
sp_poly_df <- SpatialPolygonsDataFrame(sp_poly, data=data.frame(ID=1))
writeOGR(sp_poly_df, "chull", layer="chull", driver="ESRI Shapefile")
ggplot() + geom_polygon(data=sp_poly_df, aes(x=long, y=lat, group=group))
That produces this output that's not obviously a shapefile/polygon
plot(sp_poly_df)
gives this:
Do I need to previously fortify sp_poly_df to plot with ggplot?
How can I create a shapefile or SpatialPolygon? I would like to merge all points with the same cluster attribute to map the different areas/polygons in the data set and then fill the polygons with the cluster value. Maybe this, creating polygons/shapefiles, is not the best approach to produce this type of map.
Have also tried geom_map
but it is not exactly what I want:
ggplot() +
geom_point(data=datos, aes(x=longitud, y=latitud, color=id),
alpha=1, na.rm=TRUE) + scale_size(range=c(1,12)) +
scale_color_identity() +
labs(title= "med cluster",
x="Longitude", y= "Latitude") + coord_map()
Thanks in advance for your help
Data used:
> dput(dato)
structure(list(longitud = c(18.875, 19.125, 19.375, 18.375, 18.625,
18.875, 19.125, 19.375, 19.625, 19.875, 17.875, 18.125, 18.375,
18.625, 18.875, 19.125, 19.375, 19.625, 19.875, 20.125, 28.875,
29.125, 29.375, 17.125, 17.375, 17.625, 17.875, 18.125, 18.375,
18.625, 18.875, 19.125, 19.375, 19.625, 19.875, 20.125, 27.875,
28.125, 28.375, 28.625, 28.875, 29.125, 29.375, 29.625, 29.875,
32.625, 32.875, 33.625, 33.875, 15.875, 16.125, 16.375, 16.625,
16.875, 17.125, 17.375, 17.625, 17.875, 18.125, 18.375, 18.625,
18.875, 19.125, 19.375, 19.625, 19.875, 20.125, 27.125, 27.375,
27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125, 29.375,
29.625, 29.875, 30.125, 30.375, 32.125, 32.375, 32.625, 32.875,
33.125, 33.375, 33.625, 33.875, 34.125, 15.625, 15.875, 16.125,
16.375, 16.625, 16.875, 17.125, 17.375, 17.625, 17.875, 18.125,
18.375, 18.625, 18.875, 19.125, 19.375, 19.625, 19.875, 25.375,
25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125, 27.375,
27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125, 29.375,
29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125, 31.375,
31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125, 33.375,
33.625, 33.875, 34.125, 34.375, 15.375, 15.625, 15.875, 16.125,
16.375, 16.625, 16.875, 17.125, 17.375, 17.625, 17.875, 18.125,
18.375, 18.625, 18.875, 19.125, 19.375, 19.625, 19.875, 25.125,
25.375, 25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125,
27.375, 27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125,
29.375, 29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125,
31.375, 31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125,
33.375, 33.625, 33.875, 34.125, 34.375, 34.625, 15.375, 15.625,
15.875, 16.125, 16.375, 16.625, 16.875, 17.125, 17.375, 17.625,
17.875, 18.125, 18.375, 18.625, 18.875, 19.125, 19.375, 19.625,
19.875, 23.875, 24.125, 24.375, 24.625, 24.875, 25.125, 25.375,
25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125, 27.375,
27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125, 29.375,
29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125, 31.375,
31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125, 33.375,
33.625, 33.875, 34.125, 34.375, 34.625, 15.125, 15.375, 15.625,
15.875, 16.125, 16.375, 16.625, 16.875, 17.125, 17.375, 17.625,
17.875, 18.125, 18.375, 18.625, 18.875, 19.125, 19.375, 19.625,
19.875, 20.125, 20.375, 23.125, 23.375, 23.625, 23.875, 24.125,
24.375, 24.625, 24.875, 25.125, 25.375, 25.625, 25.875, 26.125,
26.375, 26.625, 26.875, 27.125, 27.375, 27.625, 27.875, 28.125,
28.375, 28.625, 28.875, 29.125, 29.375, 29.625, 29.875, 30.125,
30.375, 30.625, 30.875, 31.125, 31.375, 31.625, 31.875, 32.125,
32.375, 32.625, 32.875, 33.125, 33.375, 33.625, 33.875, 34.125,
34.375, 34.625, 34.875, 14.375, 14.625, 14.875, 15.125, 15.375,
15.625, 15.875, 16.125, 16.375, 16.625, 16.875, 17.125, 17.375,
17.625, 17.875, 18.125, 18.375, 18.625, 18.875, 19.125, 19.375,
19.625, 19.875, 20.125, 20.375, 20.625, 20.875, 23.125, 23.375,
23.625, 23.875, 24.125, 24.375, 24.625, 24.875, 25.125, 25.375,
25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125, 27.375,
27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125, 29.375,
29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125, 31.375,
31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125, 33.375,
33.625, 33.875, 34.125, 34.375, 34.625, 34.875, 12.375, 12.625,
12.875, 13.125, 13.375, 13.625, 13.875, 14.125, 14.375, 14.625,
14.875, 15.125, 15.375, 15.625, 15.875, 16.125, 16.375, 16.625,
16.875, 17.125, 17.375, 17.625, 17.875, 18.125, 18.375, 18.625,
18.875, 19.125, 19.375, 19.625, 19.875, 20.125, 20.375, 20.625,
20.875, 21.125, 21.375, 21.625, 22.375, 22.625, 22.875, 23.125,
23.375, 23.625, 23.875, 24.125, 24.375, 24.625, 24.875, 25.125,
25.375, 25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125,
27.375, 27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125,
29.375, 29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125,
31.375, 31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125,
33.375, 33.625, 33.875, 34.125, 34.375, 34.625, 34.875, 35.125,
11.625, 11.875, 12.125, 12.375, 12.625, 12.875, 13.125, 13.375,
13.625, 13.875, 14.125, 14.375, 14.625, 14.875, 15.125, 15.375,
15.625, 15.875, 16.125, 16.375, 16.625, 16.875, 17.125, 17.375,
17.625, 17.875, 18.125, 18.375, 18.625, 18.875, 19.125, 19.375,
19.625, 19.875, 20.125, 20.375, 20.625, 20.875, 21.125, 21.375,
21.625, 21.875, 22.125, 22.375, 22.625, 22.875, 23.125, 23.375,
23.625, 23.875, 24.125, 24.375, 24.625, 24.875, 25.125, 25.375,
25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125, 27.375,
27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125, 29.375,
29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125, 31.375,
31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125, 33.375,
33.625, 33.875, 34.125, 34.375, 34.625, 34.875, 35.125, 11.125,
11.375, 11.625, 11.875, 12.125, 12.375, 12.625, 12.875, 13.125,
13.375, 13.625, 13.875, 14.125, 14.375, 14.625, 14.875, 15.125,
15.375, 15.625, 15.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 18.125, 18.375, 18.625, 18.875, 19.125,
19.375, 19.625, 19.875, 20.125, 20.375, 20.625, 20.875, 21.125,
21.375, 21.625, 21.875, 22.125, 22.375, 22.625, 22.875, 23.125,
23.375, 23.625, 23.875, 24.125, 24.375, 24.625, 24.875, 25.125,
25.375, 25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125,
27.375, 27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125,
29.375, 29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125,
31.375, 31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125,
33.375, 33.625, 33.875, 34.125, 34.375, 34.625, 34.875, 35.125,
10.875, 11.125, 11.375, 11.625, 11.875, 12.125, 12.375, 12.625,
12.875, 13.125, 13.375, 13.625, 13.875, 14.125, 14.375, 14.625,
14.875, 15.125, 15.375, 15.625, 15.875, 16.125, 16.375, 16.625,
16.875, 17.125, 17.375, 17.625, 17.875, 18.125, 18.375, 18.625,
18.875, 19.125, 19.375, 19.625, 19.875, 20.125, 20.375, 20.625,
20.875, 21.125, 21.375, 21.625, 21.875, 22.125, 22.375, 22.625,
22.875, 23.125, 23.375, 23.625, 23.875, 24.125, 24.375, 24.625,
24.875, 25.125, 25.375, 25.625, 25.875, 26.125, 26.375, 26.625,
26.875, 27.125, 27.375, 27.625, 27.875, 28.125, 28.375, 28.625,
28.875, 29.125, 29.375, 29.625, 29.875, 30.125, 30.375, 30.625,
30.875, 31.125, 31.375, 31.625, 31.875, 32.125, 32.375, 32.625,
32.875, 33.125, 33.375, 33.625, 33.875, 34.125, 34.375, 34.625,
34.875, 35.125, 35.375, 10.125, 10.375, 10.625, 10.875, 11.125,
11.375, 11.625, 11.875, 12.125, 12.375, 12.625, 12.875, 13.125,
13.375, 13.625, 13.875, 14.125, 14.375, 14.625, 14.875, 15.125,
15.375, 15.625, 15.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 18.125, 18.375, 18.625, 18.875, 19.125,
19.375, 19.625, 19.875, 20.125, 20.375, 20.625, 20.875, 21.125,
21.375, 21.625, 21.875, 22.125, 22.375, 22.625, 22.875, 23.125,
23.375, 23.625, 23.875, 24.125, 24.375, 24.625, 24.875, 25.125,
25.375, 25.625, 25.875, 26.125, 26.375, 26.625, 26.875, 27.125,
27.375, 27.625, 27.875, 28.125, 28.375, 28.625, 28.875, 29.125,
29.375, 29.625, 29.875, 30.125, 30.375, 30.625, 30.875, 31.125,
31.375, 31.625, 31.875, 32.125, 32.375, 32.625, 32.875, 33.125,
33.375, 33.625, 33.875, 34.125, 34.375, 34.625, 34.875, 35.125,
35.375, 10.125, 10.375, 10.625, 10.875, 11.125, 11.375, 11.625,
11.875, 12.125, 12.375, 12.625, 12.875, 13.125, 13.375, 13.625,
13.875, 14.125, 14.375, 14.625, 14.875, 15.125, 15.375, 15.625,
15.875, 16.125, 16.375, 16.625, 16.875, 17.125, 17.375, 17.625,
17.875, 18.125, 18.375, 18.625, 18.875, 19.125, 19.375, 19.625,
19.875, 20.125, 20.375, 20.625, 20.875, 21.125, 21.375, 21.625,
21.875, 22.125, 22.375, 22.625, 22.875, 23.125, 23.375, 23.625,
23.875, 24.125, 24.375, 24.625, 24.875, 25.125, 25.375, 25.625,
25.875, 26.125, 26.375, 26.625, 26.875, 27.125, 27.375, 27.625,
27.875, 28.125, 28.375, 28.625, 28.875, 29.125, 29.375, 29.625,
29.875, 30.125, 30.375, 30.625, 30.875, 31.125, 31.375, 31.625,
31.875, 32.125, 32.375, 32.625, 32.875, 33.125, 33.375, 33.625,
33.875, 34.125, 34.375, 34.625, 34.875, 35.125, 35.375, 35.625,
10.375, 10.625, 10.875), latitud = c(30.375, 30.375, 30.375,
30.625, 30.625, 30.625, 30.625, 30.625, 30.625, 30.625, 30.875,
30.875, 30.875, 30.875, 30.875, 30.875, 30.875, 30.875, 30.875,
30.875, 30.875, 30.875, 30.875, 31.125, 31.125, 31.125, 31.125,
31.125, 31.125, 31.125, 31.125, 31.125, 31.125, 31.125, 31.125,
31.125, 31.125, 31.125, 31.125, 31.125, 31.125, 31.125, 31.125,
31.125, 31.125, 31.125, 31.125, 31.125, 31.125, 31.375, 31.375,
31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375,
31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375,
31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375,
31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375,
31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.375, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.625,
31.625, 31.625, 31.625, 31.625, 31.625, 31.625, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875, 31.875,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125,
32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.125, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375, 32.375,
32.375, 32.375, 32.375, 32.375, 32.375, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625, 32.625,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875, 32.875,
32.875, 32.875, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125, 33.125,
33.125, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375, 33.375,
33.375, 33.375, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625, 33.625,
33.625, 33.625, 33.625, 33.625, 33.625, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875, 33.875,
33.875, 33.875, 33.875, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125, 34.125,
34.125, 34.125, 34.375, 34.375, 34.375), cluster = c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L,
3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 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5L, 4L,
4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 2L, 2L, 4L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L,
1L, 1L, 1L, 5L, 5L, 5L)), .Names = c("longitud", "latitud", "cluster"
), row.names = c(NA, 1000L), class = "data.frame")
geom_map
call or putput anywhere? – RepulsiverasterFromXYZ()
and then converting to polygons usingrasterToPolygons
. By the way: the data you shared are clearly not what you used to create the "ggmap" figure, since they cover a smaller extent and number of classes, so it is not possible to test any solution. – Vindicate