帖子
|
我的尝试块通常是这样的:eddy = arcpy.da.Editor(myWorkspace) try: eddy。startEditing(False, True) eddy.startOperation()尝试:与arcpy.da。UpdateCursor(in_table, fields, query) as uCursor: for row in uCursor: # do something uCursor. updaterow (row) del uCursor eddy. stopoperation () eddy. stopediting (True) except: eddy. abortoperation () eddy. stopediting (False) finally: del eddy
...查看更多
周一
|
1
|
0
|
12
|
帖子
|
我说得太早了。这是基于你所说的,对我有用的代码。给定地图中的一个层,我可以这样做:tableName = desc["catalogPath"] fields = ["OBJECTID", "COMMENT"] query = "OBJECTID in({0})"。format(", ".join((str(objId) for objId in objectIds))) eddy = arcpy.da.Editor(sdeFileName)startEditing(True, True) eddy.startOperation() with arcpy.da。UpdateCursor(tableName, fields, query) as uCursor: for row in uCursor: row[1] = "Test Comment" uCursor. updaterow (row) del uCursor eddy. stopoperation () eddy. stopediting (True) del eddy这将修改一个不属于选择的行!爱它!
...查看更多
一周前
|
1
|
2
|
42
|
帖子
|
好的,但是如果layername是一个层的名称,因为它出现在目录中,它将有一个选择,我需要忽略各种游标。
...查看更多
一周前
|
0
|
0
|
45
|
帖子
|
我使用的是ArcGIS Pro 2.9.3。我是一个经验丰富的Python程序员,但需要满足以下要求的帮助:环境:ArcGIS Pro项目中的Python工具箱,由手动运行工具的用户打开ArcGIS Pro项目中的地图包含几个层,这些层来自企业地理数据库特征数据集中的特征类,该特征数据集注册为版本化(传统)读取地图中各个层中一些未选择记录的值。我将使用带有where子句的arcpy.da.SearchCursor。更新地图中各个层中一些未选中记录的一些值。我将使用arcpy。da。UpdateCursor,同样带有where子句。我不知道这些弦的组合是怎样的。在我所处的环境中,我需要一些方法。我将只知道用户在运行时想要使用哪个映射层。它的数据源将是企业地理数据库上版本化数据集中的一个特征类。给定下面的变量,哪些值会生成arcpy。da methods happy, so I can Search, Update, Insert, and Delete rows from a layer, regardless of selection, and still be able to see those changes within the map? projectName = "CURRENT" project = arcpy.mp.ArcGISProject(projectName) mapName = "Map" map_ = next(filter(lambda m: m.name == mapName, project.listMaps())) grpLayerName = "theGroup" mapLayerName = "theLayer" mapLayerLongName = "\\".join((grpLayerName, mapLayerName)) layer = next(filter(lambda lyr: lyr.longName == mapLayerLongName, map_.listLayers())) dbName = "obfuscated" schemaName = "adminUser" datasetName = "bigDataSet" datasetLongName = ".".join((dbName, schemaName, datasetName)) featClassName = "bigFeatureClass" featClassLongName = ".".join((dbName, schemaName, featClassName)) sdePath = r"C:\Users\Myself\Documents\ArcGIS\Projects\BigProject" sdeFileName = "enterprise.sde" sdeFilePath = os.path.join(sdePath, sdeFileName) desc = arcpy.da.Describe(layer) # desc.catalogPath equals os.path.join(sdeFilePath, datasetLongName, featClassLongName) # desc.path equals os.path.join(sdeFilePath, datasetLongName) # SOMETIMES, however, an .sde file in a Temp path is seen, rather than the # one in my project! # desc.aliasName, baseName, file, and name all equal featClassLongName arcpy.da.Editor(workspace argument?) arcpy.da.UpdateCursor(in_table argument?) I have tried so many combinations of strings for the workspace and in_table arguments, it's not even funny. I get errors like: "Objects in this class cannot be updated outside an edit session" "cannot open workspace" "insufficient permissions" (even though the user editing is the owner) Or I succeed with the edit, but the map can't see it until I go to Contents > right-click the database connection and select Refresh. I'm okay refreshing the map or the table view, but I don't want to have to ask the user to refresh the connection Any help, ideas, or guidance would be appreciated.
...查看更多
一周前
|
0
|
6
|
97
|
帖子
|
这确实适用于我,但我没有把它标记为解决方案。是谁干的,又是怎么发生的?
...查看更多
2周前
|
0
|
0
|
64
|
帖子
|
我曾经看到过这些属性,但文档似乎表明它们是用于警告和错误消息的。谢谢你的发帖。
...查看更多
2周前
|
0
|
0
|
64
|
帖子
|
ArcGIS Pro附带的工具对每个参数都有提示。单击参数名左边的蓝色(i)符号会弹出一个漂亮的提示窗口。(示例请参见Buffer > Side Type)。我想为我的Python工具箱工具创建类似的文档。我不知道arcpy的哪个性质。为此设置的参数。请解释一下我应该如何做到这一点。谢谢你!
...查看更多
3周前
|
1
|
4
|
153
|
帖子
|
下面是另一个练习:在这里,我们创建一个元组,其中包含两个新字符串,作为切片操作的结果。由于两个字符串都保留在内存中,#都不会被释放,它们的id也会不同。Orange_slices = (s[:3], s[:5]) id(Orange_slices [0]) 1448227048496 id(Orange_slices [1]) 1448234245616
...查看更多
|
0
|
0
|
47
|
帖子
|
如果点和线在同一地理数据库和同一地理数据集中,那么它们可能具有相同的XY公差,这很好。如果我说错了请纠正我,但我所理解的XY公差是定义一个地图单位的测量中可以容纳多少个整数。数据库更喜欢存储和查询整数,因此XY公差是将这些整数分解为我们在地图、属性表、JSON几何图形等上看到的浮点数。例如,如果在Foot_US中创建了一个XY公差为0.0032808333333333333的特征类,这意味着数据库的真实值1000将返回给软件和用户为3.28083333333333 US Feet。double/float值612,718.82934将被存储在数据库中,作为大约186,757,073的整数。各位,我说的对吗?如果你的点和烟花不在同一个地理数据库或地理数据集中,那么XY公差的差异可能就是问题所在。地球几何并不总是像平面几何那样。在GIS中使用x和y这样的术语,而实际上,y轴在几千英里后会聚到一点,这仍然让我感到困扰。地球的实际形状仍然是一个谜,地震和地震发生的所有变化,不断移动的构造板块,海洋爬上海岸,在晚上退缩。 As much as I want my GIS to be like graph paper, it just isn't.
...查看更多
|
0
|
0
|
44
|
帖子
|
我已经做了很多年的ArcGIS Python程序员,我从来没有真正需要id()函数或is操作符来完成实际工作。实际上,我只关心相等(==)。既然你只是在尝试,我想这就足够了,但这可能不是一个你不需要深入研究的兔子洞。这就是上面代码中发生的事情。打印语句调用时使用逗号,这意味着每个参数#将被计算,从左到右一次一个。# 2) s [3:] id # 3)产生一个新的字符串,字符串传递给id的函数,它返回它的内存地址# 4)内存地址进入一个新的int对象# 5)字符串不再需要,所以它被释放# 6)5:产生一个新的字符串,再利用空闲内存# 7)字符串传递给id的函数,它返回它的内存地址#内存地址进入一个新的int对象# 9)字符串不再需要,#两个对象在存活时具有相同的id,因此打印出#相同的id。print(id(s[3:]), id(s[5:])) #与上面类似,每个参数从左到右计算。这一次,print只有一个参数,但是参数#是一个运算符的结果。运算符从左到右解析它的操作数#。 # Follow steps 1 through 9, paying attention to 4) and 8). # Int objects are equal to each other if they have the same value # so True is returned to the print statement. print(id(s[3:])==id(s[5:])) # 1) The print statement is called with one parameter, as evidenced by # its lack of commas # 2) The print statement's only parameter is the result of the is operator # 3) The is operator evaluates its operands from left to right # 4) s[3:] produces a new string with an id # Note that this new string is still needed for the is operator, so it # is not freed. It hangs out in memory # 6) s[5:] produces a new string with an id # This new string is also needed for the is operator, so it is not freed either # 7) The is operator now compares the identity of both living strings, # sees that they aren't equal, and returns False in both instances. print(s[3:] is s[5:]) print(s[3:] is s[3:]) Now, to address @DanPatterson 's post: s = 'a string' # Since there are no print statements, I'm not sure how he got results # that are in the comments. Perhaps, if run in a terminal, or at different # times, the new strings did not reuse recently freed memory. id(s) # 2625510363760 id(s[:3]) # 2625512614384 id(s[:3]) # 2625512614000 id(s[:3]) # 2625512908528 # 1) The is operator evaluates its operands from left to right # 2) s[:3] creates a new string with an id # 3) The id function is called, returning a new int object # 4) The new string is freed, releasing its memory # 5) s[:3] creates a new string with an id. This may or may # not have been created in the same memory space as 1) was # 6) The id function is called, returning a new int object # 7) The is operator attempts to establish identity on the # two ints that were returned, which have not been freed. # The ints are different objects, so is returns False. id(s[:3]) is id(s[:3]) # False # This is actually the easiest to explain. Dan could have # typed id(10>7), id("h" in "PYTHON".lower()), or id(5!=7) # and still gotten the same memory address. # What he is doing is grabbing the id of the result of the # _equality_ operator. Those results are bools. The values # True and False are global objects of type bool. Because # they are objects, they each have an id. Comparator operators # don't create new instances of type bool, but simply # use the existing ones. id(id(s[:3]) == id(s[:3])) # 140711459289192 id(s[:3] == s[:3]) # 140711459289192
...查看更多
|
1
|
0
|
49
|
标题 | 荣誉 | 发布 |
---|---|---|
1 | 周一 | |
1 | 一周前 | |
1 | 3周前 | |
1 | 3周前 | |
1 | 10-03-2022上午09:40 |