Day 7: Green

For today's theme, I've decided to do sustainability-themed map. Raleigh Open Data has a nice dataset contianing the location and useful attributes about sustainable projects in and around Raleigh . I really enjoyed using CARTOframes on Day 1 and have decided to use it as my final map medium. What follows is my workflow for access the data and creating a exploratory map for filtering the sustainable projects on various attributes.

Libraries

I have to install two libraries that don't come with Colaboratory's Python 3 environment: geopandas and CARTOframes.

In [0]:
! pip install geopandas cartoframes==1.0b4
In [0]:
import geopandas as gpd
from cartoframes.viz import Map, Layer, Popup, Legend, Layout, basemaps
from cartoframes.viz.widgets import category_widget, formula_widget
from cartoframes.viz.helpers import color_category_layer

Data

In [0]:
green_gdf = gpd.read_file('https://opendata.arcgis.com/datasets/009aa26c5f54427cabf4b8042186947a_0.geojson')
display(green_gdf.info(), green_gdf.head())
<class 'geopandas.geodataframe.GeoDataFrame'>
RangeIndex: 280 entries, 0 to 279
Data columns (total 15 columns):
OBJECTID         280 non-null int64
NAME             280 non-null object
CATEGORY         280 non-null object
LOCATION         276 non-null object
OWNER            220 non-null object
TYPE             180 non-null object
STATUS           233 non-null object
SIZE_            101 non-null object
OUTPUT           90 non-null object
CERTIFICATION    69 non-null object
URL              198 non-null object
X                278 non-null float64
Y                278 non-null float64
INSTALLER        77 non-null object
geometry         280 non-null geometry
dtypes: float64(2), geometry(1), int64(1), object(11)
memory usage: 32.9+ KB
None
OBJECTID NAME CATEGORY LOCATION OWNER TYPE STATUS SIZE_ OUTPUT CERTIFICATION URL X Y INSTALLER geometry
0 1 Engineering Building III Vegetative Green Roofs 911 Oval Drive, Raleigh, NC 27606 NC State University Commercial Complete 3,780 SF None None http://sustainability.ncsu.edu/news/centennial... 2.096897e+06 735571.084496 None POINT (-78.67335 35.77065)
1 2 Terry Sanford Federal Building Solar Photovoltaic Projects 310 New Bern Ave General Services Administration Commercial Complete 2,350 Solar Panels 560 kw None None 2.108535e+06 738737.907559 Standard Solar POINT (-78.63408 35.77924)
2 3 Westgate Chrysler Jeep Dodge Solar Photovoltaic Projects 6421 Old Westgate Rd Westgate Chrysler Jeep Dodge Ram Commercial Complete 420 solar panels 98.7 kW None http://www.westgatechryslerjeepdodge.com/ 2.070423e+06 782647.079911 Southern Energy Management POINT (-78.76222 35.90019)
3 4 Carmichael Gym Solar Photovoltaic Projects None North Carolina State University Commercial Complete 120 panels None None http://www.ncsu.edu 2.097124e+06 739961.406096 Southern Energy POINT (-78.67254 35.78271)
4 5 Carmichael Gym Solar Thermal 2611 Cates Ave. Raleigh, NC North Carolina State University Commercial Complete 112 panels None None http://www.schneider-electric.com 2.097051e+06 740078.072529 Schneider Electric POINT (-78.67278 35.78303)
In [0]:
Layout(
    [
     Map(
         Layer(
             green_gdf,
             style = '''
             color: green
             width: 8
             strokeWidth: 1
             strokeColor: white
             '''
             )
         )
     ],
     map_height = 600
  )
Out[0]:

The data is in pretty good shape and there don't appear to be any missing geometries. A little tidying couldn't hurt though!

In [0]:
fillna_cols = ['CERTIFICATION', 'TYPE', 'STATUS']
[green_gdf[c].fillna('Not Indicated', inplace = True) for c in fillna_cols]
green_gdf['CERTIFICATION'] = green_gdf.apply(lambda x: 'No Certification' if x['CERTIFICATION'] == ' ' else x['CERTIFICATION'], axis = 1)
green_gdf = green_gdf[['NAME', 'CATEGORY', 'LOCATION', 'OWNER', 'TYPE', 'STATUS', 'CERTIFICATION', 'SIZE_', 'OUTPUT', 'URL', 'geometry']]
green_gdf.head()
Out[0]:
NAME CATEGORY LOCATION OWNER TYPE STATUS CERTIFICATION SIZE_ OUTPUT URL geometry
0 Engineering Building III Vegetative Green Roofs 911 Oval Drive, Raleigh, NC 27606 NC State University Commercial Complete Not Indicated 3,780 SF None http://sustainability.ncsu.edu/news/centennial... POINT (-78.67335 35.77065)
1 Terry Sanford Federal Building Solar Photovoltaic Projects 310 New Bern Ave General Services Administration Commercial Complete Not Indicated 2,350 Solar Panels 560 kw None POINT (-78.63408 35.77924)
2 Westgate Chrysler Jeep Dodge Solar Photovoltaic Projects 6421 Old Westgate Rd Westgate Chrysler Jeep Dodge Ram Commercial Complete Not Indicated 420 solar panels 98.7 kW http://www.westgatechryslerjeepdodge.com/ POINT (-78.76222 35.90019)
3 Carmichael Gym Solar Photovoltaic Projects None North Carolina State University Commercial Complete Not Indicated 120 panels None http://www.ncsu.edu POINT (-78.67254 35.78271)
4 Carmichael Gym Solar Thermal 2611 Cates Ave. Raleigh, NC North Carolina State University Commercial Complete Not Indicated 112 panels None http://www.schneider-electric.com POINT (-78.67278 35.78303)

Raleigh Sustainability Projects Explorer

In [0]:
Map(
    Layer(
        green_gdf,
        '''
        color: #4CAF50
        width: 8
        strokeWidth: 1
        strokeColor: white
        ''',
        popup = Popup({
           'click': [{
                'title': 'Certification',
                'value': '$CERTIFICATION'
               }, {
                'title': 'Project Use Type',
                'value': '$TYPE'
               }, {
                'title': 'Owner',
                'value': '$OWNER'
               }, {
                'title': 'Site Address',
                'value': '$LOCATION'
               }, {
                'title': 'Site',
                'value':'$NAME'
               } 
            ],
            'hover': [{
                'title': 'Site',
                'value':'$NAME'
            }] 
        }),
        widgets = [
                   category_widget(
                       'CATEGORY',
                       title = 'Category'
                   ), category_widget(
                       'TYPE',
                       title = 'Project Use Type'
                   ), category_widget(
                       'CERTIFICATION',
                       title = 'Certification'
                   ), category_widget(
                       'STATUS',
                       title = 'Project Status'
                   )
        ]
    )
)
Out[0]: