-
Notifications
You must be signed in to change notification settings - Fork 299
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
st_transform +proj=wintri OGR error #509
Comments
Doesn't work for me either. Is it because of this?
|
Maybe, but inverse transformation shouldn't really be an issue here. Glad someone else can reproduce it though. |
|
Searching for "+proj=wintri gdal" gave a few hits suggesting this is a well-known problem, with gdal. |
... and in rgdal, we have a kludge by @barryrowlingson to permit checking for missing inverses too, so it's even harder to drop something heavy on your foot. |
Ok that explains it. Still, Winkel Tripel may have messy maths, but since Nat Geo uses it for world maps it's pretty common in the wild. I guess in an ideal world GDAL would support numerical inverses (? - the ESRI tools seem to have no problem with wintri, including inverse-using operations). In the meantime this is my +1 for the rgdal kludge to be applied here if possible. |
So the feature request here is to enable |
st_transform gains a parameter, use_gdal, which if FALSE takes a route through lwgeom_transform completely ignoreing GDAL. This allows using +over and +proj=wintri, proj.4 options not honoured/accepted by GDAL.
library(sf)
p1 = st_point(c(7,52))
geom.sf = st_sfc(p1, crs = 4326)
x <- st_transform(geom.sf, "+proj=wintri", use_gdal = FALSE) # Works! It should be noted that downstream problems may be expected, as we now created an object with a proj.4 string that GDAL does not accept, but if this is the end of the script, there should be no problem. Also, this only works if sf was built while linking against |
@econandrew can we close this issue? |
Just testing it - your point transformation works fine for me as does +over now, but wintri on library(ggplot2)
library(maps)
world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))
# This (pre-this-issue) doesn't work as it wraps the polygons, which then invert
world2 <- sf::st_transform(world1, crs = "+proj=cea +datum=WGS84 +no_defs +over")
ggplot() + geom_sf(data = world2)
# This does work, excellent!
world3 <- sf::st_transform(world1, crs = "+proj=cea +datum=WGS84 +no_defs +over", use_gdal = FALSE)
ggplot() + geom_sf(data = world3)
# This still fails for me
world4 <- sf::st_transform(world1, crs = "+proj=wintri +datum=WGS84 +no_defs +over", use_gdal = FALSE)
ggplot() + geom_sf(data = world4)
#> OGR: Corrupt data
#> Error in CPL_crs_equivalent(e1$proj4string, e2$proj4string): OGR error |
That is a downstream problem I predicted: the graticule asked for by I think we found a clear limitation of sf here, compared to sp/rgdal. |
Ah, I see, that makes some sense. Knowing that as the cause, and borrowing from your own answer to tidyverse/ggplot2#2071, the following does work: library(ggplot2)
library(maps)
world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))
world4 <- sf::st_transform(world1, crs = "+proj=wintri +datum=WGS84 +no_defs +over", use_gdal = FALSE)
ggplot() + geom_sf(data = world4) + theme_minimal() + coord_sf(datum = NA) +
theme(
panel.grid = element_blank(),
line = element_blank(),
rect = element_blank(),
text = element_blank()) I think there's possibly still some work to be done on the ggplot side to make some of this smoother (e.g. could |
Cool! Here is the version with a manual graticule: library(ggplot2)
library(maps)
world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))
world4 <- sf::st_transform(world1, crs = "+proj=wintri +datum=WGS84 +no_defs +over", use_gdal = FALSE)
gr = sf::st_graticule(lat = c(-89.9,seq(-80,80,20),89.9))
gr <- sf::st_transform(gr, crs = "+proj=wintri +datum=WGS84 +no_defs +over", use_gdal = FALSE)
ggplot() + geom_sf(data = gr, color = 'grey') + geom_sf(data = world4) + theme_minimal() +
coord_sf(datum = NA) +
theme(
panel.grid = element_blank(),
line = element_blank(),
rect = element_blank(),
text = element_blank()) |
As per future sf > 0.5-5, |
@edzer any idea for how to label these graticules (i.e. lat/lons)? I re-ran (with small edits) your code, and attempted to add labels using the scale_y_continuous() function as per #2857 but nothing happens. (FYI I've switched to Robinsons for simplicity). Also tried coord_sf(label_graticule="NE") to no avail.
|
(Good chance this is from screwed up libraries, but I can't find any positive examples that this does work elsewhere so posting anyway.)
Example:
Output (homebrew, OS X El Cap):
Any ideas?
The text was updated successfully, but these errors were encountered: