-
Notifications
You must be signed in to change notification settings - Fork 33
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
crs handling in combine_list_of_sf #46
Comments
My thoughts,
Options:The two viable options I see are:
I favour the latter as you should never be allowed to combine features with different projection (the result will be meaningless), though I see the convenience of the former. pinging @edzer for thoughts on this one. |
Here is my issue with
versus
I feel like there has been discussion on |
r-spatial/sf#49 we could "fix" this with @etiennebr's proposal for an |
Given that we are a bit pressured for time, I think we should maybe pursue option one of my comment. This is pretty close to @etiennebr 's suggestion I guess. We can easily substitute with a version hosted in sf later. |
Given time constraints I propose we leave as is for now and await a sf solution. For internal use I think 4326 GeoJSON is appropriate for this release. |
Writing in a year after the last comment on this issue -- for starters, thanks for all the work on this package! I use it often. I found this issue a few months back and it solved a major headache for me. I've been unable to find an officially-supported solution to the basic problem of a bind_rows() style rbind-ing of a list of sf objects. All of the issues above look to be closed with references to an underlying issue with dplyr, roughly a year back. I now use mapedit's internal function for this a lot -- a quick search of my private repos this morning yielded >500 instances of calls to mapedit:::combine_list_of_sf() in lieu of a purrr::reduce(list_of_sf, sf:::rbind.sf) call. In case y'all think it's helpful, here or in related packages, here's my reasoning and a broad use-case where it's been helpful. I've moved to using mapedit's internal function over reduce/rbind.sf for speed reasons -- if I understand correctly, reduce/rbind.sf takes elements 1 and 2 to create an intermediate sf dataframe A; then dataframe A is rbind-ed to element 3 to create intermediate sf df B; and so on, such that there are (for N list elements) a total of N-1 intermediate list objects and therefore N-1 copy in memory operations. I see a noticeable speed drop on polygon dataframes over about 200 rows. The generic use-case -- I very frequently (>100 times/day?) need to split / map / combine sf objects, primarily for reasons of access speed. For instance: I have all 11 million US Census blocks from tigris, saved to disk by county, and need to readRDS or read_sf those files in arbitrary subsets. (For instance -- pick a focal county, find neighbors, load block geometries only for that subset of counties.) I would do something like list_of_county_files %>% map(read_sf) %>% mapedit:::combine_list_of_sf(), sometimes with intermediate operations. Thanks again! |
Is what you are proposing say a |
From my perspective, that would be great! After reading the issue history in The other feature from @edzer if you think it's worth considering this for Thanks much. |
@sheffe, I am so happy that you commented on the issue and have found the function helpful! I just used |
Yes, worth considering:
Happy to see an issue on sf, possibly followed by a PR. |
My comment / @edzer 's followup has been summarized over on (This isn't my issue to close and looks like some other discussion was open, so I'll just say thanks all for engaging on this!) |
@sheffe I agree that this is safe to close for |
Hello, library(sf) Thanks, |
Hi @ramkumardeo, this is not the right place to ask this question. Please consider stackoverflow or r-sig-geo mailing list instead. |
How should we handle CRS in
combine_list_of_sf()
(see lines)? Originally, I specifically chose4326
since I wrotecombine_list_of_sf
to deal withGeoJSON
from Leaflet.Draw events inedit*()
. However, I am not sure I am comfortable with this approach for a couple of reasons.rbind
for sf,combine_list_of_sf()
could be helpful elsewhere. If used elsewhere,combine_list_of_sf
cannot be so crude withcrs
.Options
I wanted to think through some options for dealing with this and discuss them in this issue. I have confirmed that even if edits made on a project leaflet map the edits are converted back to
4326
,crs
argument - seems like we should do this no matter what even if we decide to continue to default to 4326crs
from the list of features if all have the samecrs
crs
and let user decide what to do with the returned sf - I could see some merit in this also and this seems most consistent withsf
.The text was updated successfully, but these errors were encountered: