- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 11:53 AM
I continues to receive a parsing error when attempting to convert lat/long data to a geohash in data bricks . I've tried two coding methods in R and get the same error.
library(geohashTools)
Method #1
my_tbl$geo_hash <- gh_encode(my_tbl$Latitude, my_tbl$Longitude, precision = 9L)
Method #2
my_tbl <- my_tbl %>%
mutate(geo_hash = gh_encode(Latitude, Longitude, precision = 9L))
Any suggestions?
Jeff
- Labels:
-
Convert
-
databricks
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 07:05 AM
The problem was I was trying to run the gh_encode function on a Spark dataframe. I needed to collect the date into a R dataframe then run the function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 02:50 AM
Please install required library in cluster settings tab -> libraries, than install new and install it from CRAN. I tested and after that geoHashTools worked without problem (second screenshot)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 06:07 AM
Whmmmmm. I ran installed.packages() from the command line and its shows the geohashTools package libpath as "/databricks/spark/R/lib" (version 0.3.1) so I am assuming I've got it loaded. So then I ran the following test:
%r
lat <- c(24.123, 45.123)
long <- c(145.123, 130.124)
test <- gh_encode(lat, long, precision = 9L)
test
[1] "xhrlnr7qd" "ybh89n3ks"
So the command works but the following code
# add geohash
my_tbl <- my_tbl %>%
mutate(geo_hash = gh_encode(Latitude, Longitude, precision = 9L)
results in the following error message:
Error in Use("escape") : Error in UseMethod("escape") :
no application method for 'escape' applied to an object of class "c('my_tbl', 'tbl_lazy', 'tbl')"
I'm to new to databricks to have any clue what the error is trying to tell me.
Any other suggestions?
----------------------
I just couldn't get the R gh_encode function to work on the Spark df so I ran the collect() function and then re-ran the mutate and gh_encode functions on the R data.frame and converted back to a Spark dataframe. That appears to have worked. However not the optimal solution (need to work in the Spark dataframe) but worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 07:05 AM
The problem was I was trying to run the gh_encode function on a Spark dataframe. I needed to collect the date into a R dataframe then run the function.

