[R-sig-Geo] Reverse y-axis with geom_sf

Edzer Pebesma edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Tue Mar 19 15:13:37 CET 2019



On 3/19/19 2:55 PM, Kent Johnson wrote:
> Hi,
> 
> I am working with data representing cells in a tissue sample with lines and
> polygonal regions defined in the same space. The cells and polygons are
> represented and manipulated as simple features objects and visualized using
> ggplot2 and geom_sf. Mostly this works very well. The problem is that the
> coordinate system of my data has the origin at the top left corner. For
> data with no CRS, geom_sf puts the origin at the bottom left so all my
> plots are inverted.
> 
> Is there a way to invert the y axis while staying within sf (or possibly
> sp?) The only answers I have found involve extracting the coordinates from
> the sf objects and inverting or plotting from the raw data. Maybe by
> creating a CRS with the correct orientation?
> 
> For a very simple example with just a few vectors - the code below plots an
> arrow pointing down; I would like to invert the y-axis so it points up.
> library(sf)
> library(ggplot2)
> s1 <- rbind(c(9, 11), c(10, 10))
> s2 <- rbind(c(11, 11), c(10, 10))
> s3 <- rbind(c(10,14), c(10, 12), c(10,10))
> mls <- st_multilinestring(list(s1,s2,s3))
> 
> ggplot(mls) + geom_sf()

You mean, like

ggplot(mls * c(1, -1)) + geom_sf()

?

> 
> Thank you for any help,
> Kent Johnson
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2472 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190319/bd508983/attachment.bin>


More information about the R-sig-Geo mailing list