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

How to color only one building. #114

Open
michkowalczuk opened this issue Mar 20, 2023 · 4 comments
Open

How to color only one building. #114

michkowalczuk opened this issue Mar 20, 2023 · 4 comments

Comments

@michkowalczuk
Copy link

michkowalczuk commented Mar 20, 2023

How can I set a different color only for one building?
I can find this building using geodataframe query, but what next? Any ideas?
buildings = plot.geodataframes["building"]

my_building = buildings[(buildings["addr:street"]=="my street name") & (buildings["addr:housenumber"]=="my house number")]

@marceloprates
Copy link
Owner

marceloprates commented Mar 21, 2023

I plan to add a feature to make this easier in the future, but you can use the "multiplot" feature to use several different palettes in the same map. I think you could create a Subplot() with the regular map and a second Subplot() with the color palette you want to use (can contain a single color) and use the "postprocessing" keyword to filter the building you want to color differently.

See the last example in the README tutorial on how to use the "multiplot" feature:

# Draw several regions on the same canvas
prettymaps.multiplot(
    prettymaps.Subplot(
        'Cidade Baixa, Porto Alegre',
        style={'building': {'palette': ['#49392C', '#E1F2FE', '#98D2EB']}}
    ),
    prettymaps.Subplot(
        'Bom Fim, Porto Alegre',
        style={'building': {'palette': ['#BA2D0B', '#D5F2E3', '#73BA9B', '#F79D5C']}}
    ),
    prettymaps.Subplot(
        'Farroupilha, Porto Alegre',
        style={'building': {'palette': ['#EEE4E1', '#E7D8C9', '#E6BEAE']}}
    ),
    # Load a global preset
    preset='cb-bf-f',
    # Figure size
    figsize=(12, 12)
)

@michkowalczuk
Copy link
Author

michkowalczuk commented Mar 21, 2023 via email

@marceloprates
Copy link
Owner

Sorry! I really should include an example in the tutorial on how to use the postprocessing parameter. But basically, postprocessing should be a function that takes a dict of GeoDataFrames as input, modifies it and returns it. For example:

def postprocessing(gdfs):
  all_buildings = gdf['buildings']
  my_building = all_buildings[(all_buildings["addr:street"]=="my street name") & (buildings["addr:housenumber"]=="my house number")]
  gdfs['buildings'] = my_building
  return gdfs

@michkowalczuk
Copy link
Author

michkowalczuk commented Mar 21, 2023 via email

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