This is a self-contained Java library able to do country localization based on geohashes.
The project puts together discretized borders in a trie data structure.
compile 'io.github.adrianulbona:cloc:0.3.2'
<dependency>
<groupId>io.github.adrianulbona</groupId>
<artifactId>cloc</artifactId>
<version>0.3.2</version>
</dependency>
final CountryLocator countryLocator = CountryLocator.create();
final List<String> countries = countryLocator.locate("u10hb1"); // ["United Kingdom"]
val locator = spark.sparkContext.broadcast(CountryLocator.create())
val locate = udf { (geohash: String) => locator.value.locate(geohash).asScala }
val pointsDF: DataFrame = Seq(
Point("u10hb1", 51.47, 0.00),
Point("u33ff3", 52.52, 13.81)).toDF
pointsDF.withColumn("countries", locate($"geohash"))
.show()
// +-------+-----+-----+----------------+
// |geohash| lat| lon| countries|
// +-------+-----+-----+----------------+
// | u10hb1|51.47| 0.0|[United Kingdom]|
// | u33ff3|52.52|13.81| [Germany]|
// +-------+-----+-----+----------------+