|
28 | 28 | },
|
29 | 29 | "outputs": [],
|
30 | 30 | "source": [
|
31 |
| - "df = pd.read_html(\"https://en.wikipedia.org/wiki/Number_of_guns_per_capita_by_country\")[2]" |
| 31 | + "df = pd.read_html(\"https://en.wikipedia.org/wiki/Number_of_guns_per_capita_by_country\")[3]" |
32 | 32 | ]
|
33 | 33 | },
|
34 | 34 | {
|
|
371 | 371 | "metadata": {
|
372 | 372 | "collapsed": false
|
373 | 373 | },
|
374 |
| - "outputs": [ |
375 |
| - { |
376 |
| - "name": "stderr", |
377 |
| - "output_type": "stream", |
378 |
| - "text": [ |
379 |
| - ":0: FutureWarning: IPython widgets are experimental and may change in the future.\n" |
380 |
| - ] |
381 |
| - } |
382 |
| - ], |
| 374 | + "outputs": [], |
383 | 375 | "source": [
|
384 | 376 | "from arcgis.gis import GIS\n",
|
385 | 377 | "from arcgis.lyr import FeatureCollection\n",
|
386 | 378 | "from arcgis.viz import MapView\n",
|
387 | 379 | "import json\n",
|
388 | 380 | "\n",
|
389 |
| - "gis = GIS(\"https://deldev.maps.arcgis.com\", \"demo_deldev\", \"P@ssw0rd\")" |
| 381 | + "gis = GIS(\"https://deldev.maps.arcgis.com\", \"demo_deldev\", \"P@ssword123\")" |
390 | 382 | ]
|
391 | 383 | },
|
392 | 384 | {
|
393 | 385 | "cell_type": "code",
|
394 | 386 | "execution_count": 11,
|
395 | 387 | "metadata": {
|
396 |
| - "collapsed": false |
| 388 | + "collapsed": true |
397 | 389 | },
|
398 | 390 | "outputs": [],
|
399 | 391 | "source": [
|
400 |
| - "path = \"content/features/analyze\"\n", |
401 |
| - "postdata = {\n", |
402 |
| - " \"f\": \"pjson\",\n", |
403 |
| - " \"text\" : df.to_csv(),\n", |
404 |
| - " \"filetype\" : \"csv\",\n", |
405 |
| - " \"analyzeParameters\" : {\n", |
406 |
| - " \"enableGlobalGeocoding\": \"true\",\n", |
407 |
| - " \"sourceLocale\":\"en-us\",\n", |
408 |
| - " \"locationType\":\"address\",\n", |
409 |
| - " \"sourceCountry\":\"\",\n", |
410 |
| - " \"sourceCountryHint\":\"\"\n", |
411 |
| - " }\n", |
412 |
| - "}\n", |
413 |
| - "\n", |
414 |
| - "\n", |
415 |
| - "res = gis._portal.con.post(path, postdata)\n", |
416 |
| - "#import json\n", |
417 |
| - "#json.dumps(res)\n", |
418 |
| - "res['publishParameters'].update({\"addressFields\":{\"CountryCode\":\"Country\"}})\n", |
419 |
| - "\n", |
420 |
| - "path = \"content/features/generate\"\n", |
421 |
| - "postdata = {\n", |
422 |
| - " \"f\": \"pjson\",\n", |
423 |
| - " \"text\" : df.to_csv(),\n", |
424 |
| - " \"filetype\" : \"csv\",\n", |
425 |
| - " \"publishParameters\" : json.dumps(res['publishParameters'])\n", |
426 |
| - "}\n", |
427 |
| - "\n", |
428 |
| - "res2014 = gis._portal.con.post(path, postdata, use_ordered_dict=True)\n", |
429 |
| - "#print(json.dumps(res2014))\n", |
430 |
| - "fc2014 = FeatureCollection(res2014['featureCollection']['layers'][0])" |
| 392 | + "fc = gis.content.import_data(df, {\"CountryCode\":\"Country\"})" |
431 | 393 | ]
|
432 | 394 | },
|
433 | 395 | {
|
|
460 | 422 | },
|
461 | 423 | "outputs": [],
|
462 | 424 | "source": [
|
463 |
| - "map.add_layer(fc2014)" |
| 425 | + "map.add_layer(fc)" |
464 | 426 | ]
|
465 | 427 | },
|
466 | 428 | {
|
|
476 | 438 | " \"tags\" : \"guns,violence\",\n",
|
477 | 439 | " \"snippet\": \" GSR Worldwide gun ownership\",\n",
|
478 | 440 | " \"description\": \"test description\",\n",
|
479 |
| - " \"text\": json.dumps({\"featureCollection\": {\"layers\": [ fc2014 ]}}),\n", |
| 441 | + " \"text\": json.dumps({\"featureCollection\": {\"layers\": [ fc ]}}),\n", |
480 | 442 | " \"type\": \"Feature Collection\",\n",
|
481 | 443 | " \"typeKeywords\": \"Data, Feature Collection, Singlelayer\",\n",
|
482 | 444 | " \"extent\" : \"-102.5272,-41.7886,172.5967,64.984\"\n",
|
483 | 445 | "}\n",
|
484 |
| - "item = gis.content.add(item_properties)\n" |
| 446 | + "\n", |
| 447 | + "item = gis.content.add(item_properties)" |
485 | 448 | ]
|
486 | 449 | },
|
487 | 450 | {
|
|
496 | 459 | "text/html": [
|
497 | 460 | "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
|
498 | 461 | " <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
|
499 |
| - " <a href='https://deldev.maps.arcgis.com/home/item.html?id=019ab56a1e7a45eead96270ba27c3949' target='_blank'>\n", |
| 462 | + " <a href='https://deldev.maps.arcgis.com/home/item.html?id=136ecf570f094c9a84f6e83521bbedf0' target='_blank'>\n", |
500 | 463 | " <img src='http://static.arcgis.com/images/desktopapp.png' class=\"itemThumbnail\">\n",
|
501 | 464 | " </a>\n",
|
502 | 465 | " </div>\n",
|
503 |
| - " \n", |
| 466 | + "\n", |
504 | 467 | " <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n",
|
505 |
| - " <a href='https://deldev.maps.arcgis.com/home/item.html?id=019ab56a1e7a45eead96270ba27c3949' target='_blank'><b>Worldwide gun ownership</b>\n", |
| 468 | + " <a href='https://deldev.maps.arcgis.com/home/item.html?id=136ecf570f094c9a84f6e83521bbedf0' target='_blank'><b>Worldwide gun ownership</b>\n", |
506 | 469 | " </a>\n",
|
507 | 470 | " <br> GSR Worldwide gun ownership<img src='http://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/features16.png' style=\"vertical-align:middle;\">Feature Collection by demo_deldev\n",
|
508 |
| - " <br>Last Modified: June 05, 2016\n", |
| 471 | + " <br>Last Modified: July 26, 2016\n", |
509 | 472 | " <br>0 comments, 0 views\n",
|
510 | 473 | " </div>\n",
|
511 | 474 | " </div>\n",
|
|
541 | 504 | "name": "python",
|
542 | 505 | "nbconvert_exporter": "python",
|
543 | 506 | "pygments_lexer": "ipython3",
|
544 |
| - "version": "3.5.1" |
| 507 | + "version": "3.4.4" |
545 | 508 | },
|
546 | 509 | "widgets": {
|
547 | 510 | "state": {},
|
|
0 commit comments