Skip to content

Commit 0594843

Browse files
author
Atma Mani
committed
geom part 3 - wip
1 parent 7e7c0fe commit 0594843

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

guide/15-working-with-geometries/part3_spatial_operations_on_geometries.ipynb

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Guide to arcgis.geometry module (Part 2)"
7+
"# Part 3: Spatial operations on geometries"
88
]
99
},
1010
{
1111
"cell_type": "markdown",
12-
"metadata": {
13-
"toc": true
14-
},
12+
"metadata": {},
1513
"source": [
16-
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
17-
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Spatial-Operations\" data-toc-modified-id=\"Spatial-Operations-1\">Spatial Operations</a></span><ul class=\"toc-item\"><li><span><a href=\"#a.-OOP-Pattern\" data-toc-modified-id=\"a.-OOP-Pattern-1.1\">a. OOP Pattern</a></span><ul class=\"toc-item\"><li><span><a href=\"#a1.-Union\" data-toc-modified-id=\"a1.-Union-1.1.1\">a1. Union</a></span></li><li><span><a href=\"#a2.-Difference\" data-toc-modified-id=\"a2.-Difference-1.1.2\">a2. Difference</a></span></li><li><span><a href=\"#a3.-Symmetric-difference\" data-toc-modified-id=\"a3.-Symmetric-difference-1.1.3\">a3. Symmetric difference</a></span></li><li><span><a href=\"#a4.-intersect()-V.S.-overlaps()\" data-toc-modified-id=\"a4.-intersect()-V.S.-overlaps()-1.1.4\">a4. intersect() V.S. overlaps()</a></span></li><li><span><a href=\"#a5.-Equals\" data-toc-modified-id=\"a5.-Equals-1.1.5\">a5. Equals</a></span></li><li><span><a href=\"#a6.-generalize()-V.S.-buffer()\" data-toc-modified-id=\"a6.-generalize()-V.S.-buffer()-1.1.6\">a6. generalize() V.S. buffer()</a></span></li><li><span><a href=\"#a7.-Find-the-nearest-point\" data-toc-modified-id=\"a7.-Find-the-nearest-point-1.1.7\">a7. Find the nearest point</a></span></li><li><span><a href=\"#a8.-contains()\" data-toc-modified-id=\"a8.-contains()-1.1.8\">a8. contains()</a></span></li><li><span><a href=\"#a9.-Clip-a-geometry-object\" data-toc-modified-id=\"a9.-Clip-a-geometry-object-1.1.9\">a9. Clip a geometry object</a></span></li></ul></li><li><span><a href=\"#b.-Spatial-operations-called-from-arcgis.geometry.functions\" data-toc-modified-id=\"b.-Spatial-operations-called-from-arcgis.geometry.functions-1.2\">b. Spatial operations called from <code>arcgis.geometry.functions</code></a></span><ul class=\"toc-item\"><li><span><a href=\"#b1.-Union\" data-toc-modified-id=\"b1.-Union-1.2.1\">b1. Union</a></span></li><li><span><a href=\"#b2.-intersect()-V.S.-overlaps()\" data-toc-modified-id=\"b2.-intersect()-V.S.-overlaps()-1.2.2\">b2. intersect() V.S. overlaps()</a></span></li><li><span><a href=\"#b3.-Difference\" data-toc-modified-id=\"b3.-Difference-1.2.3\">b3. Difference</a></span></li><li><span><a href=\"#b4.-Symmetric-difference\" data-toc-modified-id=\"b4.-Symmetric-difference-1.2.4\">b4. Symmetric difference</a></span></li><li><span><a href=\"#b5.-Equals\" data-toc-modified-id=\"b5.-Equals-1.2.5\">b5. Equals</a></span></li><li><span><a href=\"#b6.-generalize()-V.S.-buffer()\" data-toc-modified-id=\"b6.-generalize()-V.S.-buffer()-1.2.6\">b6. generalize() V.S. buffer()</a></span></li><li><span><a href=\"#b7.-Distance\" data-toc-modified-id=\"b7.-Distance-1.2.7\">b7. Distance</a></span></li><li><span><a href=\"#b8.-Determine-the-spatial-relation-between-two-geometries\" data-toc-modified-id=\"b8.-Determine-the-spatial-relation-between-two-geometries-1.2.8\">b8. Determine the spatial relation between two geometries</a></span></li><li><span><a href=\"#b9.-Clip-a-geometry-object\" data-toc-modified-id=\"b9.-Clip-a-geometry-object-1.2.9\">b9. Clip a geometry object</a></span></li></ul></li></ul></li><li><span><a href=\"#Conclusions\" data-toc-modified-id=\"Conclusions-2\">Conclusions</a></span></li></ul></div>"
14+
"Previously, in <a href=\"./part1_introduction_what_is_geometry.ipynb\">Part 1</a> of this guide series to `arcgis.geometry` module, you have seen the introduction to the module and some foundational concepts. In <a href=\"part2_working_with_geometries.ipynb\">Part 2</a>, you learned how to create geometry objects, their properties, and how to work with one, including its interactions with map widgets. In this part, let's continue to explore spatial operations of geometry objects using two different usage patterns."
1815
]
1916
},
2017
{
2118
"cell_type": "markdown",
22-
"metadata": {},
19+
"metadata": {
20+
"toc": true
21+
},
2322
"source": [
24-
"Previously, in <a href=\"./guide_to_geometry_part1.ipynb\">Part 1</a> of this guide series to `arcgis.geometry` module, you have seen the introduction to the module, how to create geometry objects, what are the basic properties, and how to work with one, including its interactions with map widgets. Let's now continue to explore the spatial operations of geometry objects, and how to process through geometry services."
23+
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
24+
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Spatial-Operations\" data-toc-modified-id=\"Spatial-Operations-1\">Spatial Operations</a></span><ul class=\"toc-item\"><li><span><a href=\"#Two-patterns-of-applying-spatial-operations\" data-toc-modified-id=\"Two-patterns-of-applying-spatial-operations-1.1\">Two patterns of applying spatial operations</a></span></li><li><span><a href=\"#a.-OOP-Pattern\" data-toc-modified-id=\"a.-OOP-Pattern-1.2\">a. OOP Pattern</a></span><ul class=\"toc-item\"><li><span><a href=\"#a1.-Union\" data-toc-modified-id=\"a1.-Union-1.2.1\">a1. Union</a></span></li><li><span><a href=\"#a2.-Difference\" data-toc-modified-id=\"a2.-Difference-1.2.2\">a2. Difference</a></span></li><li><span><a href=\"#a3.-Symmetric-difference\" data-toc-modified-id=\"a3.-Symmetric-difference-1.2.3\">a3. Symmetric difference</a></span></li><li><span><a href=\"#a4.-intersect()-V.S.-overlaps()\" data-toc-modified-id=\"a4.-intersect()-V.S.-overlaps()-1.2.4\">a4. intersect() V.S. overlaps()</a></span></li><li><span><a href=\"#a5.-Equals\" data-toc-modified-id=\"a5.-Equals-1.2.5\">a5. Equals</a></span></li><li><span><a href=\"#a6.-generalize()-V.S.-buffer()\" data-toc-modified-id=\"a6.-generalize()-V.S.-buffer()-1.2.6\">a6. generalize() V.S. buffer()</a></span></li><li><span><a href=\"#a7.-Find-the-nearest-point\" data-toc-modified-id=\"a7.-Find-the-nearest-point-1.2.7\">a7. Find the nearest point</a></span></li><li><span><a href=\"#a8.-contains()\" data-toc-modified-id=\"a8.-contains()-1.2.8\">a8. contains()</a></span></li><li><span><a href=\"#a9.-Clip-a-geometry-object\" data-toc-modified-id=\"a9.-Clip-a-geometry-object-1.2.9\">a9. Clip a geometry object</a></span></li></ul></li><li><span><a href=\"#b.-Spatial-operations-called-from-arcgis.geometry.functions\" data-toc-modified-id=\"b.-Spatial-operations-called-from-arcgis.geometry.functions-1.3\">b. Spatial operations called from <code>arcgis.geometry.functions</code></a></span><ul class=\"toc-item\"><li><span><a href=\"#b1.-Union\" data-toc-modified-id=\"b1.-Union-1.3.1\">b1. Union</a></span></li><li><span><a href=\"#b2.-intersect()-V.S.-overlaps()\" data-toc-modified-id=\"b2.-intersect()-V.S.-overlaps()-1.3.2\">b2. intersect() V.S. overlaps()</a></span></li><li><span><a href=\"#b3.-Difference\" data-toc-modified-id=\"b3.-Difference-1.3.3\">b3. Difference</a></span></li><li><span><a href=\"#b4.-Symmetric-difference\" data-toc-modified-id=\"b4.-Symmetric-difference-1.3.4\">b4. Symmetric difference</a></span></li><li><span><a href=\"#b5.-Equals\" data-toc-modified-id=\"b5.-Equals-1.3.5\">b5. Equals</a></span></li><li><span><a href=\"#b6.-generalize()-V.S.-buffer()\" data-toc-modified-id=\"b6.-generalize()-V.S.-buffer()-1.3.6\">b6. generalize() V.S. buffer()</a></span></li><li><span><a href=\"#b7.-Distance\" data-toc-modified-id=\"b7.-Distance-1.3.7\">b7. Distance</a></span></li><li><span><a href=\"#b8.-Determine-the-spatial-relation-between-two-geometries\" data-toc-modified-id=\"b8.-Determine-the-spatial-relation-between-two-geometries-1.3.8\">b8. Determine the spatial relation between two geometries</a></span></li><li><span><a href=\"#b9.-Clip-a-geometry-object\" data-toc-modified-id=\"b9.-Clip-a-geometry-object-1.3.9\">b9. Clip a geometry object</a></span></li></ul></li></ul></li><li><span><a href=\"#Conclusions\" data-toc-modified-id=\"Conclusions-2\">Conclusions</a></span></li></ul></div>"
2525
]
2626
},
2727
{
@@ -34,9 +34,16 @@
3434
"\n",
3535
"Chained operations are even more powerful. For example, in order to identify food deserts within an urban area, the analysis might begin by performing a `union` operation to the service areas of grocery stores, farmer's markets, and food co-ops. Then, taking the `difference` between this single geometry of all services areas and that of a polygon delineating a neighborhood would reveal the areas within that neighborhood where access to healthy, whole foods may not exist.\n",
3636
"\n",
37-
"Usually there are two ways of performing spatial operations - (a) `Object Oriented Programming (OOP)` pattern - through creating an geometry object first, then calling methods off the geometry object, or (b) calling functions from `arcgis.geometry.functions` directly without initating any geometry objects, e.g. the `from_geo_coordinate_string` or `to_geo_coordinate_string` methods, which takes spatial data as input, analyzes the data, then produces output data that is the derivative of the analysis performed on the input data.\n",
3837
"\n",
39-
"The major difference between these two is that the OOP pattern uses local geom engines such as shapely or arcpy, while calling from functions will send geometries over to server using geometry service, which requires credits and is not performant for larger datasets. Users are recommended to only use (b) if they do not have access to either of the local engines. Further more, if you want to process geometries on the server, rather than applying (b), you can also publish the data as feature service and then process as input data using `arcgis.feature` module."
38+
"### Two patterns of applying spatial operations\n",
39+
"There are two ways of performing spatial operations \n",
40+
"\n",
41+
"- (a) `Object Oriented Programming (OOP)` pattern - here you create a geometry object first, then call methods off the geometry object, and \n",
42+
"- (b) calling functions from `arcgis.geometry.functions` directly without initiating any geometry objects, e.g. the `from_geo_coordinate_string` or `to_geo_coordinate_string` methods, which takes spatial data as input, analyzes the data, then produces output data that is the derivative of the analysis performed on the input data.\n",
43+
"\n",
44+
"The major difference between these two is that the **OOP pattern uses local geometry engines** such as `shapely` or `arcpy`, while calling **functions from `arcgis.geometry.functions` will use server-side geometry engine** by sending the geometries over to the [Geometry Service](https://developers.arcgis.com/rest/services-reference/geometry-service.htm) configured with your web GIS server. If your web GIS is ArcGIS Online, the latter pattern requires credits. Further, the latter pattern is not performant for larger datasets. Users are recommended to only use (b) if they do not have access to either of the local geometry engines. Further more, if you want to process geometries on the server, rather than applying (b), you can also publish the data as feature service and then run analyses using `arcgis.feature` module.\n",
45+
"\n",
46+
"The rest of this page demonstrates a set of spatial operations performed using both these patterns."
4047
]
4148
},
4249
{
@@ -57,7 +64,7 @@
5764
"from arcgis.gis import GIS\n",
5865
"from arcgis.geometry import Polygon, Geometry, Point, Polyline\n",
5966
"from arcgis.geocoding import geocode\n",
60-
"import arcpy"
67+
"# import arcpy"
6168
]
6269
},
6370
{
@@ -66,7 +73,7 @@
6673
"metadata": {},
6774
"outputs": [],
6875
"source": [
69-
"gis = GIS(\"https://www.arcgis.com\", \"arcgis_python\", \"P@ssword123\", verify_cert=False)"
76+
"gis = GIS(profile='your_online_profile')"
7077
]
7178
},
7279
{
@@ -362,16 +369,21 @@
362369
"\n",
363370
"Next, you will see the difference between these two spatial operations:\n",
364371
" - `generalize(max_offset)` - Creates a new simplified geometry using a specified maximum offset tolerance (as shown in Figs 1 and 2). The result of the `generalize()` operation against a polyline object is a new polyline, while that against a polygon object is a new polygon.\n",
365-
" - `buffer(distance)` - Constructs a polygon at a specified distance from the geometry. The buffering process merges buffer polygons that overlap. Negative distances greater than one-half the maximum interior width of a polygon result in an empty geometry. Illustration of `buffer()` operations against different geomtry types can be found in Fig 3, which also shows that results of `buffer()` are always polygon objects.\n",
366-
" \n",
372+
" - `buffer(distance)` - Constructs a polygon at a specified distance from the geometry. The buffering process merges buffer polygons that overlap. Negative distances greater than one-half the maximum interior width of a polygon result in an empty geometry. Illustration of `buffer()` operations against different geomtry types can be found in Fig 3, which also shows that results of `buffer()` are always polygon objects."
373+
]
374+
},
375+
{
376+
"cell_type": "markdown",
377+
"metadata": {},
378+
"source": [
367379
"<img src=\"https://desktop.arcgis.com/en/arcmap/10.3/tools/editing-toolbox/GUID-BA4E50F7-938B-4695-9E96-B9C3B7B96365-web.gif\" />\n",
368-
"<h5><center>Fig 1. Generialize operation against a polyline object (Source: <a href=\"https://desktop.arcgis.com/en/arcmap/10.3/tools/editing-toolbox/generalize.htm\">ArcMap Toolbox Help</a>)</center></h5>\n",
380+
"<b><center>Fig 1. Generialize operation against a polyline object (Source: <a href=\"https://desktop.arcgis.com/en/arcmap/10.3/tools/editing-toolbox/generalize.htm\">ArcMap Toolbox Help</a>)</center></b>\n",
369381
" \n",
370382
"<img src=\"https://desktop.arcgis.com/en/arcmap/latest/tools/cartography-toolbox/GUID-128637E4-C21F-436E-9D37-62741C3B9E93-web.png\" />\n",
371-
"<h5><center>Fig 2. Generialize operation against a polygon object (Source: <a href=\"https://desktop.arcgis.com/en/arcmap/latest/tools/cartography-toolbox/simplify-polygon.htm\">ArcMap Toolset Help</a>)</center></h5>\n",
383+
"<b><center>Fig 2. Generialize operation against a polygon object (Source: <a href=\"https://desktop.arcgis.com/en/arcmap/latest/tools/cartography-toolbox/simplify-polygon.htm\">ArcMap Toolset Help</a>)</center><b>\n",
372384
" \n",
373385
"<img src=\"http://webhelp.esri.com/arcgisdesktop/9.2/published_images/ST_Buffer.gif\" />\n",
374-
"<h5><center>Fig 3. Buffer operation (Source: <a href=\"http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=Spatial_operations\">ArcGIS Desktop Help</a>)</center></h5>"
386+
"<b><center>Fig 3. Buffer operation (Source: <a href=\"http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=Spatial_operations\">ArcGIS Desktop Help</a>)</center></b>"
375387
]
376388
},
377389
{
@@ -2185,9 +2197,14 @@
21852197
"title_cell": "Table of Contents",
21862198
"title_sidebar": "Contents",
21872199
"toc_cell": true,
2188-
"toc_position": {},
2200+
"toc_position": {
2201+
"height": "calc(100% - 180px)",
2202+
"left": "10px",
2203+
"top": "150px",
2204+
"width": "364.2px"
2205+
},
21892206
"toc_section_display": true,
2190-
"toc_window_display": false
2207+
"toc_window_display": true
21912208
},
21922209
"varInspector": {
21932210
"cols": {

0 commit comments

Comments
 (0)