Skip to content

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

Open
Open

Description

@dmi3kno

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

Activity

  1. edzer commented on Oct 29, 2017

    @edzer
    Owner

    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.

  2. rsbivand commented on Jan 6, 2018

    @rsbivand
    Contributor

    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

  3. edzer commented on Jan 6, 2018

    @edzer
    Owner
    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.

  4. rsbivand commented on Jan 6, 2018

    @rsbivand
    Contributor

    Good, that is what I suspected.

  5. edzer commented on Jan 6, 2018

    @edzer
    Owner

    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.

  6. edzer commented on Jan 6, 2018

    @edzer
    Owner

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions