apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.79k stars 13.87k forks source link

Got error when use `deck.gl Scatterplot` with type `Delimited`. #19025

Open xyy94813 opened 2 years ago

xyy94813 commented 2 years ago

Got error when use deck.gl Scatterplot with type Delimited.

How to reproduce the bug

  1. create a new Chart
  2. Choose deck.gl Scatterplot
  3. Choose Delimited long & lat single column
  4. The column result is 110.1926929869672,30.737983766034915
  5. See error: Invalid spatial point encountered.
  6. Choose Reverse lat/long still got same error.

Expected results

Correct show Chart.

Actual results

Got Error:

Invalid spatial point encountered

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

(please complete the following information):

Checklist

Make sure to follow these steps before submitting your issue - thank you!

Additional context

When the type is "delimited", lngLat should be converted to latLng before "parse_coordinates". Otherwise an illegal lat or lng will cause an exception

https://github.com/apache/superset/blob/299b5dc64448d04abe6b35ee85fbd2b938c781bc/superset/viz.py#L2510-L2519

https://github.com/apache/superset/blob/299b5dc64448d04abe6b35ee85fbd2b938c781bc/superset/viz.py#L2542-L2551

https://geopy.readthedocs.io/en/stable/#geopy.point.Point

villebro commented 2 years ago

Thanks for reporting @xyy94813 . I agree we would need for the reversal to happen before or during parsing. On quick inspection it seems the best solution would be to open a PR on geopy to add an optional parameter to the Point constructor so the parser knows to default to latLng when no directional indicators are provided. This shouldn't be very difficult and would probably benefit the whole geopy community.

xyy94813 commented 2 years ago

A workaround before it fix.

DB Column is lngLat, ie 112,23

Add new Metric or Calculated Columns. (I still don't understand the difference between the two)

# SQL Expression
split_part(lngLat, ',', 1) # lng
split_part(lngLat, ',', 2) # lat

Then you can use the type Longitude & Latitude

xyy94813 commented 11 months ago

@yousoph Any progress?

yousoph commented 11 months ago

Hi @xyy94813 , are you testing on master? I'm seeing this working on master with data that looks like this: image

xyy94813 commented 11 months ago

@yousoph

The wrong test case is lng,lat column, ie -122.428577,37.7806267. And image

xyy94813 commented 11 months ago

https://github.com/geopy/geopy/discussions/565

yousoph commented 11 months ago

Ah, my bad, we're not currently working on it if you feel up to contributing a fix! 🙏

rusackas commented 6 months ago

If anyone reading this wants to review the linked PR, it would be appreciated! Also, I assume this is still present in 3.1/4.0 (the currently supported versions) but confirmation would be appreciated.