In [1]:
from arcgis.gis import GIS
from arcgis.mapping import WebMap, WebScene
from arcgis.widgets import FeatureSet, Layer, MapView
from arcgis.features import summarize_data, FeatureLayer, manage_data

from IPython.display import display
import pandas as pd
import json
import requests 

from data.geographic import gisConn, gisUser, gisPass

gis = GIS(gisConn, gisUser, gisPass)

In [7]:
def registerGis(gis):
    '''
    gis = GIS(conn, user, pass)
    '''
    fc = gis.content.import_data(readWiki("https://en.wikipedia.org/wiki/Number_of_guns_per_capita_by_country", 1), 
                                 {"CountryCode":"Country"})
    map1 = gis.map('UK')
    map1.add_layer(fc, {"renderer":"ClassedSizeRenderer",
               "field_name": "Guns_per_100_Residents"})
    
    item_properties = {
        "title": "Worldwide gun ownership",
        "tags" : "guns,violence",
        "snippet": " GSR Worldwide gun ownership",
        "description": "test description",
        "text": json.dumps({"featureCollection": {"layers": [dict(fc.layer)]}}),
        "type": "Feature Collection",
        "typeKeywords": "Data, Feature Collection, Singlelayer",
        "extent" : "-102.5272,-41.7886,172.5967,64.984"
    }
    item = gis.content.add(item_properties)
    return map1, item

def readWiki(url, tableIndex):
    '''
    - df = pd.read_html("https://en.wikipedia.org/wiki/Number_of_guns_per_capita_by_country")[1]
    '''
    df = pd.read_html(url)[tableIndex]
    df.columns = df.iloc[0]
    df = df.reindex(df.index.drop(0))

# change number + index to number    
    df.iloc[0,2] = 112.6

# change column format    
    converted_column = pd.to_numeric(df["Guns per 100 Residents"], errors = 'coerce')
    df['Guns per 100 Residents'] = converted_column
    return df

#map1, item = registerGis(gis)

In [8]:
search_result = gis.content.search("Worldwide gun ownership")
search_result[0]


Out[8]:
Worldwide gun ownership
GSR Worldwide gun ownershipFeature Collection by w.maquire
Last Modified: toukokuu 26, 2017
0 comments, 0 views

In [9]:
def searchGis(gis, key = 'world'):
    items = gis.content.search(key)
    for item in items:
        display(item)

def getFeatureLayers(item):
    '''
    stockTest = company performance
    cityToCompanyTest = company to city comparison    
    '''
    layers = item.layers
    fset = layers[0].query()
    display(fset.df)
    return fset

search_result = gis.content.search('cityToCompany')
#item = search_result[0]
#cityToCompany_fset = getFeatureLayers(item)

search_result = gis.content.search('stockTest')
#item = search_result[0]
#companyStat_fset = getFeatureLayers(item)

In [3]:
gis = GIS()
public_3d_city_scenes = gis.content.search(query="3d cities", item_type = "web scene",
                                           sort_field="numViews" ,sort_order="asc",
                                           max_items = 15, outside_org=True)
for item in public_3d_city_scenes:
    display(item)


Natural Disasters
This web scene contains historic earthquakes, tornados, typhoons, and 3D cities.Web Scene by khalaf_AGIS
Last Modified: huhtikuu 06, 2017
0 comments, 0 views
Sacramento City #2
Web Scene by matt8905@esri.com_CountySandbox
Last Modified: huhtikuu 25, 2017
0 comments, 0 views
Optimized New York City LOD2 3D Buildings
Render performance testing websceneWeb Scene by patr4089@esri.com_citygov
Last Modified: huhtikuu 25, 2017
0 comments, 0 views
My Scene city
Web Scene by tuc.workshop21
Last Modified: kesäkuu 07, 2017
0 comments, 0 views
New Orleans 3D Buildings
3D buildings and LiDAR for New Orleans, LAWeb Scene by esri_3d
Last Modified: helmikuu 09, 2017
0 comments, 0 views
Vancouver Coastal Health
Vancouver Coastal Health Community Care Facilities in the City of Vancouver, British ColumbiaWeb Scene by Thomas_BHCGIS
Last Modified: joulukuu 11, 2016
0 comments, 0 views
3d Parks
Where to Play in Riverside? Web Scene by LPierce@riverside.tld_CityOfRiverside
Last Modified: huhtikuu 04, 2017
0 comments, 0 views
Natural Disasters
This web scene contains historic earthquakes, tornadoes, typhoons, and 3D citiesWeb Scene by akishor1_GISandData
Last Modified: maaliskuu 17, 2017
0 comments, 0 views
NYC_3D_Buildings2
New York Cities open source LoD2 3D Buildings with 2014 Post Sandy LiDAR Point Cloud SurveyWeb Scene by YZhu_SceneLayersTeam
Last Modified: toukokuu 19, 2017
0 comments, 0 views
New_York_City_3D_LiDAR_origin
New York Cities open source LoD2 3D Buildings with 2014 Post Sandy LiDAR Point Cloud SurveyWeb Scene by holistic_user10
Last Modified: toukokuu 20, 2017
0 comments, 0 views
3dmarkers_trees_cities
tWeb Scene by susantran
Last Modified: joulukuu 10, 2016
0 comments, 0 views
WorldPop
summaryWeb Scene by msummers_monstropolis
Last Modified: maaliskuu 23, 2017
0 comments, 0 views
Mosul Dam
Web Scene of Mosul Dam, North of the CityWeb Scene by thom7739@esri.com_esrifederal
Last Modified: maaliskuu 28, 2017
0 comments, 0 views
City of Queenstown
Queenstown 3D for planning, utilities, interiorsWeb Scene by awesome3D
Last Modified: syyskuu 05, 2016
0 comments, 0 views
Natural Disasters
This web scene contains historic earthquakes, tornadoes, typhoons, and 3D cities.Web Scene by raove@us.ibm.com
Last Modified: huhtikuu 02, 2017
0 comments, 0 views

In [4]:
item = public_3d_city_scenes[0]
item


Out[4]:
Natural Disasters
This web scene contains historic earthquakes, tornados, typhoons, and 3D cities.Web Scene by khalaf_AGIS
Last Modified: huhtikuu 06, 2017
0 comments, 0 views

In [ ]: