uber / uber/h3-java

h3 index converted to Geocoordinates: how to export to geojson

Open
#66 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
333
Forks
68
PR merge metrics
No merged PRs in 30d

Description

Hi,
I had 2 quesions related to using h3ToGeoBoundary:
Question 1:
I am doing some preprocessing in spark using h3, and I want to save my results into a format that can easily be exported. My goal is to load the data in geomesa/geoserver. I notice that using h3ToGeoBoundary I get results that are a list of GeoCoord like this:
[GeoCoord{lat=50.346809, lng=14.153511}, GeoCoord{lat=50.316251, lng=14.138129}, GeoCoord{lat=50.294416, lng=14.173950}, GeoCoord{lat=50.303130, lng=14.225160}, GeoCoord{lat=50.333686, lng=14.240581}, GeoCoord{lat=50.355530, lng=14.204753}]
I assume this is the google coordinate type: https://pub.dev/documentation/google_directions_api/latest/google_directions_api/GeoCoord-class.html.
But is this compatible with geospark/geomesa?

It would be very helpful, if there was an option to save this as let's say geojson like there is for h3-js (https://github.com/uber/h3-js#module_h3.h3ToGeoBoundary where a boolean decides how it is saved).
Is there an example somewhere, if I have let's say 10k h3 indexes how to save it into a format that other geospatial tools (geomesa or geospark ) can read?

Question2:
Also when I want to apply a udf to a full column with h3 indexes, this works:
//works
val h3ToGeoBoundary = udf{ (h3Index: Long) =>
H3.instance.h3ToGeoBoundary(h3Index).toString()
}
but this does not:
//does not work
val h3ToGeoBoundaryGeoJson = udf{ (h3Index: Long) =>
H3.instance.h3ToGeoBoundary(h3Index)
}
//error:java.lang.UnsupportedOperationException: Schema for type java.util.List[com.uber.h3core.util.GeoCoord] is not supported
This means that if I want to create a dataframe with couple 1000 rows, I can only have that in string format, which does not allow me to do transformations on it (like selecting each element of the list, and using those coordinates to turn it myself into geojson).
Any clue how to solve this?

Thanks!
PS: great job-very user friendly and cool library.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the H3.instance.h3ToGeoBoundary entry point and the two Spark UDF examples in the issue, including the UnsupportedOperationException for List. Determine the intended representation for GeoJSON, GeoMesa, or GeoSpark and define completion as a supported, documented way to process many indexes without converting boundaries only to strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.