Closed MarisaBSzubryt closed 7 months ago
Hi @MarisaBSzubryt, thanks for bringing this up. Based on that error message, yeah it looks like ret_index
in the coord_to_fips.numeric
method has a list
column that is causing the error when order
is called on it. This is most likely an issue with my internal ray casting algorithm... it's not super well-written haha.
I'm currently working on a rewrite of the internal fipio
components to support more FIPS information (i.e. tracts, ZCTAs, etc.) so that might delay a fix, but I will try to get something out soon.
For (my) reference, the relevant source code causing the issue is here:
My initial, rough guess is that one of these two variables is causing the issue:
Hi Justin,
Thanks for getting back to me; I really appreciate your help with this and the R package you've created! Do you know when the updates might be published? No rush on my end or anything, was just curious if you had an estimated time when it'll be revised. I believe that I sent the dataset which does work (along with the one that doesn't) - let me know if it would be helpful for me to re-send either/both if you need some test data.
Have a nice weekend! Marisa
On Mon, Jan 15, 2024 at 2:44 PM Justin Singh-M. - NOAA < @.***> wrote:
Hi @MarisaBSzubryt https://github.com/MarisaBSzubryt, thanks for bringing this up. Based on that error message, yeah it looks like ret_index in the coord_to_fips.numeric method has a list column that is causing the error when order is called on it. This is most likely an issue with my internal ray casting algorithm... it's not super well-written haha.
I'm currently working on a rewrite of the internal fipio components to support more FIPS information (i.e. tracts, ZCTAs, etc.) so that might delay a fix, but I will try to get something out soon.
For (my) reference, the relevant source code causing the issue is here:
— Reply to this email directly, view it on GitHub https://github.com/program--/fipio/issues/15#issuecomment-1892745466, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFLT2IXUIZVUURCI3NOM3ZTYOWIJPAVCNFSM6AAAAABB3X53Z6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJSG42DKNBWGY . You are receiving this because you were mentioned.Message ID: @.***>
Hi @MarisaBSzubryt, I'm going to put out a patch for this, since I think I've figured it out. Just need to do a bit more logic work -- I'd say expect a new version up on CRAN by Wednesday at the latest.
The reason for the error is that in fipio::coords_to_fips.numeric
, the general idea is to:
x
/y
are within the bounding box of each county geometrylist
of length(lookup_geometry)
with indices to x
/y
that associate a FIPS to the coordinate, where some may be NA
)Step (3) leaves us with two variables, ret_value
and ret_index
-- ret_value
is a character(length(lookup_geometry))
with FIPS codes; ret_index
is a list
with the indices as mentioned, i.e.
r$> ret_value
[1] "04003" "04019" "04023" "35013" "35029" "48141" "48243" "48377"
r$> ret_index
[[1]]
[1] 7 9 12 13 15
[[2]]
[1] 10
[[3]]
[1] 8
[[4]]
[1] 16
[[5]]
[1] 14
[[6]]
[1] 11
[[7]]
[1] 2 3 4 5 6
[[8]]
[1] 1
I'm not sure exactly what changed, but I'm going to guess some R version modified behavior somewhere that caused either .intersects
(an internal function for fipio) or sapply
to result a list in this case. (or more likely, I wrote some code that shouldn't have been written how it was haha).
Regardless, I think I have a fix. I'll also comment once it's up on GitHub so you can install it before it's on CRAN if needed.
@MarisaBSzubryt I was able to get the change pushed and up to CRAN today actually. fipio v1.1.2 should be up on CRAN now so the issue should be fixed now. Let me know if it's good to close this issue, thanks!
Justin, thank you so much! The program works perfectly now. The fipio command works like a charm now
@MarisaBSzubryt Glad to hear, and no problem! Thanks again for bringing up the issue. If any other issues come up, feel free to let me know. 😃
Hello,
I have been having some difficulty getting the fipio package to work properly for some (but not all of my datasets). I'm trying to take a CSV of coordinates (latitude, longitude) into five-number FIPS codes. I then would split those five number codes into the first two numbers for the state and last three numbers for the county/parish, then converting them to state/county names for automatic county-level map production. In some of the datasets I use, I get this error when running the following code:
It only happens for some CSV files or dataframes, and it doesn't seem to be a case of illegal characters in the coordinates. If I enter in the coordinates manually, it seems fine with that (usually), but bringing in a CSV downloaded from somewhere else usually (but not always) causes this error to pop up. I've spoken with one of my professors who's very familiar with R, and he couldn't figure out what's going on. The latitude and longitude are converted to vectors or numeric format prior to running this line of code (see below), so I think that sometime during the fipio::coord_to_fips() function, something is converted to a list (and should be converted back to a vector but isn't always the case). Why it only happens sometimes I'm not sure, and I wasn't sure where else to ask this sort of question.
Any thoughts on how to alleviate the issue would be greatly appreciated! Files (one works, one doesn't work) are below, along with the rest of the code, Marisa
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
coordinates.csv example_coordinates_simple.csv
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .