Comments (10)
Should this be the default behaviour (maybe w/o an argument, users can wrote code to re-project from bcalbers if needed)?
from bcmaps.
We considered this, but decided that it was very computationally expensive and so left it up to the user
library(bcdata)
#>
#> Attaching package: 'bcdata'
#> The following object is masked from 'package:stats':
#>
#> filter
library(bcmaps)
library(raster)
ws <- bcdc_query_geodata("51f20b1a-ab75-42de-809d-bf415a0f9c62") %>%
filter( WATERSHED_GROUP_CODE == "PARS") %>%
collect() %>% st_as_sf()
dem.ws <- cded_raster(aoi = ws)
#> checking your existing tiles for mapsheet 93i are up to date
#> checking your existing tiles for mapsheet 93o are up to date
#> checking your existing tiles for mapsheet 93j are up to date
#> checking your existing tiles for mapsheet 93p are up to date
system.time(
newdem.ws <- projectRaster(dem.ws, crs = 3005)
)
#> user system elapsed
#> 77.458 84.469 262.218
Created on 2021-02-18 by the reprex package (v1.0.0)
from bcmaps.
It would be super fast if you don't touch the tif files, and just warp the vrt in the cded functions.
sf::gdal_utils(
util = "warp",
source = "out.vrt",
destination = "out3005.vrt",
options = c("-t_srs", "EPSG:3005",
"-r", "near",
"-of", "VRT"))
from bcmaps.
So would the actual warping then happen if you pulled it into R as a regular raster/stars object?
from bcmaps.
library(bcdata)
#> Warning: package 'bcdata' was built under R version 4.0.3
#>
#> Attaching package: 'bcdata'
#> The following object is masked from 'package:stats':
#>
#> filter
library(bcmaps)
#> Warning: package 'bcmaps' was built under R version 4.0.3
#> Loading required package: sf
#> Warning: package 'sf' was built under R version 4.0.3
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(raster)
#> Warning: package 'raster' was built under R version 4.0.3
#> Loading required package: sp
#> Warning: package 'sp' was built under R version 4.0.3
#>
#> Attaching package: 'raster'
#> The following object is masked from 'package:bcdata':
#>
#> select
ws <- bcdc_query_geodata("51f20b1a-ab75-42de-809d-bf415a0f9c62") %>%
filter( WATERSHED_GROUP_CODE == "PARS") %>%
collect() %>% st_as_sf()
#> Note: method with signature 'DBIConnection#character' chosen for function 'dbQuoteIdentifier',
#> target signature 'wfsConnection#ident'.
#> "wfsConnection#ANY" would also be valid
#> Note: method with signature 'DBIConnection#character' chosen for function 'dbQuoteIdentifier',
#> target signature 'wfsConnection#character'.
#> "wfsConnection#ANY" would also be valid
#> Note: method with signature 'DBIConnection#character' chosen for function 'dbQuoteString',
#> target signature 'wfsConnection#character'.
#> "wfsConnection#ANY" would also be valid
dem.ws <- cded_raster(aoi = ws, dest_vrt = "temp.vrt")
#> checking your existing tiles for mapsheet 93i are up to date
#> checking your existing tiles for mapsheet 93o are up to date
#> checking your existing tiles for mapsheet 93j are up to date
#> checking your existing tiles for mapsheet 93p are up to date
sf::gdal_utils(
util = "warp",
source = "temp.vrt",
destination = "out3005.vrt",
options = c("-t_srs", "EPSG:3005",
"-r", "near",
"-of", "VRT"))
raster::raster("out3005.vrt") %>% st_crs() == st_crs(ws)
#> [1] TRUE
Created on 2021-02-18 by the reprex package (v0.3.0)
from bcmaps.
This is a work arround, but pretty sure this would be easy to add into the cded functions... so it is only the VRT that is being warped
from bcmaps.
One thing to consider is that it would be a breaking change. One other option would be to leverage transform_bc_albers
and provide stars and raster methods for that function. Then this would just work:
cded_stars(aoi) %>%
transform_bc_albers()
from bcmaps.
I guess the other question is the choice of interpolation method... is there one that's best for dem data? Is the best choice different for different scenarios?
from bcmaps.
I.e., @bevingtona it looks like you've used nearest-neighbour, but I would have expected cubic or bilinear would make sense?
from bcmaps.
busted @ateucher ! yes, bilinear would be best.
from bcmaps.
Related Issues (20)
- Release bcmaps 1.1.0
- Drop raster and switch to using terra HOT 2
- Change `master` to `main` HOT 1
- Release bcmaps 1.2.0
- Drop sp support HOT 3
- Improve documentation for bc_bound() vs. bc_bound_hres() HOT 1
- Add citation to README? HOT 1
- Update add_points vignette with a ggplot2 example HOT 1
- Improvements to pkgdown site
- Missing part of map in airzone() HOT 19
- Hide uninformative plot captions in vignettes HOT 6
- Release bcmaps 2.0.0 HOT 3
- Ensure cded functions play well with terra
- Release bcmaps 2.1.0
- cded_raster deprication lifecycle message doesn't print properly HOT 4
- Release bcmaps 2.2.0
- `utm_convert()` drops tbl class
- utm_zone_lookup not found HOT 2
- function request: transform bc albers to long lat HOT 2
- utm_convert function overwrites original utms - something going on with dimensions/rows? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bcmaps.