8 from __future__
import print_function
11 from opals
import pyDM
13 def DM_spatial_query_and_classify(filename, classValue):
15 dm = pyDM.Datamanager.load(filename, readOnly=
False, threadSafety=
False)
17 print(
"Unable to open ODM '" + filename +
"'")
22 print(
"ODM contains", dm.sizePoint(),
"points")
23 print(
"2D-limit (%.3f," % limit.xmin,
"%.3f) -" % limit.ymin,
"(%.3f," % limit.xmax,
"%.3f)" % limit.ymax)
26 lf = pyDM.AddInfoLayoutFactory()
27 type, inDM = lf.addColumn(dm,
"Id",
True);
assert inDM ==
True
28 type, inDM = lf.addColumn(dm,
"Classification",
True);
assert inDM ==
True
29 layout = lf.getLayout()
32 queryWin = pyDM.Window(529600, 5338600, 529650, 5338650)
33 print(
"\nPerform spatial query")
34 result = pyDM.NumpyConverter.searchPoint(dm, queryWin, layout, withCoordinates=
True)
37 ptsQueried = result[next(iter(result))].size
38 print(f
"{ptsQueried} points queried")
43 print(f
"Change selected points to classification {classValue}")
44 classArray = result[
"Classification"]
45 classArray.fill(classValue)
49 setObj[
"Id"] = result[
"Id"]
50 setObj[
"Classification"] = classArray
53 pyDM.NumpyConverter.setById(setObj, dm, layout)
59 if len(sys.argv) == 1:
60 print(
"ODM parameter missing")
63 DM_spatial_query_and_classify(sys.argv[1], classValue=6)