Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRS("+axis=wsu") support #42

Open
dmi3kno opened this issue Oct 29, 2017 · 6 comments
Open

CRS("+axis=wsu") support #42

dmi3kno opened this issue Oct 29, 2017 · 6 comments

Comments

@dmi3kno
Copy link

dmi3kno commented Oct 29, 2017

Following this, axis orientation was first introduced into proj4 in 2010 and became part of standard in 2012 (listed now among common parameters

However, when I try to "turn my world upside down" I get the error. Does it follow that the proj4 version used by CRS() does not (yet?) support +axis param?

> data("wrld_simpl", package = "maptools")
> spTransform(wrld_simpl, "+proj=latlong +axis=wsd")
Error in CRS(CRSobj) : 
  northings must follow eastings: +proj=latlong +axis=wsd
@edzer
Copy link
Owner

edzer commented Oct 29, 2017

No, this is a case that is not allowed by sp, and caught before passing stuff on to proj.4. Pkg sf allows it:

library(sf)
s  = st_as_sf(wrld_simpl)
s2 = st_transform(s, "+proj=latlong +axis=wsd")
plot(s2)

but doesn't seem to do much.

@rsbivand
Copy link
Contributor

rsbivand commented Jan 6, 2018

Re: email from Nick Tate 5/1-18

Using that example, I see:

library(rgdal)
data("wrld_simpl", package = "maptools")
t0 <- spTransform(wrld_simpl, CRS("+proj=cea +lat_ts=37.5 +ellps=WGS84 +datum=WGS84 +units=m +axis=wsu +no_defs +towgs84=0,0,0"))
plot(t0)

which is upside-down - is that what you wanted? This doesn't work for sf:

library(sf)
s  = st_as_sf(wrld_simpl)
s2 = st_transform(s, "+proj=cea +lat_ts=37.5 +ellps=WGS84 +datum=WGS84 +units=m +axis=wsu +no_defs +towgs84=0,0,0")
plot(st_geometry(s2))

which is not upside-down, and reverses the signs on the bounding box y-axis

> st_bbox(s2)
     xmin      ymin      xmax      ymax 
-15916580  -8011546  15916580   7960704 
> bbox(t0)
        min      max
x -15916580 15916580
y  -7960704  8011546

I tried using the with_geos argument FALSE in st_transform, but I think the outcome was the same - unsure because I had an older lwgeom attached.

I'm copying this into the GitHub issue.

Email:

Quick question: I’m playing around with various projection transformations via sf (st_transform) and ggplot.
I notice that it is possible in PROJ.4 to influence axis orientation see http://proj4.org/parameters.html#axis-orientation via the +axis parameter.
But I am unsure whether I can effect this in R.

The proj4 definition below is for the standard Hobo Dyer (from tmap definitions)
crs <- "+proj=cea +lat_ts=37.5 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0"

P.S. it seems some comment on this has appeared.
#42
Though as Edzer notes, it doesn’t seem to do much...

I suspect what I want is to replace the default +axis=enu with +axis=wsu

@edzer
Copy link
Owner

edzer commented Jan 6, 2018

s3 = lwgeom::st_transform_proj(s, "+proj=cea +lat_ts=37.5 +ellps=WGS84 +datum=WGS84 +units=m +axis=wsu +no_defs +towgs84=0,0,0")
plot(st_geometry(s3))

does plot the world upside down; sf::st_transform takes the GDAL path to transformations, and it seems that that silently ignores the +axis=wsu.

@rsbivand
Copy link
Contributor

rsbivand commented Jan 6, 2018

Good, that is what I suspected.

@edzer
Copy link
Owner

edzer commented Jan 6, 2018

With upside down, do you imply only y is affected? In any case, they are both; +axis=esu only affects y. In the bounding box example above, xmin equals -xmax, so you cannot see the swap.

@edzer
Copy link
Owner

edzer commented Jan 6, 2018

Interestingly, following this suggestion,

s2 = st_transform(s, "+proj=cea +lat_ts=37.5 +ellps=WGS84 +datum=WGS84 +units=m +axis=wsu +no_defs +towgs84=0,0,0 +wktext")
plot(st_geometry(s2))

does work as intended.

edzer added a commit to r-spatial/sf that referenced this issue Jan 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants