From 83d790af3b550bd267a767551a1caeee908cb815 Mon Sep 17 00:00:00 2001 From: Huite Date: Thu, 22 Aug 2024 14:09:07 +0000 Subject: [PATCH] deploy: 875051f2eecbda56883978cb85824bc502f77662 --- .doctrees/api.doctree | Bin 81350 -> 81663 bytes .doctrees/environment.pickle | Bin 49061 -> 49182 bytes .doctrees/examples/sg_execution_times.doctree | Bin 8193 -> 8193 bytes .doctrees/examples/spatial_indexing.doctree | Bin 51409 -> 51416 bytes .doctrees/sg_execution_times.doctree | Bin 8202 -> 8202 bytes .../spatial_indexing.zip | Bin 29173 -> 27988 bytes .../examples_python.zip | Bin 12492 -> 11307 bytes .../spatial_indexing.py | 45 ++++++---- .../examples_jupyter.zip | Bin 16703 -> 16703 bytes _modules/numba_celltree/celltree.html | 3 + _sources/examples/sg_execution_times.rst.txt | 4 +- _sources/examples/spatial_indexing.rst.txt | 78 ++++++++++-------- _sources/sg_execution_times.rst.txt | 4 +- api.html | 2 + examples/sg_execution_times.html | 4 +- examples/spatial_indexing.html | 2 +- searchindex.js | 2 +- sg_execution_times.html | 4 +- 18 files changed, 87 insertions(+), 61 deletions(-) diff --git a/.doctrees/api.doctree b/.doctrees/api.doctree index d53a6c12a468c09fe5ef96727b1947d889785bd0..6c36aa2310f26a4aff4965ad34212b3d0d656781 100644 GIT binary patch delta 2305 zcmcIlZETZO6yCY3E7*2(bdw)&25s{(JK1HR^KK`eBK`nioRgDLu`>A_HUL#-Tqd;v|03p(H;!?Lv85N zE&D?%D32+P$=c?aY}$1%-KPJG@5R`T*!I|b*%}D4VGX#W?OMYYb6T40Se1^-^=9h) zr41t7wvcQ$(-UzQz44?U_A1_VxmQbGH`DBq+5G37rz-f*)gc?L|J4H@s)$P!myz-u zZu5j)^virL*^T0YxzSTv4qDyiptn})NS~SAErUXO@?Z{raR2H77b zSd4zu*CLSXyq+qZ(Sq1N6Z}|NYz{OUZu2NC9&;S$g%mTp8MdwNtK27cmwQ6vAl3Ei{1{E@CJ8S#3FX6DzWl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_rE^WpBBBHlo#)%6MoU=$zeLshV^Clg(*=pwu^5Z?WFQ{jJgJdzLIkMi_s_+IX;u! NvRpmcuiCL0{{yJUAbbD- diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index 813086aa535ee9d619e604ef4cdde7af880e58ea..c5841dcdd7efd05dfe1577cd94e4484fd328569b 100644 GIT binary patch delta 1600 zcmZ`(Sxj7280O3jGfYKVih`8w7N(oAU=>DL%2I3rhbaMVC}5dhW-iR!&eoX$h8@xb z%VbDN|H~E=Dv8)2m7@1W4Vxw|v1nW#s%T@>7&W0ueZUwKQvY)<@aBE^&iDW4JKJ~u zb7vl^rux;9{gI<_tM5c!%88E=g1pP?6#Q8Zw@nC2VKwh{NU+e544>sZ9v6<>PABc^ z;PaenG78DYL^1(J<6$xm7mNvsk~$(noTBhEL6|`{DAh>fBn%smRgGcT8s2BId8}^U zC0GI;i_ZPKQ?-5hvic{C9~2a|H&KI1bANNjTAZ z!5XHx!gOe;kB6U57Q=MWDc}o>A-yOAW-O`j3-am0447?62EM2m-aMHB3(hq7wWzwB z855=1G2tL(%!EwJ=$XWP%9w5Clrh`RA!`k50v@Yh@mKCHP9ad)Xpommx+#g3Uo8Dr zA(^M6RWt)G(-GNM_C3q8;7WxO$S%{CqU|#Ot8{mn4PXgq<%O!Rm7eR>|0v|Om$tRD z=d^5IdA0T_6?$;LZVhhN#zLw+4(`=|L?rq3hPwn#Ifp^hSPls;19%%hfxH$E+R_Y< z+6{8n#YBQ6R<7gS3i+%gMX@4b>JjnCP9(3p>r`Y^&c6IW!<0CfUK}=bdTi*GVKWXTZIx+s zA46;#LrgZrR6|TOgqmAzHCRgz+j0?e+e;9;+UXPgqP+q!AxM#DI2SylWmWSPECjRZ z9Yu+oxGQ{QklRs)x`B??CW-rG3e~J;HzHm9^B8$ ztx8YdvRH!+J_27)0ZMKoj>ASzHgge=vhC6T9P@?VT>T$-OngzI1cSXf`0rTkt=0dz zn@jF1)c?L4S^LUxk-5GS{l<1~3^q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S(HrW??tLUEEhx%_ecH=onc!MI*}&09pAjUZ_|iYPziI26K`3 zm`(9v{))%cg}AXS0i5)=;*bLb>R+LN$o5HPtHp!H@KT8dnK-@lBxK=GX`!h5WYry0 zL@}q#f~V=WvOfUkQ~z_-PPTbm=}~0WGgWvASQx?*a)p8S21^V5_L=OvfkS zlC&82ZL#1zdUK0Gpr1J_6jejkblxYfiE?L+1w(YAX3B}#H3@Vwl*vZpWisA)CW~=d zE!#NyZf!DQE5}?p*>E(x-IvD{j66O}-@(`G%&rEN@xTyc{)L*I<#m zK)V{=1h~f~g2v8calBDJ+GLR_pc74F0QYe`bOM8~w+YPN;QPt)VRx6a9Jb&IS{wca z$ZUe+tWgH5-)B2ZVgk1F> z1gyu4T{?TFb){iq_j&N+m2O?~bMYYw$C5H}G>`(7IM`PxYHnHAqZPA^Y#!~gpo)@X zlOP4SO@o9>=g+1ykI!&G$TrfsFuDPHjN4CH&_u7Ex(d)7)vzzSeWzR^(=x{F)6c?g zT621~L)sJb+q1U|17}2Zo#`ODil3eNlK(^oHb4*F88`*U>7l{D9b!M1cVPM141B71 z2K3WQbTttN`RV2VPY0=Wu7Ci=@UQ}u4h^dSC+Wn82MCN{g*-p%XAMj}-#i_T Jaft7)Qp1Fn5=9^5nS(t$I SHufnzA{ItiRK$s_;RXQ77Z-j2 delta 82 zcmeBj=yKSQ$i!l7sHHVoidk`T8aft7)Qp1HB%=9^5nS(t$I SHufnzBF2VTRK$s_;RXQ1cNba! diff --git a/_downloads/0aecb10e7c78353581d9a2a41fdc6b88/spatial_indexing.zip b/_downloads/0aecb10e7c78353581d9a2a41fdc6b88/spatial_indexing.zip index 1da224343979baad4faeca5dd9d4a1971b2fd6ef..7d8588d1452c75378fd62ec8d72dbe928da598fb 100644 GIT binary patch delta 329 zcmezRnDNRjM(F@=W)=|!5Kt-aC*{ILKGTDOV2eX2z>f}0B zjm=A0IT*p5-)tt64R~gQ+2S0@lPft^g4ml2IF%SDPvp7}=IrCc?%mlPT^1BE89DwJlrqCI({fyCtdg#v6lb3ow+0I;uG AsQ>@~ delta 1532 zcmca|i}CAYMu`A#W)=|!5SZe{5}Es&Z-$Ej1A~jfMhSVA$!07+{gkN+CL6J8Y>sAS zXQZ~dsca^b_j1jmwz1~y$&+WZub{HAo835+7$?i{+@rR+UR=D4fmDq!WiDlf$^Lf6 zlP7Sy0z*Q5@?Y-1)OPh>o@q>z9R#f=*SknDQH ZnKM_KsnlTd2W^STcDVv{Qz?+#xgaHJU3dJI?l(`fv)@EP;Vd2RO48%4Xvaw9IVEMtUpsG5#j#Xpx zQdSN|Fy}X$$z%hb*o@8?t?k|xOpL}C3&lXDl{hV=KTwn zVB??0w0X8*14K4c_!U@mp-2$p=1-#2z@nS4iAynVelH=*43e81CG%r*psX7cSm9H7 zOE6<{j?&!89Ll@Ff`TexEMUe~jaXJNBSBA;Nr6ilsGTdon~_O`8JkZh_ZyhAT>*NS GfdK&KFGsKd delta 1471 zcmZ1-aVAkZz?+#xgaHJmc(Fw0zUG_ZV!*%v!orjPYm03(WMi3Z#`4oonW|v25v#`L zXjXPcYMYzNW-@s%*DPuqYtEiLc{ckBDjU1mjYElXvJB5XYMblD#Y^>&jpD8b27&tI zzubSR?cBdS)0ieZ2wH7E$L~sYcZ&(WqPBaPg@PD2hY3%mwp%y96Om%v%qb?rOl22O z){y+MSy9TBiOS|~&XlpFwwaTc%FUhZEWeA&PTiys#zJKyH%F?(vQpd3otmOdQUTtK VOd`zKisi}gw9VN{fu%D80|0tK?L+_o diff --git a/_downloads/f989545cc7034bd6c0c40e2091705820/spatial_indexing.py b/_downloads/f989545cc7034bd6c0c40e2091705820/spatial_indexing.py index d3e1f11..599b25a 100644 --- a/_downloads/f989545cc7034bd6c0c40e2091705820/spatial_indexing.py +++ b/_downloads/f989545cc7034bd6c0c40e2091705820/spatial_indexing.py @@ -24,7 +24,6 @@ We'll start by importing the required packages with matplotlib for plotting. """ - import os import matplotlib.pyplot as plt @@ -34,27 +33,30 @@ os.environ["NUMBA_DISABLE_JIT"] = "1" # small examples, avoid JIT overhead from numba_celltree import CellTree2d, demo # noqa E402 -############################################################################### +# %% # Let's start with a rectangular mesh: + nx = ny = 10 x = y = np.linspace(0.0, 10.0, nx + 1) vertices = np.array(np.meshgrid(x, y, indexing="ij")).reshape(2, -1).T a = np.add.outer(np.arange(nx), nx * np.arange(ny)) + np.arange(ny) faces = np.array([a, a + 1, a + nx + 2, a + nx + 1]).reshape(4, -1).T -############################################################################### +# %% # Determine the edges of the cells, and plot them. + node_x, node_y = vertices.transpose() edges = demo.edges(faces, -1) fig, ax = plt.subplots() demo.plot_edges(node_x, node_y, edges, ax, color="black") -############################################################################### +# %% # Locating points # --------------- # # We'll build a cell tree first, then look for some points. + tree = CellTree2d(vertices, faces, -1) points = np.array( [ @@ -66,13 +68,14 @@ i = tree.locate_points(points) i -############################################################################### +# %% # These numbers are the cell numbers in which we can find the points. # # A value of -1 means that a point is not located in any cell. # # Let's get rid of the -1 values, and take a look which cells have been found. # We'll color the found cells blue, and we'll draw the nodes to compare. + i = i[i != -1] fig, ax = plt.subplots() @@ -80,7 +83,7 @@ demo.plot_edges(node_x, node_y, edges, ax, color="black") demo.plot_edges(node_x, node_y, demo.edges(faces[i], -1), ax, color="blue", linewidth=3) -############################################################################### +# %% # Now let's try a more exotic example. vertices, faces = demo.generate_disk(5, 5) vertices += 1.0 @@ -91,10 +94,11 @@ fig, ax = plt.subplots() demo.plot_edges(node_x, node_y, edges, ax, color="black") -############################################################################### +# %% # There are certainly no rows or columns to speak of! # # Let's build a new tree, and look for the same points as before. + tree = CellTree2d(vertices, faces, -1) i = tree.locate_points(points) i = i[i != -1] @@ -104,7 +108,7 @@ demo.plot_edges(node_x, node_y, edges, ax, color="black") demo.plot_edges(node_x, node_y, demo.edges(faces[i], -1), ax, color="blue", linewidth=3) -############################################################################### +# %% # It should be clear by now that a point may only fall into a single cell. A # point may also be out of bounds. If a cell falls exactly on an edge, one of the # two neighbors will be chosen arbitrarily. At any rate, we can always expect @@ -120,6 +124,7 @@ # A search of N points will yield N answers (cell numbers). A search of N boxes # may yield M answers. To illustrate, let's look for all the cells inside of # a box. + box_coords = np.array( [ [4.0, 8.0, 4.0, 6.0], # xmin, xmax, ymin, ymax @@ -134,7 +139,7 @@ ) demo.plot_boxes(box_coords, ax, color="red", linewidth=3) -############################################################################### +# %% # We can also search for multiple boxes: box_coords = np.array( [ @@ -146,12 +151,13 @@ box_i, cell_i = tree.locate_boxes(box_coords) box_i, cell_i -############################################################################### +# %% # Note that this method returns two arrays of equal length. The second array # contains the cell numbers, as usual. The first array contains the index of # the bounding box in which the respective cells fall. Note that there are only # two numbers in ``box_i``: there are no cells located in the third box, as we # can confirm visually: + cells_0 = cell_i[box_i == 0] cells_1 = cell_i[box_i == 1] @@ -165,7 +171,7 @@ ) demo.plot_boxes(box_coords, ax, color="red", linewidth=3) -############################################################################### +# %% # Locating cells # -------------- # @@ -177,6 +183,7 @@ # * the index of the face to locate # * the index of the face in the celtree # * the area of the intersection + triangle_vertices = np.array( [ [5.0, 3.0], @@ -209,11 +216,12 @@ ) demo.plot_edges(tri_x, tri_y, demo.edges(triangles, -1), ax, color="red", linewidth=3) -############################################################################### +# %% # Let's color the faces of the mesh by their ratio of overlap. Because our # mesh is triangular, we can represent the triangles as two collections of # vectors (V, U). Then the area is half of the absolute value of the cross # product of U and V. + intersection_faces = faces[cell_i] intersection_vertices = vertices[intersection_faces] U = intersection_vertices[:, 1] - intersection_vertices[:, 0] @@ -232,7 +240,7 @@ demo.plot_edges(node_x, node_y, edges, ax, color="black") demo.plot_edges(tri_x, tri_y, demo.edges(triangles, -1), ax, color="red", linewidth=3) -############################################################################### +# %% # ``CellTree2d`` also provides a method to compute overlaps between boxes and a # mesh. This may come in handy to compute overlap with a raster, for example to # rasterize a mesh. @@ -256,9 +264,10 @@ ) raster_i, cell_i, raster_overlap = tree.intersect_boxes(coords) -############################################################################### +# %% # We can construct a weight matrix with these arrays. This weight matrix stores # for every raster cell (row) the area of overlap with a triangle (column). + weight_matrix = np.zeros((ny * nx, len(faces))) weight_matrix[raster_i, cell_i] = raster_overlap @@ -266,7 +275,7 @@ colored = ax.imshow(weight_matrix) _ = fig.colorbar(colored) -############################################################################### +# %% # This weight matrix can be used for translating data from one mesh to another. # Let's generate some mock elevation data for a valley. Then, we'll compute the # area weighted mean for every raster cell. @@ -296,7 +305,7 @@ def saddle_elevation(x, y): ax1.imshow(mean_elevation.reshape(ny, nx), extent=(xmin, xmax, ymin, ymax)) demo.plot_edges(node_x, node_y, edges, ax1, color="white") -############################################################################### +# %% # Such a weight matrix doesn't apply to just boxes and triangles, but to every # case of mapping one mesh to another by intersecting cell areas. Note however # that the aggregation above is not very efficient. Most of the entries in the @@ -330,7 +339,7 @@ def saddle_elevation(x, y): edge_i, cell_i, intersections = tree.intersect_edges(edge_coords) edge_i, cell_i -############################################################################### +# %% # To wrap up, we'll color the intersect faces with the length of the # intersected line segments. We can easily compute the length of each segment # with the Euclidian norm (Pythagorean distance): @@ -346,3 +355,5 @@ def saddle_elevation(x, y): fig.colorbar(colored) ax.add_collection(LineCollection(edge_coords, color="red", linewidth=3)) demo.plot_edges(node_x, node_y, edges, ax, color="black") + +# %% diff --git a/_downloads/fb625db3c50d423b1b7881136ffdeec8/examples_jupyter.zip b/_downloads/fb625db3c50d423b1b7881136ffdeec8/examples_jupyter.zip index f3aad67a94bff90368c0e2e638444d6c0a5b4a84..3a6012b456e2ab476f374fbd3f24d08bfda1b0de 100644 GIT binary patch delta 32 kcmdnr#JInSkvG7bnMH&F1e6NJHu64kUSource code for numba_celltree.celltree
         """
         Find the index of a face that contains a point.
 
+        Points that are very close near an edge of a face will also be
+        identified as falling within that face.
+
         Parameters
         ----------
         points: ndarray of floats with shape ``(n_point, 2)``
diff --git a/_sources/examples/sg_execution_times.rst.txt b/_sources/examples/sg_execution_times.rst.txt
index 62812f4..97ae383 100644
--- a/_sources/examples/sg_execution_times.rst.txt
+++ b/_sources/examples/sg_execution_times.rst.txt
@@ -6,7 +6,7 @@
 
 Computation times
 =================
-**00:00.731** total execution time for 1 file **from examples**:
+**00:00.782** total execution time for 1 file **from examples**:
 
 .. container::
 
@@ -33,5 +33,5 @@ Computation times
      - Time
      - Mem (MB)
    * - :ref:`sphx_glr_examples_spatial_indexing.py` (``spatial_indexing.py``)
-     - 00:00.731
+     - 00:00.782
      - 0.0
diff --git a/_sources/examples/spatial_indexing.rst.txt b/_sources/examples/spatial_indexing.rst.txt
index 1531899..2354d32 100644
--- a/_sources/examples/spatial_indexing.rst.txt
+++ b/_sources/examples/spatial_indexing.rst.txt
@@ -43,11 +43,10 @@ these.
 
 We'll start by importing the required packages with matplotlib for plotting.
 
-.. GENERATED FROM PYTHON SOURCE LINES 27-37
+.. GENERATED FROM PYTHON SOURCE LINES 27-36
 
 .. code-block:: Python
 
-
     import os
 
     import matplotlib.pyplot as plt
@@ -64,14 +63,15 @@ We'll start by importing the required packages with matplotlib for plotting.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 38-39
+.. GENERATED FROM PYTHON SOURCE LINES 37-38
 
 Let's start with a rectangular mesh:
 
-.. GENERATED FROM PYTHON SOURCE LINES 39-45
+.. GENERATED FROM PYTHON SOURCE LINES 38-45
 
 .. code-block:: Python
 
+
     nx = ny = 10
     x = y = np.linspace(0.0, 10.0, nx + 1)
     vertices = np.array(np.meshgrid(x, y, indexing="ij")).reshape(2, -1).T
@@ -89,10 +89,11 @@ Let's start with a rectangular mesh:
 
 Determine the edges of the cells, and plot them.
 
-.. GENERATED FROM PYTHON SOURCE LINES 47-53
+.. GENERATED FROM PYTHON SOURCE LINES 47-54
 
 .. code-block:: Python
 
+
     node_x, node_y = vertices.transpose()
     edges = demo.edges(faces, -1)
 
@@ -111,17 +112,18 @@ Determine the edges of the cells, and plot them.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 54-58
+.. GENERATED FROM PYTHON SOURCE LINES 55-59
 
 Locating points
 ---------------
 
 We'll build a cell tree first, then look for some points.
 
-.. GENERATED FROM PYTHON SOURCE LINES 58-69
+.. GENERATED FROM PYTHON SOURCE LINES 59-71
 
 .. code-block:: Python
 
+
     tree = CellTree2d(vertices, faces, -1)
     points = np.array(
         [
@@ -146,7 +148,7 @@ We'll build a cell tree first, then look for some points.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 70-76
+.. GENERATED FROM PYTHON SOURCE LINES 72-78
 
 These numbers are the cell numbers in which we can find the points.
 
@@ -155,10 +157,11 @@ A value of -1 means that a point is not located in any cell.
 Let's get rid of the -1 values, and take a look which cells have been found.
 We'll color the found cells blue, and we'll draw the nodes to compare.
 
-.. GENERATED FROM PYTHON SOURCE LINES 76-83
+.. GENERATED FROM PYTHON SOURCE LINES 78-86
 
 .. code-block:: Python
 
+
     i = i[i != -1]
 
     fig, ax = plt.subplots()
@@ -178,11 +181,11 @@ We'll color the found cells blue, and we'll draw the nodes to compare.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 84-85
+.. GENERATED FROM PYTHON SOURCE LINES 87-88
 
 Now let's try a more exotic example.
 
-.. GENERATED FROM PYTHON SOURCE LINES 85-94
+.. GENERATED FROM PYTHON SOURCE LINES 88-97
 
 .. code-block:: Python
 
@@ -207,16 +210,17 @@ Now let's try a more exotic example.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 95-98
+.. GENERATED FROM PYTHON SOURCE LINES 98-101
 
 There are certainly no rows or columns to speak of!
 
 Let's build a new tree, and look for the same points as before.
 
-.. GENERATED FROM PYTHON SOURCE LINES 98-107
+.. GENERATED FROM PYTHON SOURCE LINES 101-111
 
 .. code-block:: Python
 
+
     tree = CellTree2d(vertices, faces, -1)
     i = tree.locate_points(points)
     i = i[i != -1]
@@ -238,7 +242,7 @@ Let's build a new tree, and look for the same points as before.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 108-123
+.. GENERATED FROM PYTHON SOURCE LINES 112-127
 
 It should be clear by now that a point may only fall into a single cell. A
 point may also be out of bounds. If a cell falls exactly on an edge, one of the
@@ -256,10 +260,11 @@ A search of N points will yield N answers (cell numbers). A search of N boxes
 may yield M answers. To illustrate, let's look for all the cells inside of
 a box.
 
-.. GENERATED FROM PYTHON SOURCE LINES 123-137
+.. GENERATED FROM PYTHON SOURCE LINES 127-142
 
 .. code-block:: Python
 
+
     box_coords = np.array(
         [
             [4.0, 8.0, 4.0, 6.0],  # xmin, xmax, ymin, ymax
@@ -286,11 +291,11 @@ a box.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 138-139
+.. GENERATED FROM PYTHON SOURCE LINES 143-144
 
 We can also search for multiple boxes:
 
-.. GENERATED FROM PYTHON SOURCE LINES 139-149
+.. GENERATED FROM PYTHON SOURCE LINES 144-154
 
 .. code-block:: Python
 
@@ -323,7 +328,7 @@ We can also search for multiple boxes:
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 150-155
+.. GENERATED FROM PYTHON SOURCE LINES 155-160
 
 Note that this method returns two arrays of equal length. The second array
 contains the cell numbers, as usual. The first array contains the index of
@@ -331,10 +336,11 @@ the bounding box in which the respective cells fall. Note that there are only
 two numbers in ``box_i``: there are no cells located in the third box, as we
 can confirm visually:
 
-.. GENERATED FROM PYTHON SOURCE LINES 155-168
+.. GENERATED FROM PYTHON SOURCE LINES 160-174
 
 .. code-block:: Python
 
+
     cells_0 = cell_i[box_i == 0]
     cells_1 = cell_i[box_i == 1]
 
@@ -360,7 +366,7 @@ can confirm visually:
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 169-180
+.. GENERATED FROM PYTHON SOURCE LINES 175-186
 
 Locating cells
 --------------
@@ -374,10 +380,11 @@ This returns three arrays of equal length:
 * the index of the face in the celtree
 * the area of the intersection
 
-.. GENERATED FROM PYTHON SOURCE LINES 180-212
+.. GENERATED FROM PYTHON SOURCE LINES 186-219
 
 .. code-block:: Python
 
+
     triangle_vertices = np.array(
         [
             [5.0, 3.0],
@@ -422,17 +429,18 @@ This returns three arrays of equal length:
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 213-217
+.. GENERATED FROM PYTHON SOURCE LINES 220-224
 
 Let's color the faces of the mesh by their ratio of overlap. Because our
 mesh is triangular, we can represent the triangles as two collections of
 vectors (V, U). Then the area is half of the absolute value of the cross
 product of U and V.
 
-.. GENERATED FROM PYTHON SOURCE LINES 217-235
+.. GENERATED FROM PYTHON SOURCE LINES 224-243
 
 .. code-block:: Python
 
+
     intersection_faces = faces[cell_i]
     intersection_vertices = vertices[intersection_faces]
     U = intersection_vertices[:, 1] - intersection_vertices[:, 0]
@@ -463,13 +471,13 @@ product of U and V.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 236-239
+.. GENERATED FROM PYTHON SOURCE LINES 244-247
 
 ``CellTree2d`` also provides a method to compute overlaps between boxes and a
 mesh. This may come in handy to compute overlap with a raster, for example to
 rasterize a mesh.
 
-.. GENERATED FROM PYTHON SOURCE LINES 239-259
+.. GENERATED FROM PYTHON SOURCE LINES 247-267
 
 .. code-block:: Python
 
@@ -500,15 +508,16 @@ rasterize a mesh.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 260-262
+.. GENERATED FROM PYTHON SOURCE LINES 268-270
 
 We can construct a weight matrix with these arrays. This weight matrix stores
 for every raster cell (row) the area of overlap with a triangle (column).
 
-.. GENERATED FROM PYTHON SOURCE LINES 262-269
+.. GENERATED FROM PYTHON SOURCE LINES 270-278
 
 .. code-block:: Python
 
+
     weight_matrix = np.zeros((ny * nx, len(faces)))
     weight_matrix[raster_i, cell_i] = raster_overlap
 
@@ -528,13 +537,13 @@ for every raster cell (row) the area of overlap with a triangle (column).
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 270-273
+.. GENERATED FROM PYTHON SOURCE LINES 279-282
 
 This weight matrix can be used for translating data from one mesh to another.
 Let's generate some mock elevation data for a valley. Then, we'll compute the
 area weighted mean for every raster cell.
 
-.. GENERATED FROM PYTHON SOURCE LINES 273-299
+.. GENERATED FROM PYTHON SOURCE LINES 282-308
 
 .. code-block:: Python
 
@@ -576,7 +585,7 @@ area weighted mean for every raster cell.
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 300-324
+.. GENERATED FROM PYTHON SOURCE LINES 309-333
 
 Such a weight matrix doesn't apply to just boxes and triangles, but to every
 case of mapping one mesh to another by intersecting cell areas. Note however
@@ -603,7 +612,7 @@ This once again returns three arrays of equal length:
 * the index of the cell
 * the location of the intersection
 
-.. GENERATED FROM PYTHON SOURCE LINES 324-333
+.. GENERATED FROM PYTHON SOURCE LINES 333-342
 
 .. code-block:: Python
 
@@ -632,13 +641,13 @@ This once again returns three arrays of equal length:
 
 
 
-.. GENERATED FROM PYTHON SOURCE LINES 334-337
+.. GENERATED FROM PYTHON SOURCE LINES 343-346
 
 To wrap up, we'll color the intersect faces with the length of the
 intersected line segments. We can easily compute the length of each segment
 with the Euclidian norm (Pythagorean distance):
 
-.. GENERATED FROM PYTHON SOURCE LINES 337-349
+.. GENERATED FROM PYTHON SOURCE LINES 346-359
 
 .. code-block:: Python
 
@@ -657,6 +666,7 @@ with the Euclidian norm (Pythagorean distance):
 
 
 
+
 .. image-sg:: /examples/images/sphx_glr_spatial_indexing_011.png
    :alt: spatial indexing
    :srcset: /examples/images/sphx_glr_spatial_indexing_011.png
@@ -669,7 +679,7 @@ with the Euclidian norm (Pythagorean distance):
 
 .. rst-class:: sphx-glr-timing
 
-   **Total running time of the script:** (0 minutes 0.731 seconds)
+   **Total running time of the script:** (0 minutes 0.782 seconds)
 
 
 .. _sphx_glr_download_examples_spatial_indexing.py:
diff --git a/_sources/sg_execution_times.rst.txt b/_sources/sg_execution_times.rst.txt
index 618f33c..8df5010 100644
--- a/_sources/sg_execution_times.rst.txt
+++ b/_sources/sg_execution_times.rst.txt
@@ -6,7 +6,7 @@
 
 Computation times
 =================
-**00:00.731** total execution time for 1 file **from all galleries**:
+**00:00.782** total execution time for 1 file **from all galleries**:
 
 .. container::
 
@@ -33,5 +33,5 @@ Computation times
      - Time
      - Mem (MB)
    * - :ref:`sphx_glr_examples_spatial_indexing.py` (``../examples/spatial_indexing.py``)
-     - 00:00.731
+     - 00:00.782
      - 0.0
diff --git a/api.html b/api.html
index 1ea1d80..abc6f20 100644
--- a/api.html
+++ b/api.html
@@ -549,6 +549,8 @@
 
locate_points(points: ndarray) ndarray[source]#

Find the index of a face that contains a point.

+

Points that are very close near an edge of a face will also be +identified as falling within that face.

Parameters:

points (ndarray of floats with shape (n_point, 2))

diff --git a/examples/sg_execution_times.html b/examples/sg_execution_times.html index 0d64577..32bb16e 100644 --- a/examples/sg_execution_times.html +++ b/examples/sg_execution_times.html @@ -382,7 +382,7 @@

Computation times#

-

00:00.731 total execution time for 1 file from examples:

+

00:00.782 total execution time for 1 file from examples: