Closed caldwellst closed 2 months ago
will look into it more... just putting down a couple notes from my first glance:
Warning message:
In st_point_on_surface.sfc(sf::st_zm(x)) :
st_point_on_surface may not give correct results for longitude/latitude data
As indicated the warning message originates from sf::st_point_on_surface()
, however in our context warning is only generated when labeling the cities insidegeom_cities()
with geom_text_repel()
. Interestingly no warning when plotting the point(s) themselves inside geom_cities()
ggrepel$geom_text_repel(
data = sf_cities,
mapping = gg$aes(
label = name,
geometry = geometry
),
stat = "sf_coordinates",
min.segment.length = Inf,
family = "Source Sans 3",
color = "black"
)
I think i found a work-around -- which is to add fun.geometry argument.
ggrepel$geom_text_repel(
data = sf_cities,
mapping = gg$aes(
label = name,
geometry = geometry
),
stat = "sf_coordinates",
fun.geometry = \(x) sf::st_centroid(x , of_largest_polygon = F),
min.segment.length = Inf,
family = "Source Sans 3",
color = "black"
)
Some points I don't fully understand yet:
of_large_polygon=T
it works, but the point moves from default text_repel location. Not necessarily in a bad wayst_centroid()
directly on the data input does not remove the warning messageI got the fun.geometry
from:
https://stackoverflow.com/questions/73623865/ggplot2-and-eurostat-row-removed-due-to-missing-values-geom-text-using-geom-s
So there might be some more interesting tidbits/clues there.
anyways will add the map testing PR
Closed by #75
Somehow have maps not generate warnings when plotting longitude/latitude in
geom_sf()
.