Skip to content

Reversing bounding box projection results in different extents #1481

@natemiller

Description

@natemiller

I'm trying to understand why if I project a bounding box into a new CRS and then use the resulting extents (xmin, ymin, xmax, ymax) to regenerate a bounding box and transform back to the original CRS the resulting extents (x-coordinates) are different than what I started with?

# transform bounding box defined in ESPG:4326 to Equal Earth

bb_ee = sf::st_bbox(c(xmin = -20, xmax = 30, 
                      ymin = 30, ymax = 65),  
                 crs = 4326) %>%
  sf::st_as_sfc() %>%
  sf::st_transform(crs = "+proj=eqearth +datum=WGS84 +wktext") %>%
  sf::st_bbox()

# Using extent of Equal Earth bounding box, transform back to EPSG:4326

bb_4326 = sf::st_bbox(c(xmin = bb_ee[['xmin']], xmax = bb_ee[['xmax']], 
                        ymin = bb_ee[['ymin']], ymax = bb_ee[['ymax']]),  
                 crs = "+proj=eqearth +datum=WGS84 +wktext") %>%
  sf::st_as_sfc() %>%
  sf::st_transform(crs = 4326) %>%
  sf::st_bbox()


# input is
#   xmin      ymin      xmax      ymax 
#   -20       30        30        65 

bb_4326

# result is  
#   xmin         ymin           xmax          ymax 
# -26.12724  30.00000  39.19085  65.00000

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