deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Bug] 2D object is smaller than 3D on the map

Open yaras-phoenix opened this issue 1 year ago • 10 comments

Description

  1. Created a square polygon in QGIS with a side = 2000.256 m. image
  2. Created a GLB-model using Blender with the same size and 1m high. image
  3. I expected the size to be at least almost equal but given the 1m height the difference seems to be much bigger. image

Flavors

  • [ ] Script tag
  • [ ] React
  • [ ] Python/Jupyter notebook
  • [ ] MapboxOverlay
  • [ ] GoogleMapsOverlay
  • [ ] CartoLayer
  • [ ] ArcGIS

Expected Behavior

No response

Steps to Reproduce

Using codepens from deck.gl GeoJSON layer and Scenegraph layer docs made my own here. Links to sample objects (JSON and GLB) are attached in the code.

Environment

  • Framework version: taken from the codepen
  • Browser: Google Chrome 128.0
  • OS: Win10 x64

Logs

No response

yaras-phoenix avatar Sep 19 '24 10:09 yaras-phoenix

Does it work if in QGIS you use Cartesian instead of Ellipsoidal?

felixpalmer avatar Sep 20 '24 07:09 felixpalmer

Does it work if in QGIS you use Cartesian instead of Ellipsoidal?

I work in EPSG:3857 Pseudo-Mercator so cartesian gives me irrelevant 3385 meters. If I change QGIS CRS to, let's say, WGS_1984_Complex_UTM_Zone_30N (ESRI:102580), Cartesian measurement on this object gives 2000.00 meters.

Anyway, it is nowhere near the difference mentioned above.

yaras-phoenix avatar Sep 24 '24 07:09 yaras-phoenix

By the way, using Turf.js I measured distance between [ -5.280356221393128, 53.86928337707964 ] and [ -5.249963734890388, 53.869857228664557 ] and got ~1993.65 meters. This seems like something very close to what I see. Can this be any helpful?

yaras-phoenix avatar Sep 24 '24 14:09 yaras-phoenix

using Turf.js I measured distance between and got ~1993.65 meters.

Yes, I believe that is the difference you see.

Pessimistress avatar Sep 24 '24 15:09 Pessimistress

Is there a way to avoid this behaviour when 2d and 3d object differ in size in Deck?

yaras-phoenix avatar Sep 24 '24 15:09 yaras-phoenix

What exactly is the bug you are reporting here? The GeoJSON you supply is smaller than the mesh and the rendering result is true to the data.

Pessimistress avatar Sep 24 '24 15:09 Pessimistress

The problem is that every desktop GIS I use measures this object at ~2000.25: QGIS, GeoMedia, ArcGIS. And when it is published using Deck, I get 1993.5. building measure geomedia building measure arcgis

yaras-phoenix avatar Sep 25 '24 08:09 yaras-phoenix

Trying to go deeper I found a clue in Postgis docs. There are 2 functions there: ST_DistanceSphere and ST_DistanceSpheroid. They give me the same difference (1993.65745225 and 2000.2556515777933 respectively) and they relate to slightly different world spaces.

It seems desktop GIS applications work with spheroids and web applications work with spheres so the same data gives different result. But 3D model in the scenegraph layer was generated in different, cartesian environment.

So my question would be: is it possible to somehow bring all my data into line so they would be the same on the deck map?

yaras-phoenix avatar Sep 25 '24 14:09 yaras-phoenix

@yaras-phoenix Your model data in 3D tiles might be in meter offsets where each tile has a lng/lat anchor. You could try to hook into the tile loading and use something like @math.gl/proj4 to reproject that anchor from spheroid to spherical coordinates or vice versa. It would likely take you a bit of fiddling to figure out where and how to hook in and which coordinate systems to use in the reprojection and how to specify them.

ibgreen avatar Sep 25 '24 16:09 ibgreen

More precisely the lng/lat anchor is probably calculated by loaders.gl from the WGS84 world centric coordinates, you might also be able to access the WGS84 "anchor" coordinates in the loaded tile and reproject directly from those.

ibgreen avatar Sep 25 '24 16:09 ibgreen

Circumvented this one by letting users manually change model dimensions in app so closing the issue.

yaras-phoenix avatar Jun 20 '25 09:06 yaras-phoenix