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

Creating a new raster based on an sf vector fails when PROJ >=6 #101

Closed
Nowosad opened this issue Mar 21, 2020 · 2 comments
Closed

Creating a new raster based on an sf vector fails when PROJ >=6 #101

Nowosad opened this issue Mar 21, 2020 · 2 comments

Comments

@Nowosad
Copy link
Contributor

Nowosad commented Mar 21, 2020

Creating a new raster based on an sf vector fails when PROJ >=6. Below you can see two examples, one on a computer with PROJ5.2.0 and one with PROJ7.0.0. This issue is related to #78.

Proj < 6

library(spData)
library(raster)
#> Loading required package: sp
library(sf)
#> Linking to GEOS 3.7.1, GDAL 2.3.2, PROJ 5.2.0
world = read_sf(system.file("shapes/world.gpkg", package = "spData"))
world_raster = raster(world, resolution = 10)
world_raster
#> class      : RasterLayer 
#> dimensions : 17, 36, 612  (nrow, ncol, ncell)
#> resolution : 10, 10  (x, y)
#> extent     : -180, 180, -86.35487, 83.64513  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0

Created on 2020-03-21 by the reprex package (v0.3.0)

Proj >= 6

library(spData)
library(raster)
#> Loading required package: sp
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 7.0.0
world = read_sf(system.file("shapes/world.gpkg", package = "spData"))
world_raster = raster(world, resolution = 10)
#> Error in if (!is.na(projargs) && !nzchar(projargs)) projargs <- NA_character_ : 
#>   missing value where TRUE/FALSE needed

Created on 2020-03-21 by the reprex package (v0.3.0)

@rhijmans
Copy link
Member

rhijmans commented Apr 21, 2020

I do not see this with raster 3.1-5 (CRAN) or 3.1-6 (github) with PROJ 7

library(sf)
#Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 7.0.0
world = read_sf(system.file("shapes/world.gpkg", package = "spData"))
world_raster = raster(world, resolution = 10)
packageVersion("sf")
#[1] ‘0.9.2’

Does it also work for you?

@Nowosad
Copy link
Contributor Author

Nowosad commented Apr 21, 2020

Yes, it works now. Thank you

@Nowosad Nowosad closed this as completed Apr 21, 2020
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

2 participants