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

Invert layers order in split_mixed_gdf function #513

Closed
RaczeQ opened this issue May 11, 2024 · 2 comments
Closed

Invert layers order in split_mixed_gdf function #513

RaczeQ opened this issue May 11, 2024 · 2 comments

Comments

@RaczeQ
Copy link
Contributor

RaczeQ commented May 11, 2024

What do you think about changing the order of gdfs and subsequently layers to keep points and lines on top of polygons? It seems natural to me, but I don't know if it's viable to do so.

lonboard/lonboard/_utils.py

Lines 143 to 161 in b2ca192

gdfs = []
point_indices = np.where(
(type_ids == GeometryType.POINT) | (type_ids == GeometryType.MULTIPOINT)
)[0]
if len(point_indices) > 0:
gdfs.append(gdf.iloc[point_indices])
linestring_indices = np.where(
(type_ids == GeometryType.LINESTRING)
| (type_ids == GeometryType.MULTILINESTRING)
)[0]
if len(linestring_indices) > 0:
gdfs.append(gdf.iloc[linestring_indices])
polygon_indices = np.where(
(type_ids == GeometryType.POLYGON) | (type_ids == GeometryType.MULTIPOLYGON)
)[0]
if len(polygon_indices) > 0:
gdfs.append(gdf.iloc[polygon_indices])

viz(
    result_gdf.geometry, # since points are being split first, they land as first layer on the bottom
    # optional styling
    scatterplot_kwargs=dict(get_fill_color="#5c53a5"),
    path_kwargs=dict(get_color="#eb7f86"),
    polygon_kwargs=dict(stroked=False, get_fill_color="#f3e79b"),
    map_kwargs=dict(basemap_style=basemap.CartoBasemap.VoyagerNoLabels),
)

image

@RaczeQ
Copy link
Contributor Author

RaczeQ commented May 13, 2024

I've created a #516 PR for this issue 😉

kylebarron added a commit that referenced this issue May 14, 2024
## What I am changing
<!-- What were the high-level goals of the change? -->
- Layer order for objects with mixed geometry types

## How I did it
Changed list appending order for `split_mixed_gdf` and `parse_wkb_table`
function from [`points`, `linestrings`, `polygons`] to [`polygons`,
`linestrings`, `points`]

## How you can test it
<!-- How might a reviewer test your changes to verify that they work as
expected? -->
- Points and paths should be now plotted on top of polygon for better
visibility.

Old:

![Untitled](https://github.com/developmentseed/lonboard/assets/17250607/f0d4a4f5-d69d-4e27-bbc7-3d159d1d2e6b)

New:

![image](https://github.com/developmentseed/lonboard/assets/17250607/8e154ff7-996a-4556-9406-daa355d4184a)

## Related Issues
#513

---------

Co-authored-by: Kyle Barron <kyle@developmentseed.org>
@kylebarron
Copy link
Member

Closed by #516

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