Skip to content

Commit f0b6e6e

Browse files
authored
Merge pull request #1610 from mbana641/meg10359/arcgis-knowledge-guides
Knowledge Graph guides in _Administration -> Managing ArcGIS applications_.
2 parents 240aaf2 + 4754367 commit f0b6e6e

File tree

3 files changed

+1054
-0
lines changed

3 files changed

+1054
-0
lines changed
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"# Introduction to Knowledge Graphs"
9+
]
10+
},
11+
{
12+
"attachments": {},
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
17+
"<div class=\"toc\">\n",
18+
" <ul class=\"toc-item\">\n",
19+
" <li><span><a href=\"#Introduction\" data-toc-modified-id=\"Introduction-1\">Introduction</a></span>\n",
20+
" <ul>\n",
21+
" <li><span><a href=\"#What-is-a-knowledge-graph?\" data-toc-modified-id=\"What-is-a-knowledge-graph?-1.1\">What is a knowledge graph?</a></span></li>\n",
22+
" <li><span><a href=\"#Key-Terms\" data-toc-modified-id=\"Key-Terms-1.2\">Key Terms</a></span></li>\n",
23+
" </ul>\n",
24+
" </li>\n",
25+
" <li><span><a href=\"#Connect\" data-toc-modified-id=\"Connect-2\">Connect</a></span></li>\n",
26+
" <li><span><a href=\"#Data-Model\" data-toc-modified-id=\"Data-Model-3\">Data Model</a></span></li>\n",
27+
" <li><span><a href=\"#Path-Forward\" data-toc-modified-id=\"Path-Forward-4\">Path Forward</a></span></li>\n",
28+
" </ul>\n",
29+
"</div>"
30+
]
31+
},
32+
{
33+
"attachments": {},
34+
"cell_type": "markdown",
35+
"metadata": {},
36+
"source": [
37+
"## Introduction\n",
38+
"\n",
39+
"ArcGIS Knowledge integrates graph and spatial analytics to support data discovery, collaborative investigations, link analysis, and information sharing across organizations. An ArcGIS Enterprise portal configured for ArcGIS Knowledge is required. Find out more at [Configure ArcGIS Knowledge](https://enterprise.arcgis.com/en/knowledge/latest/introduction/configure-arcgis-knowledge.htm)\n",
40+
"\n",
41+
"In order to use the [`arcgis.graph`](https://developers.arcgis.com/python/api-reference/arcgis.graph.html) capabilities in the ArcGIS API for Python, you must have an existing knowledge graph. Learn more about [creating knowledge graphs](https://pro.arcgis.com/en/pro-app/latest/help/data/knowledge/create-an-investigation-in-a-project.htm)."
42+
]
43+
},
44+
{
45+
"attachments": {},
46+
"cell_type": "markdown",
47+
"metadata": {},
48+
"source": [
49+
"### What is a knowledge graph?\n",
50+
"A knowledge graph consists of entities and the relationships between them. Each of these entities and relationships can also have properties that contain information describing the entity or relationship. Entities in the model represent real-world objects, concepts, or events. Relationships in the model express how entities are associated with each other. \n",
51+
"\n",
52+
"### Key Terms\n",
53+
"A few key terms to understand are:\n",
54+
"- Knowledge Graph: A network that connects people, places, things, and events with each other through relationships.\n",
55+
"- Data Model: Defines the types of entities and relationships that can exist in the knowledge graph along with their properties.\n",
56+
"- Entity: Representation of a specific thing in the graph such as a person, building, vehicle, etc. These can have any number of properties and be either spatial or nonspatial.\n",
57+
"- Relationship: Connects two entities in the graph and represents their relationship such as knows, works_at, drives, etc. These can have any number of properties and are nonspatial.\n",
58+
"- Properties: key-value pairs that describe the entity or relationships such as name, start_date, make, model, etc."
59+
]
60+
},
61+
{
62+
"attachments": {},
63+
"cell_type": "markdown",
64+
"metadata": {},
65+
"source": [
66+
"## Connect\n",
67+
"\n",
68+
"Using the ArcGIS API for Python, you can connect to a `KnowledgeGraph` with `arcgis.graph`:"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"metadata": {},
75+
"outputs": [],
76+
"source": [
77+
"from arcgis.gis import GIS\n",
78+
"from arcgis.graph import KnowledgeGraph\n",
79+
"\n",
80+
"url = \"https://myHostName.domain.com/server/rest/services/Hosted/myServiceName/KnowledgeGraphServer\"\n",
81+
"gis = GIS(\"home\")\n",
82+
"knowledge_graph = KnowledgeGraph(url=url, gis=gis)"
83+
]
84+
},
85+
{
86+
"attachments": {},
87+
"cell_type": "markdown",
88+
"metadata": {},
89+
"source": [
90+
"A knowledge graph service is composed of two primary resources, the data and data model. The data contains entities and relationships with their associated properties. "
91+
]
92+
},
93+
{
94+
"attachments": {},
95+
"cell_type": "markdown",
96+
"metadata": {},
97+
"source": [
98+
"## Data Model\n",
99+
"\n",
100+
"The data model defines the schema of the knowledge graph by defining the entity types and relationship types in the graph:"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"metadata": {},
107+
"outputs": [],
108+
"source": [
109+
"knowledge_graph.datamodel"
110+
]
111+
},
112+
{
113+
"attachments": {},
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"The response from `datamodel` has many useful components that describe the schema of the knowledge graph. Important information to look for on the data model includes spatial reference, strictness, whether the service is arcgis managed, information on the unique identifier property, and search indexes. The data model also includes detailed information on each entity and relationship type.\n",
118+
"\n",
119+
"```\n",
120+
"{'data_model_timestamp': datetime.datetime(2023, 3, 22, 14, 4, 44, 432000),\n",
121+
" 'spatial_reference': {'wkid': 4326},\n",
122+
" 'entity_types': <dictionary of entity types>, # see below for more info on type dictionaries\n",
123+
" 'relationship_types': <dictionary of relationship types>, # see below for more info on type dictionaries\n",
124+
" 'strict': False,\n",
125+
" 'objectid_property': 'objectid',\n",
126+
" 'globalid_property': 'globalid',\n",
127+
" 'arcgis_managed': True,\n",
128+
" 'identifier_info': {'identifier_mapping_info': {'uniform_property': {'identifier_property_name': 'globalid'}},\n",
129+
" 'identifier_generation_info': {'uuid_method_hint': 'esriUUIDESRI'}},\n",
130+
" 'search_indexes': {'esri__search_idx': {'name': 'esri__search_idx',\n",
131+
" 'supported_category': 'Both',\n",
132+
" 'analyzers': [{'name': 'text_en'}, {'name': 'identity'}],\n",
133+
" 'search_properties': {'Document': {'property_names': ['metadata',\n",
134+
" 'keywords',\n",
135+
" 'fileExtension',\n",
136+
" 'globalid',\n",
137+
" 'name',\n",
138+
" 'text',\n",
139+
" 'title',\n",
140+
" 'contentType',\n",
141+
" 'url']},\n",
142+
" 'HasDocument': {'property_names': ['globalid']},\n",
143+
" 'Observation': {'property_names': ['quality_grade',\n",
144+
" 'globalid',\n",
145+
" 'time_observed',\n",
146+
" 'description',\n",
147+
" 'location',\n",
148+
" 'observation_url',\n",
149+
" 'photo_url',\n",
150+
" 'species_guess',\n",
151+
" 'most_disagree_with_identificati',\n",
152+
" 'place_guess']},\n",
153+
" 'Observed': {'property_names': ['globalid']},\n",
154+
" 'ObservedIn': {'property_names': ['globalid']},\n",
155+
" 'Reviewed': {'property_names': ['globalid']},\n",
156+
" 'Species': {'property_names': ['taxon_common_name',\n",
157+
" 'globalid',\n",
158+
" 'taxon_name',\n",
159+
" 'taxon_wikipedia',\n",
160+
" 'taxon_photo_url']},\n",
161+
" 'User': {'property_names': ['globalid', 'name', 'created_date']}}}}}\n",
162+
"```\n",
163+
"\n",
164+
"Entity and relationship types each have a format very similar to each other including basic information about the type like the name, role and strictness as well as properties and field indexes on the type. For a single type, this could look like:\n",
165+
"```\n",
166+
"{'Company': {\n",
167+
" 'name': 'Company',\n",
168+
" 'alias': '',\n",
169+
" 'role': 'esriGraphNamedObjectRegular',\n",
170+
" 'strict': False,\n",
171+
" 'properties': {\n",
172+
" 'name': {\n",
173+
" 'name': 'name',\n",
174+
" 'alias': 'name',\n",
175+
" 'fieldType': 'esriFieldTypeString',\n",
176+
" 'hasZ': False,\n",
177+
" 'hasM': False,\n",
178+
" 'nullable': True,\n",
179+
" 'editable': True,\n",
180+
" 'visible': True,\n",
181+
" 'required': False,\n",
182+
" 'isSystemMaintained': False,\n",
183+
" 'role': 'esriGraphPropertyRegular'\n",
184+
" },\n",
185+
" 'objectid': {\n",
186+
" 'name': 'objectid',\n",
187+
" 'alias': 'objectid',\n",
188+
" 'fieldType': 'esriFieldTypeOID',\n",
189+
" 'hasZ': False,\n",
190+
" 'hasM': False,\n",
191+
" 'nullable': False,\n",
192+
" 'editable': False,\n",
193+
" 'visible': True,\n",
194+
" 'required': True,\n",
195+
" 'isSystemMaintained': True,\n",
196+
" 'role': 'esriGraphPropertyRegular'\n",
197+
" },\n",
198+
" 'globalid': {\n",
199+
" 'name': 'globalid',\n",
200+
" 'alias': 'globalid',\n",
201+
" 'fieldType': 'esriFieldTypeGlobalID',\n",
202+
" 'hasZ': False,\n",
203+
" 'hasM': False,\n",
204+
" 'nullable': False,\n",
205+
" 'editable': False,\n",
206+
" 'visible': True,\n",
207+
" 'required': True,\n",
208+
" 'isSystemMaintained': True,\n",
209+
" 'role': 'esriGraphPropertyRegular'\n",
210+
" },\n",
211+
" 'shape': {\n",
212+
" 'name': 'shape',\n",
213+
" 'alias': 'shape',\n",
214+
" 'fieldType': 'esriFieldTypeGeometry',\n",
215+
" 'geometryType': 'esriGeometryPoint',\n",
216+
" 'hasZ': False,\n",
217+
" 'hasM': False,\n",
218+
" 'nullable': True,\n",
219+
" 'editable': True,\n",
220+
" 'visible': True,\n",
221+
" 'required': False,\n",
222+
" 'isSystemMaintained': False,\n",
223+
" 'role': 'esriGraphPropertyRegular'\n",
224+
" }\n",
225+
" },\n",
226+
" 'field_indexes': {\n",
227+
" 'esri__oid_idx': {\n",
228+
" 'name': 'esri__oid_idx',\n",
229+
" 'fields': ['objectid'],\n",
230+
" 'isAscending': True,\n",
231+
" 'isUnique': True\n",
232+
" },\n",
233+
" 'esri__globalid_idx': {\n",
234+
" 'name': 'esri__globalid_idx',\n",
235+
" 'fields': ['globalid'],\n",
236+
" 'isAscending': True,\n",
237+
" 'isUnique': True\n",
238+
" },\n",
239+
" 'esri__shape_geo_idx': {\n",
240+
" 'name': 'esri__shape_geo_idx',\n",
241+
" 'fields': ['shape'],\n",
242+
" 'isAscending': True,\n",
243+
" 'isUnique': False\n",
244+
" }\n",
245+
" }\n",
246+
"}\n",
247+
"```"
248+
]
249+
},
250+
{
251+
"attachments": {},
252+
"cell_type": "markdown",
253+
"metadata": {},
254+
"source": [
255+
"## Path Forward\n",
256+
"\n",
257+
"The knowledge graph can be used to <a href=\"part2-search-query-knowledge-graph.ipynb\">search and query a knowledge graph</a> as well as <a href=\"part3-edit-knowledge-graph.ipynb\">add, update and delete</a> types and instances of the data. These will help you to create and use your knowledge graphs."
258+
]
259+
}
260+
],
261+
"metadata": {
262+
"kernelspec": {
263+
"display_name": "Python 3",
264+
"language": "python",
265+
"name": "python3"
266+
},
267+
"language_info": {
268+
"name": "python",
269+
"version": "3.9.13"
270+
},
271+
"orig_nbformat": 4,
272+
"vscode": {
273+
"interpreter": {
274+
"hash": "d622b5871f1605057390dea3c8b45e995d0d19bef8604acd7f5b2e1066a85139"
275+
}
276+
}
277+
},
278+
"nbformat": 4,
279+
"nbformat_minor": 2
280+
}

0 commit comments

Comments
 (0)