r-raster-vector-geospatial icon indicating copy to clipboard operation
r-raster-vector-geospatial copied to clipboard

coordinate system mismatch in aoi bounding box

Open evebohnett opened this issue 6 years ago • 2 comments

Lesson 6: Open and Plot Shapefiles in R

In this lesson, there is a emphasis on understanding what the coordinate system is for the data, and looking for the UTM CRS info for the blue bounding box.

Then after the plot renders we can see that the plot is projected in lat long, so there's a mismatch somewhere. Either the ggplot doesn't understand it's in UTM or it's projecting on the fly into lat long. I'm not sure what the intention was here. If this is part of the sf functionality then maybe there can be a line added explaining that.

evebohnett avatar May 08 '19 14:05 evebohnett

Thanks for the report! I can see what you mean. One option I see would be to show people how to plot the UTM coordinate labels (use the datum flag in coord_sf) but I rarely see this done in practice...

ggplot() + 
  geom_sf(data = aoi_boundary_HARV, size = 3, color = "black", fill = "cyan1") + 
  ggtitle("AOI Boundary Plot") + 
  coord_sf(datum = sf::st_crs(aoi_boundary_HARV))

jsta avatar May 08 '19 15:05 jsta

Great point about this lesson!

Digging a bit it seems like this is a known issue (https://github.com/tidyverse/ggplot2/issues/2200#issuecomment-315377512) and the workaround (datum=NULL) is given in the help for sf::st_graticule . It doesn't seem like the docs for ggplot2::coord_sf really reflect this change as of ggplot2_3.2.0

ashander avatar Aug 18 '19 12:08 ashander