bvarick / route_analysis

GNU General Public License v3.0
0 stars 1 forks source link

Error on Line 171 #13

Closed syounkin closed 2 weeks ago

syounkin commented 2 weeks ago

https://github.com/bvarick/route_analysis/blob/338e608d926eef669b21811801b752c803aa642e/cycling_route_analysis_brouter.Rmd#L171

> bike_lts_buffer <- st_buffer(st_intersection(bike_lts, cycle_boundary_poly), 20)
Warning message:
attribute variables are assumed to be spatially constant throughout all geometries 
> bike_lts_buffer["student_use"] <- unlist(lapply(st_intersects(bike_lts_buffer, routes), length))
Error in st_geos_binop("intersects", x, y, sparse = sparse, prepared = prepared,  : 
  st_crs(x) == st_crs(y) is not TRUE
bvarick commented 2 weeks ago

I'm not getting that error. And when I check the CRS for those two layers (bike_lts_buffer and routes) they seem the same:

> st_crs(routes)
Coordinate Reference System:
  User input: WGS 84 
  wkt:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
> st_crs(bike_lts_buffer)
Coordinate Reference System:
  User input: WGS 84 
  wkt:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
> st_crs(routes)==st_crs(bike_lts_buffer)
[1] TRUE
bvarick commented 2 weeks ago

I just made a couple of changes that set the crs explicitly for each data import. Let me know if that fixes the error for you.

syounkin commented 2 weeks ago

Working now. Not sure how it was resolved.