|
32 | 32 | "outputs": [],
|
33 | 33 | "source": [
|
34 | 34 | "from arcgis.gis import GIS\n",
|
35 |
| - "from arcgis.mapping.ogc import WMTSLayer, WMSLayer, OGCFeatureService\n", |
36 |
| - "from arcgis.mapping import WebMap\n", |
| 35 | + "from arcgis.mapping.layers import WMTSLayer, WMSLayer\n", |
| 36 | + "from arcgis.map import Map\n", |
37 | 37 | "\n",
|
38 | 38 | "gis = GIS(\"home\")"
|
39 | 39 | ]
|
40 | 40 | },
|
41 |
| - { |
42 |
| - "cell_type": "markdown", |
43 |
| - "metadata": {}, |
44 |
| - "source": [ |
45 |
| - "We can take a look at how many service types are supported by the `ogc` module in the Python API." |
46 |
| - ] |
47 |
| - }, |
48 |
| - { |
49 |
| - "cell_type": "code", |
50 |
| - "execution_count": 2, |
51 |
| - "metadata": {}, |
52 |
| - "outputs": [ |
53 |
| - { |
54 |
| - "data": { |
55 |
| - "text/plain": [ |
56 |
| - "['CSVLayer',\n", |
57 |
| - " 'GeoJSONLayer',\n", |
58 |
| - " 'GeoRSSLayer',\n", |
59 |
| - " 'KMLLayer',\n", |
60 |
| - " 'OGCCollection',\n", |
61 |
| - " 'OGCFeatureService',\n", |
62 |
| - " 'WMSLayer',\n", |
63 |
| - " 'WMTSLayer',\n", |
64 |
| - " '__all__',\n", |
65 |
| - " '__builtins__',\n", |
66 |
| - " '__cached__',\n", |
67 |
| - " '__doc__',\n", |
68 |
| - " '__file__',\n", |
69 |
| - " '__loader__',\n", |
70 |
| - " '__name__',\n", |
71 |
| - " '__package__',\n", |
72 |
| - " '__path__',\n", |
73 |
| - " '__spec__',\n", |
74 |
| - " '_base',\n", |
75 |
| - " '_csv',\n", |
76 |
| - " '_geojson',\n", |
77 |
| - " '_georss',\n", |
78 |
| - " '_kml',\n", |
79 |
| - " '_service',\n", |
80 |
| - " '_wms',\n", |
81 |
| - " 'wmts']" |
82 |
| - ] |
83 |
| - }, |
84 |
| - "execution_count": 2, |
85 |
| - "metadata": {}, |
86 |
| - "output_type": "execute_result" |
87 |
| - } |
88 |
| - ], |
89 |
| - "source": [ |
90 |
| - "from arcgis.mapping import ogc\n", |
91 |
| - "dir(ogc)" |
92 |
| - ] |
93 |
| - }, |
94 | 41 | {
|
95 | 42 | "cell_type": "markdown",
|
96 | 43 | "metadata": {},
|
|
245 | 192 | ],
|
246 | 193 | "source": [
|
247 | 194 | "m = gis.map()\n",
|
248 |
| - "m.add_layer(WMTSLayer(url=wmts_url))\n", |
| 195 | + "m.content.add(wmts_lyr)\n", |
249 | 196 | "m"
|
250 | 197 | ]
|
251 | 198 | },
|
|
271 | 218 | "print(webmap_item.title)"
|
272 | 219 | ]
|
273 | 220 | },
|
| 221 | + { |
| 222 | + "cell_type": "markdown", |
| 223 | + "metadata": {}, |
| 224 | + "source": [ |
| 225 | + "The ``get_data`` method retrieves the data associated with the Web Map item, and we can see it contains `operationalLayers` and `baseMap`." |
| 226 | + ] |
| 227 | + }, |
274 | 228 | {
|
275 | 229 | "cell_type": "code",
|
276 | 230 | "execution_count": 39,
|
|
489 | 443 | "cell_type": "markdown",
|
490 | 444 | "metadata": {},
|
491 | 445 | "source": [
|
492 |
| - "The ``get_data`` method retrieves the data associated with the WebMap item, and we can see it contains `operationalLayers` and `baseMap`." |
| 446 | + "We'll delete this web map since it's for illustration:" |
493 | 447 | ]
|
494 | 448 | },
|
495 | 449 | {
|
496 | 450 | "cell_type": "code",
|
497 |
| - "execution_count": 42, |
| 451 | + "execution_count": null, |
498 | 452 | "metadata": {},
|
499 | 453 | "outputs": [
|
500 |
| - { |
| 454 | + { |
501 | 455 | "data": {
|
502 | 456 | "text/plain": [
|
503 | 457 | "True"
|
|
509 | 463 | }
|
510 | 464 | ],
|
511 | 465 | "source": [
|
512 |
| - "webmap_item.delete()" |
| 466 | + "webmap_item.delete(permanent=True)" |
513 | 467 | ]
|
514 | 468 | },
|
515 | 469 | {
|
|
528 | 482 | "outputs": [],
|
529 | 483 | "source": [
|
530 | 484 | "import json\n",
|
531 |
| - "\n", |
| 485 | + "root_folder = gis.content.folders.get()\n", |
532 | 486 | "dictItemData = {\n",
|
533 | 487 | " 'title': 'World Imagery (Wayback)', \n",
|
534 | 488 | " 'tags': ['imagery', 'wayback', 'esri_imagery', 'community basemap', 'world', 'community', 'satellite', 'orthophotos', 'baseimagery', 'general availability', 'esri_basemap', 'aerial'], \n",
|
|
540 | 494 | " 'type': 'WMTS', \n",
|
541 | 495 | " 'typeKeywords': ['Data', 'OGC', 'Service', 'Web Map Tile Service']\n",
|
542 | 496 | " }\n",
|
543 |
| - "item = gis.content.add(item_properties=dictItemData, upload_size=2836)" |
544 |
| - ] |
545 |
| - }, |
546 |
| - { |
547 |
| - "cell_type": "markdown", |
548 |
| - "metadata": {}, |
549 |
| - "source": [ |
550 |
| - "Here, the `upload_size` is an optional parameter, specifying the minimum default value for the size of the file when uploading by parts (float. The default value is 1e7 bytes or ~10 MBs). For more info, please check [add](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.add)." |
| 497 | + "item = root_folder.add(item_properties=dictItemData).result()" |
551 | 498 | ]
|
552 | 499 | },
|
553 | 500 | {
|
|
707 | 654 | "Compared to the response of `get_data` retrieved from a WMTS Layer, we can see that that of a WMTS service serves as a subset to the former."
|
708 | 655 | ]
|
709 | 656 | },
|
| 657 | + { |
| 658 | + "cell_type": "markdown", |
| 659 | + "metadata": {}, |
| 660 | + "source": [ |
| 661 | + "We'll delete this:" |
| 662 | + ] |
| 663 | + }, |
710 | 664 | {
|
711 | 665 | "cell_type": "code",
|
712 |
| - "execution_count": 8, |
| 666 | + "execution_count": null, |
713 | 667 | "metadata": {},
|
714 |
| - "outputs": [ |
715 |
| - { |
| 668 | + "outputs": [{ |
716 | 669 | "data": {
|
717 | 670 | "text/plain": [
|
718 | 671 | "True"
|
719 | 672 | ]
|
720 | 673 | },
|
721 |
| - "execution_count": 8, |
| 674 | + "execution_count": 43, |
722 | 675 | "metadata": {},
|
723 | 676 | "output_type": "execute_result"
|
724 |
| - } |
725 |
| - ], |
| 677 | + }], |
726 | 678 | "source": [
|
727 |
| - "item.delete()" |
| 679 | + "item.delete(permanent=True)" |
728 | 680 | ]
|
729 | 681 | },
|
730 | 682 | {
|
|
883 | 835 | ],
|
884 | 836 | "source": [
|
885 | 837 | "m1 = gis.map()\n",
|
886 |
| - "m1.add_layer(wms_lyr)\n", |
| 838 | + "m1.content.add(wms_lyr)\n", |
887 | 839 | "m1"
|
888 | 840 | ]
|
889 | 841 | },
|
|
923 | 875 | " 'type': 'WMS', \n",
|
924 | 876 | " 'typeKeywords': ['Data', 'OGC', 'Service', 'Web Map Service']\n",
|
925 | 877 | " }\n",
|
926 |
| - "wms_item = gis.content.add(item_properties=dictItemData)\n", |
| 878 | + "wms_item = root_folder.add(item_properties=dictItemData).result()\n", |
927 | 879 | "wms_item.type"
|
928 | 880 | ]
|
929 | 881 | },
|
|
993 | 945 | }
|
994 | 946 | ],
|
995 | 947 | "source": [
|
996 |
| - "wms_item.delete()" |
| 948 | + "wms_item.delete(permanent=True)" |
997 | 949 | ]
|
998 | 950 | },
|
999 | 951 | {
|
|
1015 | 967 | "source": [
|
1016 | 968 | "### WFS Service\n",
|
1017 | 969 | "\n",
|
1018 |
| - "For example, the `West Virginia Geological and Economic Survey (WVGES)`, which investigates and reports on West Virginia's geology and disseminates information, provides `WFS` endpoints at [WFS GetCapabilities](https://atlas2.wvgs.wvnet.edu/server/services/Hosted/Reference_Quadrangles/MapServer/WFSServer?request=GetCapabilities&service=WFS). With the WFS data support, we can see a simple example below that query the `Reference Boundaries for the State of West Virginia: 3.75' Quarter Quadrangles, 7.5' Quadrangles, 15' Quadrangles, 100k Quadrangles, 250k Quadrangles` layer to create WFS service, and add to a WebMap item:" |
| 970 | + "For example, the `West Virginia Geological and Economic Survey (WVGES)`, which investigates and reports on West Virginia's geology and disseminates information, provides `WFS` endpoints at [WFS GetCapabilities](https://atlas2.wvgs.wvnet.edu/server/services/Hosted/Reference_Quadrangles/MapServer/WFSServer?request=GetCapabilities&service=WFS). With the WFS data support, we can see a simple example below that queries the `Reference Boundaries for the State of West Virginia: 3.75' Quarter Quadrangles, 7.5' Quadrangles, 15' Quadrangles, 100k Quadrangles, 250k Quadrangles` layer to create a WFS service, and then add it to a Web Map item:" |
1019 | 971 | ]
|
1020 | 972 | },
|
1021 | 973 | {
|
|
1154 | 1106 | "cell_type": "markdown",
|
1155 | 1107 | "metadata": {},
|
1156 | 1108 | "source": [
|
1157 |
| - "Then, use the `add(item_properties, data=None, thumbnail=None, metadata=None, owner=None, folder=None, item_id=None, **kwargs)` method defined in `arcgis.gis` module to add content to the GIS by creating an `WFS` service, with parameters set as:\n", |
1158 |
| - " - item_properties: Required dictionary. See [table](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.add) for the keys and values." |
| 1109 | + "Then, use the [`add()`](/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis._impl._content_manager.Folder.add) method on a [_Folder_](/python/latest/api-reference/arcgis.gis.toc.html#folder) object to add content to the GIS by creating an `WFS` service. The _item_properties_ argument can be an [ItemProperties](/python/api-reference/arcgis.gis.toc.html#arcgis.gis._impl._dataclasses.ItemProperties) object or a dictionary you create. \n", |
| 1110 | + "See the [Items and item types](/rest/users-groups-and-items/items-and-item-types/) rest documentation for detailed description on various items, and the [addItem](/rest/users-groups-and-items/add-item/#request-parameters) documentation for detailed descriptions of the properties." |
1159 | 1111 | ]
|
1160 | 1112 | },
|
1161 | 1113 | {
|
|
1188 | 1140 | " 'type': 'WFS', \n",
|
1189 | 1141 | " 'typeKeywords': ['Data', 'OGC', 'Service', 'Web Feature Service']\n",
|
1190 | 1142 | " }\n",
|
1191 |
| - "wfs_item = gis.content.add(item_properties=dictItemData)\n", |
| 1143 | + "\n", |
| 1144 | + "root_folder = gis.content.folders.get()\n", |
| 1145 | + "wfs_item = root_folder.add(item_properties=dictItemData).result()\n", |
1192 | 1146 | "wfs_item.type "
|
1193 | 1147 | ]
|
1194 | 1148 | },
|
|
1212 | 1166 | "wfs_item.get_data()['layerType']"
|
1213 | 1167 | ]
|
1214 | 1168 | },
|
1215 |
| - { |
1216 |
| - "cell_type": "code", |
1217 |
| - "execution_count": 16, |
1218 |
| - "metadata": {}, |
1219 |
| - "outputs": [ |
1220 |
| - { |
1221 |
| - "data": { |
1222 |
| - "text/plain": [ |
1223 |
| - "True" |
1224 |
| - ] |
1225 |
| - }, |
1226 |
| - "execution_count": 16, |
1227 |
| - "metadata": {}, |
1228 |
| - "output_type": "execute_result" |
1229 |
| - } |
1230 |
| - ], |
1231 |
| - "source": [ |
1232 |
| - "wfs_item.delete()" |
1233 |
| - ] |
1234 |
| - }, |
1235 | 1169 | {
|
1236 | 1170 | "cell_type": "markdown",
|
1237 | 1171 | "metadata": {},
|
|
1272 | 1206 | "metadata": {},
|
1273 | 1207 | "outputs": [],
|
1274 | 1208 | "source": [
|
1275 |
| - "wfs_item = gis.content.add(\n", |
| 1209 | + "wfs_item = root_folder.add(\n", |
1276 | 1210 | " item_properties={\n",
|
1277 | 1211 | " \"title\": \"Sample WFS Map\",\n",
|
1278 | 1212 | " \"type\": \"Web Map\",\n",
|
1279 | 1213 | " \"tags\": \"erase, me\",\n",
|
1280 | 1214 | " \"text\": json.dumps(wm2),\n",
|
1281 | 1215 | " }\n",
|
1282 |
| - " )" |
| 1216 | + " ).result()" |
1283 | 1217 | ]
|
1284 | 1218 | },
|
1285 | 1219 | {
|
|
1295 | 1229 | "metadata": {},
|
1296 | 1230 | "outputs": [],
|
1297 | 1231 | "source": [
|
1298 |
| - "wm_obj2 = WebMap(wfs_item)\n", |
| 1232 | + "wm_obj2 = Map(item=wfs_item)\n", |
1299 | 1233 | "printed_file_url = wm_obj2.print(file_format='JPG', \n",
|
1300 | 1234 | " extent={\"xmin\":-10909090.288200358,\"ymin\":2331023.6145840986,\"xmax\":-6203015.330739876,\"ymax\":6401142.496712082,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}})"
|
1301 | 1235 | ]
|
|
1324 | 1258 | "Image(printed_file_url)"
|
1325 | 1259 | ]
|
1326 | 1260 | },
|
1327 |
| - { |
1328 |
| - "cell_type": "code", |
1329 |
| - "execution_count": 42, |
1330 |
| - "metadata": {}, |
1331 |
| - "outputs": [ |
1332 |
| - { |
1333 |
| - "data": { |
1334 |
| - "text/plain": [ |
1335 |
| - "True" |
1336 |
| - ] |
1337 |
| - }, |
1338 |
| - "execution_count": 42, |
1339 |
| - "metadata": {}, |
1340 |
| - "output_type": "execute_result" |
1341 |
| - } |
1342 |
| - ], |
1343 |
| - "source": [ |
1344 |
| - "wfs_item.delete()" |
1345 |
| - ] |
1346 |
| - }, |
1347 | 1261 | {
|
1348 | 1262 | "cell_type": "markdown",
|
1349 | 1263 | "metadata": {},
|
|
1372 | 1286 | "name": "python",
|
1373 | 1287 | "nbconvert_exporter": "python",
|
1374 | 1288 | "pygments_lexer": "ipython3",
|
1375 |
| - "version": "3.7.11" |
| 1289 | + "version": "3.11.10" |
1376 | 1290 | }
|
1377 | 1291 | },
|
1378 | 1292 | "nbformat": 4,
|
1379 |
| - "nbformat_minor": 2 |
| 1293 | + "nbformat_minor": 4 |
1380 | 1294 | }
|
0 commit comments