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

aw_area assumes geometry column is named "geometry" #14

Closed
dblodgett-usgs opened this issue Jan 7, 2019 · 3 comments
Closed

aw_area assumes geometry column is named "geometry" #14

dblodgett-usgs opened this issue Jan 7, 2019 · 3 comments

Comments

@dblodgett-usgs
Copy link
Contributor

@dblodgett-usgs dblodgett-usgs commented Jan 7, 2019

See here: https://github.com/slu-openGIS/areal/blob/master/R/aw_intersect.R#L103

The use of quosures is beyond my tidyverse skill or I'd PR a fix. You need to use sf::st_geometry() to operate on the geometry list column directly or lookup the name with attr(x, "sf_column").

b1 <- sf::st_polygon(list(rbind(c(-1, -1), c(1, -1),
                                c(1, 1), c(-1, 1),
                                c(-1, -1))))
b2 <- b1 + 2
b3 <- b1 + c(-0.2, 2)
b4 <- b1 + c(2.2, 0)
b <- sf::st_sfc(b1, b2, b3, b4)
a1 <- b1 * 0.8
a2 <- a1 + c(1, 2)
a3 <- a1 + c(-1, 2)
a <- sf::st_sfc(a1, a2, a3)

sf::st_crs(b) <- sf::st_crs(a) <- sf::st_crs(5070)

b <- sf::st_sf(geom = b, data.frame(idb = c(1, 2, 3, 4)))
a <- sf::st_sf(geom = a, data.frame(ida = c(1, 2, 3)))

sf::st_agr(a) <- sf::st_agr(b) <- "constant"

aw_intersect(a, b, "area")

attr(a, "sf_column") <- "geometry"
attr(b, "sf_column") <- "geometry"

names(a) <- c("ida", "geometry")
names(b) <- c("idb", "geometry")

aw_intersect(a, b, "area")
@dblodgett-usgs
Copy link
Contributor Author

@dblodgett-usgs dblodgett-usgs commented Jan 7, 2019

Side note, now that I have this handled over in intersectr I've found that areal works great and I use it directly as of: https://github.com/dblodgett-usgs/intersectr/pull/2.

I implemented a little cross-validation with an old java-based system that we use a lot. See the bottom here: https://dblodgett-usgs.github.io/intersectr/dev/articles/prism_demo.html for records of that cross validation.

@chris-prener
Copy link
Member

@chris-prener chris-prener commented Jan 8, 2019

This works great - I'm going to fix the "geometry" column bug next week - an oversight that just didn't occur to me since our columns are always named "geometery"!

Thanks for keeping me in the loop with this @dblodgett-usgs.

@chris-prener
Copy link
Member

@chris-prener chris-prener commented Jan 18, 2019

This is now fixed - thanks @dblodgett-usgs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.