Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute_view not working #365

Closed
giswqs opened this issue Feb 14, 2024 · 4 comments
Closed

compute_view not working #365

giswqs opened this issue Feb 14, 2024 · 4 comments

Comments

@giswqs
Copy link
Contributor

giswqs commented Feb 14, 2024

Context

I am trying to use to the compute_view method to get the latitude, longitude, and zoom level of the layer so that the map can automatically zoom to the area of interest. It used to work, but not any more. It throws the following error:

AttributeError: 'pyarrow.lib.ChunkedArray' object has no attribute '_bbox'

Code

import geopandas as gpd
from lonboard import Map, SolidPolygonLayer
from lonboard._viewport import compute_view

gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

layer = SolidPolygonLayer.from_geopandas(
    gdf,
    get_fill_color=[255, 0, 0],
)

compute_view(layer.table)

Error

image

@kylebarron
Copy link
Member

I mean... you're using a private method. No attempt for backwards compatibility is made for private methods.

@kylebarron kylebarron changed the title [EPIC] compute_view not working compute_view not working Feb 14, 2024
@giswqs
Copy link
Contributor Author

giswqs commented Feb 14, 2024

Understood. What is the recommended way of getting the center and zoom level of a layer so that the map can zoom to the layer programmatically?

@kylebarron
Copy link
Member

kylebarron commented Feb 14, 2024

The simple answer is that there isn't a public API for this because lonboard expects to be able to auto-center once when the user creates a map. We don't try to support auto-zooming for new layers because that's an open question: to what extent should it zoom to the new layer, even if it's at a completely different location than the previous layer.

We have some heuristics internally, but those heuristics are not stable enough to be exposed publicly as standalone functions IMO.

The table attribute of any layer that subclasses from BaseArrowLayer is public; that will always be a GeoArrow table object. For the forseeable future that will always be a pyarrow.Table. You can rely on those public attributes

@kylebarron
Copy link
Member

I'm going to close this because this is expected behavior. At some point in the future, maybe
more internals will be made public, but for now I'm focusing on the stability of the end-user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants