Comments (3)
The idea here is to let the user draw a box on the screen and select items from their visualization. The items may either be highlighted on the JS side in the map or, also, the row indexes can be sent back from JS to Python so that the user can call gdf.iloc[layer.selected_indexes]
.
The predominant question is: how do you draw a bounding box in deck.gl?
Option 1: "Manual" approach
Deck has a pickObjects
method on the map class to find the objects that intersect with the box. I believe the input box should be in screen space, as it's described to be pixels. This means that what we need to do is enable a selection tool and access the pixel range of the map canvas from that selection. I don't know how to do this myself, and maybe nebula.gl would help with this, or maybe it's better to read up on how e.g. leaflet-draw works.
Option 2: Nebula.gl
nebula.gl is a library that works with deck.gl to enable editing of geospatial data. In theory, this should solve the problem for us using its SelectionLayer, but the library seems to be no longer maintained.
Once we have the data from pickObjects
, we can take those row indexes and update them on the widget state to send the data back to Python.
from lonboard.
Some related findings discussions we had today.
For 'Drawing-bbox' UI part
Existing options - Nebula.gl
As mentioned, Nebula.gl seems to be not maintained anymore.
Use react-map-gl-draw
I was hoping we could use react-map-gl-draw plugin with ReactMapGL's useControl
hook. However, the current way of using Mapbox (Inside of as a child of ) seems to confuse the plugin. I could not draw anything with the control added on. I can't pinpoint why, maybe DeckGL layer is interfering the interaction between mapbox-gl-draw and mapbox gl? or mapbox-gl-draw cannot reach Mapbox?
We discussed using the DeckGL layer as a MapboxOverlay, which will give a better integration with other Mapbox controls. Considering this will change how all the layers will work internally, it seems not worth the risk.
For passing the data to layer part
pickObjects
method belongs to DeckGL instance. (So the layer doesn't have access to these objects.) To expose the selected indices in a coherent way (attaching selected objects to the layer level), We would need to associate selected indices to each layer. Since selected objects have the layer that they belong to, we can use that info and attach it to the layers? Maybe using Submodelstates which have the layers?:
Lines 68 to 73 in 96611f5
from lonboard.
@kylebarron and I started hacking on this a bit when we met last week, many thanks to @isaacbrodsky for the initial PR that was a great starting point.
This is the PR where I've been working: #417
Here's a screen recording of what the interaction looks like currently:
BboxScreengrab.mp4
The bit to get working is passing the selected indexes back to Python, but that should be reasonably straightforward. And the code needs a bunch of cleanups.
It would also be nice to get some design help :)
Seeing how complex this could get in the future (do we support drawing arbitrary polygons, etc) - @kylebarron, am wondering how this code should be structured -- I'll leave further comments on the PR.
from lonboard.
Related Issues (20)
- Improve attribution
- lonboard within quarto? HOT 8
- Chunking issues with Arrow input.
- PathStyleExtension in lonboard HOT 3
- [BUG] Unable to change the basemap_style HOT 2
- Pass `crs` parameter into `viz` HOT 1
- [EPIC] Enable mixed geometry type visualization HOT 9
- Adding a legend? HOT 1
- Allow dict input for Map Style
- Pass `Path` into `viz`?
- WidgetControl: display other widgets on the same map
- Test with pyogrio 0.8
- GeoArrowLayer
- Use `ravel()` instead of `flatten()`
- Invert layers order in `split_mixed_gdf` function HOT 2
- Google Colab support. HOT 3
- Understanding fly_to() and set_view_state() HOT 3
- Automated widget testing
- [BUG] Error in reprojection from GeoArrow stream with non-WGS84 crs and non-nullable coords HOT 1
- Add test for fixed GeoArrow reprojection with GeoPandas 1.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lonboard.