Skip to content

Commit e9d3b4a

Browse files
authored
Merge pull request #2136 from Esri/NA/guides_16
Update OGC Sample
2 parents 17d9f0e + eb09685 commit e9d3b4a

File tree

1 file changed

+42
-128
lines changed

1 file changed

+42
-128
lines changed

samples/05_content_publishers/publish_ogc_services.ipynb

Lines changed: 42 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,12 @@
3232
"outputs": [],
3333
"source": [
3434
"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",
3737
"\n",
3838
"gis = GIS(\"home\")"
3939
]
4040
},
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-
},
9441
{
9542
"cell_type": "markdown",
9643
"metadata": {},
@@ -245,7 +192,7 @@
245192
],
246193
"source": [
247194
"m = gis.map()\n",
248-
"m.add_layer(WMTSLayer(url=wmts_url))\n",
195+
"m.content.add(wmts_lyr)\n",
249196
"m"
250197
]
251198
},
@@ -271,6 +218,13 @@
271218
"print(webmap_item.title)"
272219
]
273220
},
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+
},
274228
{
275229
"cell_type": "code",
276230
"execution_count": 39,
@@ -489,15 +443,15 @@
489443
"cell_type": "markdown",
490444
"metadata": {},
491445
"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:"
493447
]
494448
},
495449
{
496450
"cell_type": "code",
497-
"execution_count": 42,
451+
"execution_count": null,
498452
"metadata": {},
499453
"outputs": [
500-
{
454+
{
501455
"data": {
502456
"text/plain": [
503457
"True"
@@ -509,7 +463,7 @@
509463
}
510464
],
511465
"source": [
512-
"webmap_item.delete()"
466+
"webmap_item.delete(permanent=True)"
513467
]
514468
},
515469
{
@@ -528,7 +482,7 @@
528482
"outputs": [],
529483
"source": [
530484
"import json\n",
531-
"\n",
485+
"root_folder = gis.content.folders.get()\n",
532486
"dictItemData = {\n",
533487
" 'title': 'World Imagery (Wayback)', \n",
534488
" 'tags': ['imagery', 'wayback', 'esri_imagery', 'community basemap', 'world', 'community', 'satellite', 'orthophotos', 'baseimagery', 'general availability', 'esri_basemap', 'aerial'], \n",
@@ -540,14 +494,7 @@
540494
" 'type': 'WMTS', \n",
541495
" 'typeKeywords': ['Data', 'OGC', 'Service', 'Web Map Tile Service']\n",
542496
" }\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()"
551498
]
552499
},
553500
{
@@ -707,24 +654,29 @@
707654
"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."
708655
]
709656
},
657+
{
658+
"cell_type": "markdown",
659+
"metadata": {},
660+
"source": [
661+
"We'll delete this:"
662+
]
663+
},
710664
{
711665
"cell_type": "code",
712-
"execution_count": 8,
666+
"execution_count": null,
713667
"metadata": {},
714-
"outputs": [
715-
{
668+
"outputs": [{
716669
"data": {
717670
"text/plain": [
718671
"True"
719672
]
720673
},
721-
"execution_count": 8,
674+
"execution_count": 43,
722675
"metadata": {},
723676
"output_type": "execute_result"
724-
}
725-
],
677+
}],
726678
"source": [
727-
"item.delete()"
679+
"item.delete(permanent=True)"
728680
]
729681
},
730682
{
@@ -883,7 +835,7 @@
883835
],
884836
"source": [
885837
"m1 = gis.map()\n",
886-
"m1.add_layer(wms_lyr)\n",
838+
"m1.content.add(wms_lyr)\n",
887839
"m1"
888840
]
889841
},
@@ -923,7 +875,7 @@
923875
" 'type': 'WMS', \n",
924876
" 'typeKeywords': ['Data', 'OGC', 'Service', 'Web Map Service']\n",
925877
" }\n",
926-
"wms_item = gis.content.add(item_properties=dictItemData)\n",
878+
"wms_item = root_folder.add(item_properties=dictItemData).result()\n",
927879
"wms_item.type"
928880
]
929881
},
@@ -993,7 +945,7 @@
993945
}
994946
],
995947
"source": [
996-
"wms_item.delete()"
948+
"wms_item.delete(permanent=True)"
997949
]
998950
},
999951
{
@@ -1015,7 +967,7 @@
1015967
"source": [
1016968
"### WFS Service\n",
1017969
"\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:"
1019971
]
1020972
},
1021973
{
@@ -1154,8 +1106,8 @@
11541106
"cell_type": "markdown",
11551107
"metadata": {},
11561108
"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."
11591111
]
11601112
},
11611113
{
@@ -1188,7 +1140,9 @@
11881140
" 'type': 'WFS', \n",
11891141
" 'typeKeywords': ['Data', 'OGC', 'Service', 'Web Feature Service']\n",
11901142
" }\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",
11921146
"wfs_item.type "
11931147
]
11941148
},
@@ -1212,26 +1166,6 @@
12121166
"wfs_item.get_data()['layerType']"
12131167
]
12141168
},
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-
},
12351169
{
12361170
"cell_type": "markdown",
12371171
"metadata": {},
@@ -1272,14 +1206,14 @@
12721206
"metadata": {},
12731207
"outputs": [],
12741208
"source": [
1275-
"wfs_item = gis.content.add(\n",
1209+
"wfs_item = root_folder.add(\n",
12761210
" item_properties={\n",
12771211
" \"title\": \"Sample WFS Map\",\n",
12781212
" \"type\": \"Web Map\",\n",
12791213
" \"tags\": \"erase, me\",\n",
12801214
" \"text\": json.dumps(wm2),\n",
12811215
" }\n",
1282-
" )"
1216+
" ).result()"
12831217
]
12841218
},
12851219
{
@@ -1295,7 +1229,7 @@
12951229
"metadata": {},
12961230
"outputs": [],
12971231
"source": [
1298-
"wm_obj2 = WebMap(wfs_item)\n",
1232+
"wm_obj2 = Map(item=wfs_item)\n",
12991233
"printed_file_url = wm_obj2.print(file_format='JPG', \n",
13001234
" extent={\"xmin\":-10909090.288200358,\"ymin\":2331023.6145840986,\"xmax\":-6203015.330739876,\"ymax\":6401142.496712082,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}})"
13011235
]
@@ -1324,26 +1258,6 @@
13241258
"Image(printed_file_url)"
13251259
]
13261260
},
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-
},
13471261
{
13481262
"cell_type": "markdown",
13491263
"metadata": {},
@@ -1372,9 +1286,9 @@
13721286
"name": "python",
13731287
"nbconvert_exporter": "python",
13741288
"pygments_lexer": "ipython3",
1375-
"version": "3.7.11"
1289+
"version": "3.11.10"
13761290
}
13771291
},
13781292
"nbformat": 4,
1379-
"nbformat_minor": 2
1293+
"nbformat_minor": 4
13801294
}

0 commit comments

Comments
 (0)