Open friendly opened 1 year ago
I also tried the grid designer, uploading my grid as a .csv file. It gave me this error:
There are duplicates of the following (row,col) indices: (9,1), (7,8), (4,0), (5,0), (8,1), (5,3), (4,8), (2,7), (4,5), (6,3), (1,6), (8,7), (9,7), (5,7), (3,5). Please correct this by editing the csv above and repopulate.
I guess I have to try more bins, but I'm still stumped on how to use my own grid.
I posted a revision of the code above, but using a 17 x 17 grid on SO, https://stackoverflow.com/questions/76268255/how-to-create-a-geofacet-grid-from-the-guerry-map-of-france-in-1830
Sorry to persist, but I'd really like to solve this. I'm attaching the .csv file for my 17 x 17 grid. There are no duplicates. gfrance85_grid.csv
grid_preview()
refuses to accept this:
> grid_preview("gfrance85_grid") +
+ geom_text(aes(label=name), size=2, nudge_y=0.35)
grid 'gfrance85_grid' not found in package, checking online...
Error in get_grid(x) : grid 'gfrance85_grid' not recognized...
I also tried to use your GeoGrid Designer with this csv file. But it gives me:
All row and column indices must be positive. Please correct this by editing the csv above and repopulate.
How can I make this work?
You need to send the data frame object gfrance85_grid
to grid_preview()
, not the string "gfrance85_grid"
. If you send a string it searches the collection of grids that have already been contributed to the package.
However, if you send the data frame, you will get the following error:
grid_preview(gfrance85_grid) +
geom_text(aes(label = name), size = 2, nudge_y = 0.35)
# Error: A custom grid must have unique row/column locations for each entry
There are several entries that share the same grid cell:
count(gfrance85_grid, row, col) %>% arrange(desc(n))
# row col n
# 1 2 7 2
# 2 3 8 2
# 3 4 6 2
# 4 5 1 2
# 5 5 6 2
# 6 5 9 2
# 7 6 1 2
# 8 6 4 2
# 9 6 8 2
# 10 7 4 2
# 11 8 9 2
# 12 9 2 2
# 13 9 8 2
# 14 10 2 2
# 15 10 8 2
# 16 1 8 1
# 17 2 8 1
# ...
Have you tried using grid_auto()
?
I'm re-opening this query #353 after I have what I think is a solution, but I get an error when I try to use it. The code below creates
gfrance85_grid
from the map dataGuerry::gfrance85
.This looks OK to me:
grid_preview
gives me this error, suggesting it does not accept an appropriate grid data frame as input, but instead looks inside the package: