コード例 #1
0
 def __init__(
     self,
     mesh: str = DeckGLMapProps.image,
     property_texture: str = DeckGLMapProps.image,
     color_map_name: str = DeckGLMapProps.color_map_name,
     name: str = LayerNames.MAP3D,
     bounds: List[float] = None,
     mesh_value_range: List[float] = None,
     mesh_max_error: int = 5,
     property_value_range: List[float] = None,
     color_map_range: List[float] = None,
     contours: List[float] = None,
     rot_deg: float = 0.0,
     uuid: Optional[str] = None,
     **kwargs: Any,
 ) -> None:
     super().__init__(
         type=LayerTypes.MAP3D,
         id=uuid if uuid is not None else LayerIds.MAP3D,
         mesh=String(mesh),
         propertyTexture=String(property_texture),
         colorMapName=String(color_map_name),
         name=String(name),
         bounds=bounds if bounds is not None else DeckGLMapProps.bounds,
         meshValueRange=mesh_value_range if mesh_value_range is not None else [0, 1],
         propertyValueRange=property_value_range
         if property_value_range is not None
         else [0, 1],
         colorMapRange=color_map_range if color_map_range is not None else [0, 1],
         meshMaxError=mesh_max_error,
         contours=contours if contours is not None else [0, 100],
         rotDeg=rot_deg,
         **kwargs,
     )
コード例 #2
0
 def __init__(
     self,
     data: FeatureCollection = None,
     name: str = LayerNames.WELL,
     uuid: Optional[str] = None,
     **kwargs: Any,
 ) -> None:
     super().__init__(
         type="GeoJsonLayer",
         id=uuid if uuid is not None else LayerIds.WELL,
         name=String(name),
         data={"type": "FeatureCollection", "features": []}
         if data is None
         else data,
         get_text="properties.attribute",
         get_text_size=12,
         get_text_anchor=String("start"),
         # logData=log_data,
         # logrunName=log_run,
         # logName=log_name,
         # selectedWell=String(selected_well),
         pointType=String("circle+text"),
         lineWidthMinPixels=2,
         pointRadiusMinPixels=2,
         pickable=True,
         **kwargs,
     )
コード例 #3
0
ファイル: image.py プロジェクト: wsmoyer/deck.gl
 def __repr__(self):
     if self.is_local:
         with open(self.path, "rb") as img_file:
             encoded_string = get_encoding(self.path) + base64.b64encode(
                 img_file.read()).decode("utf-8")
             return String(encoded_string).__repr__()
     else:
         return String(self.path).__repr__()
コード例 #4
0
def plot_arc(
    df,
    time,
    txpower: int,
    lat_view: float = 26.713389,
    lng_view: float = -80.053782,
):
    # prepare data snapshot at a specific time point for a specific txpower
    plot_df = df[(df.plot_timestamp == time) & (df.txpower == txpower)]
    arc_layer = pdk.Layer(
        "ArcLayer",
        data=plot_df,
        get_width="width",
        get_source_position=["lng_emit", "lat_emit"],
        get_target_position=["lng_sensor", "lat_sensor"],
        get_tilt=15,
        get_source_color="color",
        get_target_color="color",
        pickable=True,
        auto_highlight=True,
    )
    emitter_id_layer = pdk.Layer(
        "TextLayer",
        data=plot_df,
        get_position=["lng_emit", "lat_emit"],
        get_text="emitter",
        get_size=50,
        get_color="color",
        get_text_anchor=String("end"),
        get_alignment_baseline=String("top"),
    )
    sensor_id_layer = pdk.Layer(
        "TextLayer",
        data=plot_df,
        get_position=["lng_sensor", "lat_sensor"],
        get_text="sensor",
        get_size=50,
        get_color=[77, 77, 255],
        get_text_anchor=String("end"),
        get_alignment_baseline=String("top"),
    )
    view_state = pdk.ViewState(
        latitude=lat_view,
        longitude=lng_view,
        pitch=50,
        zoom=20,
    )
    TOOLTIP_TEXT = {"html": "RSSI relative change: {rc}"}
    return pdk.Deck(
        [arc_layer, emitter_id_layer, sensor_id_layer],
        initial_view_state=view_state,
        tooltip=TOOLTIP_TEXT,
        map_style="road",
        map_provider="mapbox",
        api_keys={"mapbox": st.secrets["MAPBOX_API_KEY"]},
    )
コード例 #5
0
 def __repr__(self):
     if self.is_local:
         with open(os.path.expanduser(self.path), "rb") as img_file:
             encoded_string = get_encoding(self.path) + base64.b64encode(
                 img_file.read()).decode("utf-8")
             return repr(String(encoded_string, quote_type=""))
     else:
         return self.path
コード例 #6
0
 def __init__(
     self,
     image: str = DeckGLMapProps.image,
     name: str = LayerNames.HILLSHADING,
     bounds: List[float] = None,
     value_range: List[float] = None,
     uuid: Optional[str] = None,
     **kwargs: Any,
 ) -> None:
     super().__init__(
         type=LayerTypes.HILLSHADING,
         id=uuid if uuid is not None else LayerIds.HILLSHADING,
         image=String(image),
         name=String(name),
         bounds=bounds if bounds is not None else DeckGLMapProps.bounds,
         valueRange=value_range if value_range is not None else [0, 1],
         **kwargs,
     )
コード例 #7
0
def generateNPALabelsLayer(label_file):
    """
        Generates Layer for NPA number labels at the average lng-lat for each NPA.

        label_file: dataframe with columns "NPA_str", "longitude", and "latitude"
    """
    label_file["NPA_str"] = label_file["NPA_str"].astype(str)

    return pdk.Layer('TextLayer',
                     data=label_file,
                     pickable=False,
                     get_size=16,
                     get_color=[1, 1, 1],
                     get_position=['longitude', 'latitude'],
                     get_text="NPA_str",
                     get_angle=0,
                     get_text_anchor=String("middle"),
                     get_alignment_baseline=String("center"))
コード例 #8
0
 def __init__(
     self,
     mode: Literal[  # Use Enum?
         "view", "modify", "transform", "drawPoint", "drawLineString", "drawPolygon"
     ] = "view",
     uuid: Optional[str] = None,
     **kwargs: Any,
 ):
     super().__init__(
         type=LayerTypes.DRAWING,
         id=uuid if uuid is not None else LayerIds.DRAWING,
         name=LayerNames.DRAWING,
         mode=String(mode),
         **kwargs,
     )
コード例 #9
0
 def __init__(
     self,
     data: FeatureCollection = None,
     name: str = LayerNames.FAULTPOLYGONS,
     uuid: Optional[str] = None,
     **kwargs: Any,
 ) -> None:
     super().__init__(
         type=LayerTypes.FAULTPOLYGONS,
         id=uuid if uuid is not None else LayerIds.FAULTPOLYGONS,
         name=String(name),
         data={
             "type": "FeatureCollection",
             "features": [],
         }
         if data is None
         else data,
         **kwargs,
     )
コード例 #10
0
 def __init__(self, layer_type: str, uuid: str, name: str, **kwargs: Any) -> None:
     super().__init__(type=layer_type, id=String(uuid), name=String(name), **kwargs)
コード例 #11
0
from pydeck import Layer, Deck
from pydeck.data_utils import compute_view
from pydeck.types import String

DATA_URL = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/bart-stations.json"
SCENEGRAPH_URL = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxAnimated/glTF-Binary/BoxAnimated.glb"

# Automatically fit viewport location based on data
df = pd.read_json(DATA_URL)
view = compute_view(df["coordinates"])

layer = Layer(
    type="ScenegraphLayer",
    id="scenegraph-layer",
    data=DATA_URL,
    pickable=True,
    scenegraph=SCENEGRAPH_URL,
    get_position="coordinates",
    get_orientation=[0, 180, 90],
    size_scale=500,
    _animations={"*": {
        "speed": 5
    }},
    _lighting=String("pbr"),
)

# Render
r = Deck(layer, initial_view_state=view)
r.to_html("scenegraph_layer.html")
コード例 #12
0
def test_quotes():
    assert "`ok`" == String("ok", quote_type="`")
コード例 #13
0
def test_basic_case():
    assert '"ok"' == String("ok")
コード例 #14
0
def run():

    st.title('Beatties Ford Road Project')

    grocery = pd.read_csv('./grocery-data/Grocery_Stores.csv')
    grocery = grocery.rename(columns={'X': 'longitude', 'Y': 'latitude'})
    grocery = grocery[['longitude', 'latitude', 'Name']]
    coords = grocery[['longitude', 'latitude']]

    st.write(grocery)
    medianLong = grocery['longitude'].median()
    medianLat = grocery['latitude'].median()
    st.write(grocery.dtypes)

    beattiesGeoJson = "https://raw.githubusercontent.com/wesmith4/mat210-proj-beatties/main/beatties.geojson"
    roadLabel = pd.read_json("./roadLabel.json")

    tooltip = {"html": "<b>Store:</b> {Name}"}
    view_state = pdk.ViewState(
        **{
            "latitude": 35.33,
            "longitude": -80.89,
            "zoom": 10.50,
            "maxZoom": 22,
            "pitch": 0,
            "bearing": 0
        })
    st.write("""## Grocery stores in Mecklenburg County""")
    st.pydeck_chart(
        pdk.Deck(
            map_style='mapbox://styles/mapbox/streets-v11',
            initial_view_state=view_state,
            layers=[
                pdk.Layer(
                    'ScatterplotLayer',
                    data=grocery,
                    get_position=['longitude', 'latitude'],
                    get_color='[200, 30, 0, 160]',
                    get_radius=200,
                    pickable=True,
                    extruded=True,
                    #  elevationScale=4,
                    #  elevationRange=[0,1000]
                ),
                pdk.Layer('GeoJsonLayer',
                          data=beattiesGeoJson,
                          filled=True,
                          pickable=False,
                          lineWidthMinPixels=3,
                          get_line_color=[0, 0, 200],
                          opacity=1,
                          id='beatties-ford-road',
                          use_binary_transport=False,
                          extruded=True),
                pdk.Layer('TextLayer',
                          data=roadLabel,
                          id='label',
                          pickable=False,
                          get_size=16,
                          get_color=[1, 1, 1],
                          get_position="coordinates",
                          get_text="name",
                          get_angle=0,
                          get_text_anchor=String("middle"),
                          get_alignment_baseline=String("center"))
            ],
            tooltip=tooltip))

    components.html("""
    <iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.socialexplorer.com/bc9c206f28/embed" width="640" height="480" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
    """,
                    width=640,
                    height=480)

    components.html("""
        <iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.socialexplorer.com/7e100dcc9b/embed" width="640" height="480" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
    """,
                    width=640,
                    height=480)
コード例 #15
0
TEXT_LAYER_DATA = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/bart-stations.json"  # noqa
df = pd.read_json(TEXT_LAYER_DATA)

# Define a layer to display on a map
layer = pdk.Layer(
    "TextLayer",
    df,
    pickable=True,
    get_position="coordinates",
    get_text="name",
    get_size=16,
    get_color=[255, 255, 255],
    get_angle=0,
    # Note that string constants in pydeck are explicitly passed as strings
    # This distinguishes them from columns in a data set
    get_text_anchor=String("middle"),
    get_alignment_baseline=String("center"),
)

# Set the viewport location
view_state = pdk.ViewState(latitude=37.7749295,
                           longitude=-122.4194155,
                           zoom=10,
                           bearing=0,
                           pitch=45)

# Render
r = pdk.Deck(
    layers=[layer],
    initial_view_state=view_state,
    tooltip={"text": "{name}\n{address}"},
コード例 #16
0
def run():
    st.title('A Journey Down Beatties Ford Road')
    st.write('**Sights along Beatties Ford Road from North to South**')
    st.write('\n')
    st.write(
        'As Beatties Ford runs from Huntersville to West Charlotte, the sights along the way are not uniform. Housing quality, racial demographics of neighborhoods, and the prevalence of fast food chains begin to shift as the road travels south. Before using the data collected on various socioeconomic indicators for different areas along the road and in different time periods, let us first journey down the road and examine the sights that are seen on the way.'
    )
    st.write(
        'The Quality of Life Explorer divides Mecklenburg County into NPAs, or Neighborhood Profile Areas, for its spatial visualization of the included variables.'
    )
    st.markdown("""
    
    As defined by the [Quality of Life Study](https://mcmap.org/qol/#15/):

    > *Neighborhood Profile Areas (NPAs) are geographic areas used for the organization and presentation of data in the Quality of Life Study.
    The boundaries were developed with community input and are based on one or more Census block groups.*

    """)
    st.write('\n')
    st.write(
        'As we visualize a drive down Beatties Ford Road, different sights will be marked by which NPA they are in, and will be ordered from north to south. Not all locations will be directly on Beatties Ford Road, but in the same NPA or nearby. The NPAs that Beatties Ford Road runs through are shown in the map below:'
    )
    jsonData = json.load(open('./qol-data/npa.json'))
    frame = pd.DataFrame()
    frame['coordinates'] = [
        feature['geometry']['coordinates'] for feature in jsonData['features']
    ]
    frame['NPA'] = [
        int(feature['properties']['id']) for feature in jsonData['features']
    ]

    master = pd.read_pickle('./qol-data/master.pkl')

    forMap = pd.merge(master[['NPA']], frame, how="left", on="NPA")

    npa_layer = pdk.Layer('PolygonLayer',
                          data=forMap,
                          get_polygon='coordinates',
                          filled=True,
                          stroked=True,
                          extruded=False,
                          get_fill_color=[0, 0, 0, 0],
                          get_line_color=[0, 0, 0],
                          lineWidthMinPixels=1,
                          pickable=True,
                          auto_highlight=True)

    road_layer = mapping.generateRoadLayer()

    labels = pd.read_csv('./qol-data/NPA_Labels.csv')
    labels['NPA_str'] = labels['NPA_str'].astype(str)

    label_layer = pdk.Layer('TextLayer',
                            data=labels,
                            pickable=False,
                            get_size=16,
                            get_color=[1, 1, 1],
                            get_position=['longitude', 'latitude'],
                            get_text="NPA_str",
                            get_angle=0,
                            get_text_anchor=String("middle"),
                            get_alignment_baseline=String("center"))

    view_state = pdk.ViewState(
        **{
            'latitude': 35.33,
            'longitude': -80.89,
            'zoom': 10.50,
            'maxZoom': 22,
            'pitch': 0,
            'bearing': 0
        })

    tooltip = {'html': '<b>NPA:</b> {NPA}'}

    deck = pdk.Deck(map_style='mapbox://styles/mapbox/streets-v11',
                    layers=[npa_layer, label_layer, road_layer],
                    initial_view_state=view_state,
                    tooltip=tooltip)
    st.pydeck_chart(deck)

    st.write('')
    st.write('')

    col1, col2 = st.beta_columns(2)
    with col1:
        st.image(Image.open('images/1house.png'))
    with col2:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 450**')
        st.write(' ')
        st.write('House on Savannah Grace Lane.')

    col3, col4 = st.beta_columns(2)
    with col4:
        st.image(Image.open('images/2school.png'))
    with col3:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 450**')
        st.write(' ')
        st.write('Front of Francis Bradley Middle School.')
    col5, col6 = st.beta_columns(2)
    with col5:
        st.image(Image.open('images/3school.png'))
    with col6:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 447**')
        st.write(' ')
        st.write('View of Community School of Davidson.')

    col7, col8 = st.beta_columns(2)
    with col8:
        st.image(Image.open('images/4house.png'))
    with col7:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 447**')
        st.write(' ')
        st.write('House along Carrington Ridge Drive.')

    col9, col10 = st.beta_columns(2)
    with col9:
        st.image(Image.open('images/5house.png'))
    with col10:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 447**')
        st.write(' ')
        st.write('House along Mclothian Lane.')

    col11, col12 = st.beta_columns(2)
    with col12:
        st.image(Image.open('images/6house.png'))
    with col11:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 209**')
        st.write(' ')
        st.write('Streetview of Davis Meadows Drive.')

    col13, col14 = st.beta_columns(2)
    with col13:
        st.image(Image.open('images/7house.png'))
    with col14:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 280**')
        st.write(' ')
        st.write(
            'Streetview of Countrywoods Mobile Home Park. The number of mobile homes increases as we travel more south; the particular park is in NPA 280, southeast of NPA 209.'
        )

    col15, col16 = st.beta_columns(2)
    with col16:
        st.image(Image.open('images/9store.jpg'))
    with col15:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 123**')
        st.write(' ')
        st.write(
            "Storefront of Firestone-Garden Park. The number of fast food restaurants such as Little Caesar's is also increasing."
        )

    col17, col18 = st.beta_columns(2)
    with col17:
        st.image(Image.open('images/10house.png'))
    with col18:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 385**')
        st.write(' ')
        st.write(
            'Streetview of Charlotte Village Mobile Home. Another trailer park in the area, NPA 385 is southwest of NPA 123.'
        )

    col19, col20 = st.beta_columns(2)
    with col20:
        st.image(Image.open('images/11house.png'))
    with col19:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 374**')
        st.write(' ')
        st.write(
            'Lincoln Heights made headlines in June 2020 after a shooting occurred in the area.'
        )

    col21, col22 = st.beta_columns(2)
    with col21:
        st.image(Image.open('images/12mem.jpg'))
    with col22:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 374**')
        st.write(' ')
        st.write(
            'A memorial for the victims of the June 22nd, 2020 shooting. The incident occurred near the intersection of Beatties Ford Road and Catherine Simmons Avenue.'
        )

    col23, col24 = st.beta_columns(2)
    with col24:
        st.image(Image.open('images/13house.png'))
    with col23:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 85**')
        st.write(' ')
        st.write(
            'Washington Heights is one of the neighborhoods in the area with a historic past. It was made as a neighborhood for the rising Black middle-class in the early 20th century.'
        )

    col25, col26 = st.beta_columns(2)
    with col25:
        st.image(Image.open('images/14brew.png'))
    with col26:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 347**')
        st.write(' ')
        st.write(
            "Blue Blaze Brewery. Now that we're closer to Charlotte, note the difference in surrounding restaurants."
        )
    col27, col28 = st.beta_columns(2)

    with col28:
        st.image(Image.open('images/16brew.png'))
    with col27:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 340**')
        st.write(' ')
        st.write('VBGB Beer Hall and Garden.')

    col29, col30 = st.beta_columns(2)
    with col29:
        st.image(Image.open('images/15brew.png'))
    with col30:
        st.markdown("""
        #
        # 
        ## """)
        st.write('**NPA 340**')
        st.write(' ')
        st.write(
            'Storefront of VBGB Beer Hall and Garden - now, at the end of Beatties Ford Road, the surrounding area is starting to look like how much of West Charlotte does.'
        )
コード例 #17
0
def test_basic_case():
    assert "ok" == String("ok")