Giter Club home page Giter Club logo

Comments (10)

stephhazlitt avatar stephhazlitt commented on September 7, 2024

Should this be the default behaviour (maybe w/o an argument, users can wrote code to re-project from bcalbers if needed)?

from bcmaps.

ateucher avatar ateucher commented on September 7, 2024

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.

bevingtona avatar bevingtona commented on September 7, 2024

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.

ateucher avatar ateucher commented on September 7, 2024

So would the actual warping then happen if you pulled it into R as a regular raster/stars object?

from bcmaps.

bevingtona avatar bevingtona commented on September 7, 2024
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.

bevingtona avatar bevingtona commented on September 7, 2024

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.

boshek avatar boshek commented on September 7, 2024

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.

ateucher avatar ateucher commented on September 7, 2024

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.

ateucher avatar ateucher commented on September 7, 2024

I.e., @bevingtona it looks like you've used nearest-neighbour, but I would have expected cubic or bilinear would make sense?

from bcmaps.

bevingtona avatar bevingtona commented on September 7, 2024

busted @ateucher ! yes, bilinear would be best.

from bcmaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.