GoogleCloudPlatform / bigquery-geo-viz

Visualize Google BigQuery geospatial data using Google Maps Platform APIs
https://bigquerygeoviz.appspot.com/
Apache License 2.0
112 stars 41 forks source link

Visualization going Red on Zoom #54

Open nyjr10025 opened 2 years ago

nyjr10025 commented 2 years ago

Running into an issue where the screen is going red when zooming into the map. No styles have been applied. Has happened consistently with multiple data sets

image
nickkieffer commented 1 year ago

Makes geo viz nearly unusable for me

mentin commented 1 year ago

Could you share any of the datasets that cause such result?

One hypothesis, judging by the fact that red starts at antimeridian in the image above - there are some inverted polygons in the dataset. Converted to GeoJson used by GeoViz they are represented by +-180/+-90 box, with the polygon you do want to show as a hole. I could not reproduce this with the polygons I've tried though. So having a dataset to repro would be helpful.

nickkieffer commented 1 year ago

Yep here ya go bquxjob_7d574d42_18b67e06b84.json

mentin commented 1 year ago

Thanks!

For some reasons I don't understand, I don't get that kind of fill in GeoViz. But I can confirm the polygons are inverted (if they are supposed to describe small blocks in Virginia):

select 
  st_area(st_geogfromtext(geom, oriented=>TRUE)) area, 
  st_area(st_geogfromtext(geom)) area2,
  geom
from  tmp.gvbug

Results I get:

Row | area | area2 | geom |  
-- | -- | -- | -- | --
1 | 510066073116955.81 | 1032.7522888034407 | POLYGON((-79.9924959415828 37.7939704994434, -79.9923042878136 37.7941072727986, -79.9919581354936 37.7938100261923, -79.9921564035582 37.793670066394, -79.9924959415828 37.7939704994434)) |  
2 | 510066073117479.56 | 508.98898554590954 | POLYGON((-79.9921195896996 37.794239082534, -79.992024820132 37.7943067140553, -79.9916787100328 37.7940072747658, -79.9917752115521 37.7939391538722, -79.9921195896996 37.794239082534)) |  
3 | 510066073117735.62 | 252.93059403002817 | POLYGON((-79.9919262704538 37.7943770429917, -79.9915845989301 37.794073722444, -79.9915913848041 37.7940689180758, -79.9916303878571 37.7940413852345, -79.9919753481127 37.7943420190847, -79.9919262704538 37.7943770429917)) |  
4 | 510066073117728.12 | 260.51798355690715 | POLYGON((-79.9919753481127 37.7943420190847, -79.9916303878571 37.7940413852345, -79.9916787100328 37.7940072747658, -79.992024820132 37.7943067140553, -79.9919753481127 37.7943420190847)) |  
5 |  510066073116963.5 |   1025.10061000995 | POLYGON((-79.9924959415828 37.7939704994434, -79.9921564035582 37.793670066394, -79.9923494443263 37.7935337962376, -79.9926909882889 37.7938313030569, -79.9924959415828 37.7939704994434))

The area of the polygons is almost whole globe - so the red fill of the whole globe is correct. I wonder why it does not happen in my browser - this might be an actual bug.

I suggest fixing the polygons - you are likely getting invalid analysis results any way. When loading the geospatial data BigQuery uses oriented semantics. ST_GeogFromText uses unoriented semantics (smaller of two interpretations) by default. Another option is to subtract (ST_Difference) already loaded geography from the whole globe (ST_GeogFromText('fullglobe')).

nickkieffer commented 1 year ago

Hmm thank you for taking a look and letting me know about my geometries! Extra weird is that the correct polygons look to be where they should be but I just can't zoom to them because of this other backwards polygon coming in at just after this zoom level

image image
nickkieffer commented 1 year ago

They show in the data view as all wonky too I guess, should've noticed that 😬

nickkieffer commented 1 year ago

FWIW inverting my geometries fixed the issue I was seeing. Sorry for the sass and thanks for the help!