<jupyter_start><jupyter_text>Exercise Set 2 - Content   1. Run the following code to download the dataset:- French Colleges: https://opendata.arcgis.com/datasets/e51c463be0234a86afa5d243e085cc03_12.zip- Traffic Accidents: https://opendata.arcgis.com/datasets/da2cb32e8c0a4007aca8b3c339408665_0.gdb<jupyter_code>import requests, os
urls = [(r'./data/frenchshapefile.zip', 'https://opendata.arcgis.com/datasets/e51c463be0234a86afa5d243e085cc03_12.zip'), 
        (r'./data/fgdb.zip', 'https://opendata.arcgis.com/datasets/da2cb32e8c0a4007aca8b3c339408665_0.gdb')]
for fname, url in urls:
    resp = requests.get(url, allow_redirects=True)
    if os.path.isfile(fname):
        os.remove(fname)
    with open(fname, 'wb') as writer:
        writer.write(resp.content)
shapefile_data = urls[0][0]
fgdb_data = urls[1][0]<jupyter_output><empty_output><jupyter_text>2.  Publish each dataset to your organization.- For the accidents item, set the thumbnail to `./data/car_accidents.png`<jupyter_code># insert add and publish code here for the two files
from arcgis.gis import GIS
gis = GIS(profile='your_online_profile')
for f in ['frenchshapefile.zip', 'fgdb.zip']:
    items = gis.content.search(f)
    print(items)
    if len(items) > 0:
        print(items[0].delete())
college__item = (gis
                 .content
                 .add({'title' : "French_Colleges", 
                       'type' : 'Shapefile', 
                       'tags' : "College, University"}, 
                 data=shapefile_data))
college__item__published = college__item.publish(publish_parameters={'name' : "FrenchColleges"})
college__item__published
traffic_published_item = (gis
                          .content
                          .add({'title' : "Traffic_Incidents", 
                                'type' : 'File Geodatabase', 
                                'tags' : "Traffic, Crash"}, 
                               data=fgdb_data,
                              thumbnail="./data/car_accidents.png")
                           .publish()
                         )
traffic_published_item<jupyter_output><empty_output><jupyter_text>3.  Create a Group and share the items with that group- Call the Group: `EuropeanDevTutorial`- Add 10 members to the group- share the published item from question `2` to the group<jupyter_code>try:
    gis.groups.search("EuropeanDevTutorial")[0].delete()
except: pass
# insert code here
grp = gis.groups.create(title='EuropeanDevTutorial',
                        tags='erase, me',
                        description="European DevSummit Demo Group",)
grp
traffic_published_item.share(groups=[grp])
college__item__published.share(groups=[grp])
grp.add_users(gis.content.search("*")[:10])<jupyter_output><empty_output><jupyter_text>4. Create a Web Map and add the two layers to the map.    - Set the extent to: `-30498.37428577314,5490739.271321731,2376350.772357217,6469133.233371727`    - Ensure the extent is 3857    - use a dictionary data structure to do this        - Once added, turn on the legend.        - Change the `basemap` to light gray<jupyter_code>from arcgis.gis import GIS
gis = GIS()
m = gis.map()
m.add_layer?
m.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},
 'xmin': -30498.37428577314,
 'ymin': 5490739.271321731,
 'xmax': 2376350.772357217,
 'ymax': 6469133.233371727}
m.legend = True
m.basemap = 'gray'
m
m.add_layer(traffic_published_item)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11827956989247312, 'fraction_numerical': 0.07120023249055507, 'mean_word_length': 3.0541813898704357, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '491428', 'license': 'Apache-2.0', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1168, 'n_words': 238, 'path': '02. Managing Your Content/student_exercise/exercise_questions-answers.ipynb', 'repo_name': 'achapkowski/pythonworkshop', 'size': '3441'}