
:orphan:
:html_theme.sidebar_secondary.remove:

.. This document is auto-generated by the altair-gallery extension. Do not modify directly.

.. _gallery_point_map:


Point map
=========
This is a layered map that shows the positions of airports on a background of U.S. states.


.. altair-plot::
    :remove-code:
    


    import altair as alt
    from altair.datasets import data

    # Read in points
    airports = data.airports()

    # Read in polygons from topojson
    states = alt.topo_feature(data.us_10m.url, feature='states')

    # US states background
    background = alt.Chart(states).mark_geoshape(
        fill='lightgray',
        stroke='white'
    ).properties(
        width=500,
        height=300
    ).project('albersUsa')

    # airport positions on background
    points = alt.Chart(airports).mark_circle(
        size=10,
        color='steelblue'
    ).encode(
        longitude='longitude:Q',
        latitude='latitude:Q',
        tooltip=['name', 'city', 'state']
    )

    background + points
    # No channel encoding options are specified in this chart
    # so the code is the same as for the method-based syntax.


.. tab-set::

    .. tab-item:: Method syntax
        :sync: method

        .. code:: python


            import altair as alt
            from altair.datasets import data

            # Read in points
            airports = data.airports()

            # Read in polygons from topojson
            states = alt.topo_feature(data.us_10m.url, feature='states')

            # US states background
            background = alt.Chart(states).mark_geoshape(
                fill='lightgray',
                stroke='white'
            ).properties(
                width=500,
                height=300
            ).project('albersUsa')

            # airport positions on background
            points = alt.Chart(airports).mark_circle(
                size=10,
                color='steelblue'
            ).encode(
                longitude='longitude:Q',
                latitude='latitude:Q',
                tooltip=['name', 'city', 'state']
            )

            background + points


    .. tab-item:: Attribute syntax
        :sync: attribute

        .. code:: python


            import altair as alt
            from altair.datasets import data

            # Read in points
            airports = data.airports()

            # Read in polygons from topojson
            states = alt.topo_feature(data.us_10m.url, feature='states')

            # US states background
            background = alt.Chart(states).mark_geoshape(
                fill='lightgray',
                stroke='white'
            ).properties(
                width=500,
                height=300
            ).project('albersUsa')

            # airport positions on background
            points = alt.Chart(airports).mark_circle(
                size=10,
                color='steelblue'
            ).encode(
                longitude='longitude:Q',
                latitude='latitude:Q',
                tooltip=['name', 'city', 'state']
            )

            background + points
            # No channel encoding options are specified in this chart
            # so the code is the same as for the method-based syntax.
