I'm trying to view the latitudinal and longitudinal distributions of different shapes in R. I'm trying to find the area of an sf object across bands of latitude, basically flattening the shape sideways to see where most of its mass is distributed. How would I go about this?
I thought about using st_cast() to reproject the multipolygon into multipoints, then making a density curve of those points across latitude, but that only makes points around the perimeter of the shape, not the inside. Maybe I can find the distance between multipoints at the same latitudes, then plot those distances as a pseudo-histogram?
I think maybe it will be easier if I convert to raster and count the number of cells in each latitudinal row? Any thoughts appreciated.
Code to get a small shapefile below to start with:
# try with the country of brazil
brazil <- rnaturalearth::ne_countries(continent = "South America",
returnclass = "sf") %>%
filter(name == "Brazil")
brazil %>%
ggplot() +
geom_sf() +
theme_minimal()
Desired output: density plot or histogram showing latitude on the Y-axis and area of the country on the x axis.
Thanks!

