Skip to content

Add crs argument? #51

Description

@Robinlovelace

General gist of what I'm after, and would make my life easier, shown below:

library(sfheaders)
x <- matrix( c(1:4), ncol = 2 )
xsfc <- sfc_linestring( x )
sf::st_crs(xsfc)
#> Coordinate Reference System: NA
xsfc <- sfc_linestring( x , crs = 4326)
#> Error in sfc_linestring(x, crs = 4326): unused argument (crs = 4326)
attributes(xsfc)
#> $n_empty
#> [1] 0
#> 
#> $crs
#> Coordinate Reference System: NA
#> 
#> $class
#> [1] "sfc_LINESTRING" "sfc"           
#> 
#> $precision
#> [1] 0
#> 
#> $bbox
#> xmin ymin xmax ymax 
#>    1    3    2    4 
#> 
#> $z_range
#> zmin zmax 
#>   NA   NA 
#> 
#> $m_range
#> mmin mmax 
#>   NA   NA
attr(xsfc, which = "crs") = 4326
sf::st_crs(xsfc)
#> [1] 4326

xsfc2 <- sf::st_sfc(sf::st_linestring(x), crs = 4326)
sf::st_crs(xsfc2)
#> Coordinate Reference System:
#>   EPSG: 4326 
#>   proj4string: "+proj=longlat +datum=WGS84 +no_defs"

Created on 2020-02-08 by the reprex package (v0.3.0)

FYI I'm rewriting stplanr::od2line() in a new package and think using sfheaders, among other changes, can make it 10+ or in some cases ~100+ times faster!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions