|
POST
|
Would it be possible to create a polygon of your total investigation area, erase the digitized polygons of the lakes and then use the raster clip tool?
... View more
11-16-2020
01:56 AM
|
1
|
3
|
3734
|
|
POST
|
Thank you David, unfortunately I get an error message if I insert lyr.save() after the findAndReplace ... : line 35, in DataSourcesReplace lyr.save() File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\utils.py", line 182, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\arcobjects\mixins.py", line 416, in save assert hasattr(self, '_lyr'), gp.getIDMessage(89003, "No filename set.") AssertionError: No filename set.
... View more
11-12-2020
03:29 AM
|
0
|
1
|
1772
|
|
POST
|
Hello, I can't find and replace a workspace path with the following script: # -*- coding: cp1252 -*-
import arcpy, os
arcpy.env.overwriteOutput = True
mxd=arcpy.mapping.MapDocument(r"C:\temp_replaceDatasource\Detail.mxd")
class ReplaceDataSource(object):
def __init__(self):
self.mxd = mxd
def DataSourcesReplace(self):
for lyr in arcpy.mapping.ListLayers(self.mxd, ""):
if lyr.isServiceLayer == 1:
print lyr.name + " is a WMS Layer"
else:
print lyr.name + " X " + lyr.dataSource
newDataSource = lyr.dataSource.replace("R:\\", "\\\\{}\\{}\\".format("Client", "R$"))
print newDataSource
lyr.findAndReplaceWorkspacePath(lyr.dataSource, newDataSource)
print lyr.dataSource
mxd.saveACopy(r"C:\temp_replaceDatasource\Detail_WIBAS.mxd")
if __name__ == '__main__':
MyClass = ReplaceDataSource()
MyClass.DataSourcesReplace() The print statement looks ok but the path is not replaced - nothing happens with the path? Any ideas why? output of the print statement Maßnahmenflaeche X R:\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme \\Client\R$\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme R:\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme
... View more
11-11-2020
11:26 PM
|
0
|
3
|
1802
|
|
POST
|
One solution could be this (Polsby-Popper test): vector - Calculating roundness/compactness of polygon? - Geographic Information Systems Stack Exchange
... View more
10-28-2020
10:47 PM
|
0
|
0
|
4474
|
|
POST
|
Some years later - Is there today a tool to remove linear Polygons? In ArcMaP (10.6.)?
... View more
10-28-2020
02:13 AM
|
0
|
2
|
729
|
|
POST
|
sorry wrong command - i wanted to do .findAndReplaceWorkspacePath
... View more
08-27-2020
05:00 AM
|
0
|
0
|
1072
|
|
POST
|
I've problems with .replaceDataSource. I get an error message running this script? # -*- coding: cp1252 -*-
import arcpy, os
arcpy.env.overwriteOutput = True
mxd=arcpy.mapping.MapDocument(r"R:\SG-A\Karto\Bierer2020\WIBAS_Zentralisierung\ReplaceDataSource\Detail.mxd")
# Encoding der Standardausgabe herausfinden
stdout_encoding = sys.stdout.encoding or sys.getfilesystemencoding()
class ReplaceDataSource(object):
def __init__(self):
self.mxd = mxd
def DataSourcesReplace(self):
for lyr in arcpy.mapping.ListLayers(self.mxd, ""):
if lyr.isServiceLayer == 1:
print lyr.name + " is a WMS Layer"
else:
print lyr.name + " X " + lyr.dataSource
dataSource = lyr.dataSource.encode(stdout_encoding)
newDataSource = dataSource.replace("R:\\", "\\\\Client\\R$\\""")
newDataSource1 = (os.path.dirname(newDataSource))
print newDataSource1
lyr.replaceDataSource(workspace_path = newDataSource1, workspace_type = "FILEGDB_WORKSPACE", dataset_name = lyr.name)
mxd.saveACopy(r"R:\SG-A\Karto\Bierer2020\WIBAS_Zentralisierung\ReplaceDataSource\Detail_WIBAS.mxd")
if __name__ == '__main__':
MyClass = ReplaceDataSource()
MyClass.DataSourcesReplace()
Error Message: Maßnahmenflaeche X R:\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme \\Client\R$\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data Traceback (most recent call last): ... line 36, in DataSourcesReplace lyr.replaceDataSource(workspace_path = newDataSource1, workspace_type = "FILEGDB_WORKSPACE", dataset_name = lyr.name) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\utils.py", line 182, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\_mapping.py", line 681, in replaceDataSource return convertArcObjectToPythonObject(self._arc_object.replaceDataSource(*gp_fixargs((workspace_path, workspace_type, dataset_name, validate), True))) ValueError: Layer: Unexpected error
... View more
08-27-2020
03:56 AM
|
0
|
1
|
1093
|
|
POST
|
Hello, I want to select the maximum area of features with the same attribute. If I run the following script I don't get the maximum value of the list. Any ideas why? import arcpy
arcpy.env.overwriteOutput = True
inFile = r"path... \Default.gdb\NSG_Kreis_Inters"
fc = r"path... \Bearbeitung.gdb\data\Test_NSG_Hauptkreis"
Fields = ["OBJECTID_1", "OBJEKT", "m2"]
inFileL = "inFileL"
arcpy.CopyFeatures_management(inFile, fc)
arcpy.MakeFeatureLayer_management(fc, inFileL)
arcpy.AddField_management(inFileL, "relevant", "Single")
arcpy.AddField_management(inFileL, "m2", "Long")
arcpy.CalculateField_management(inFileL, "m2", "!Shape_Area!", "PYTHON_9.3")
with arcpy.da.SearchCursor(inFileL, Fields) as cursor:
for row in cursor:
sql = "OBJEKT = '{}'".format(row[1].encode('utf-8'))
arcpy.SelectLayerByAttribute_management(inFileL, where_clause=sql)
myList = list()
with arcpy.da.SearchCursor(inFileL, Fields) as cursor:
for row in cursor:
myList.append("{}".format(row[2]))
print myList
print max(myList)
sql1 = "{} AND m2 = {}".format(sql, max(myList))
arcpy.SelectLayerByAttribute_management(inFileL, "NEW_SELECTION", where_clause=sql1)
arcpy.CalculateField_management(inFileL, "relevant", 1, "PYTHON_9.3") Here is the result of the prints in lines 31 and 32: ['0', '1012219'] 1012219 ['0', '1012219'] 1012219 ['2', '1344613'] 2 ['2', '1344613'] 2 ['1649705', '2100'] 2100 ['1918769', '2100'] 2100
... View more
08-20-2020
09:54 PM
|
0
|
3
|
1145
|
|
POST
|
As well not sure but do you think of a tool to create index features for the line, have a look here: Index-Features der Streifenkarte—Hilfe | ArcGIS for Desktop Indexgitter-Features—Hilfe | ArcGIS for Desktop
... View more
07-02-2020
07:13 AM
|
0
|
0
|
1268
|
|
POST
|
Somehow I'm not able to add all values in a search cursor to a dictionary - one value pair is missing? What is my mistake? def Dict1(self):
with arcpy.da.SearchCursor(outIntersect, ["FID_Anbinden1", "FLURSTUECKSTEXT"]) as cursor:
for row in cursor:
print("{} - {}".format(row[0], row[1]))
myKey = row[1]
myValue = row[0]
myDict[myKey] = myValue
# myDict.update({myKey: myValue})
print myDict This leads to this output (as well as .update in line 9): 1 - 10125 1 - 10079 1 - 10337/2 2 - 10125 {u'10079': 1, u'10337/2': 1, u'10125': 2} u'10125':1 is missing?
... View more
05-29-2020
02:32 AM
|
0
|
4
|
2550
|
|
POST
|
Thank you David, didn't see your answer. But it works with one "/", I only made a big mistake in line 6 🙂
... View more
05-08-2020
05:04 AM
|
0
|
1
|
775
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-10-2025 08:08 AM | |
| 1 | 05-13-2025 05:05 AM | |
| 1 | 04-28-2025 03:40 AM | |
| 4 | 08-13-2024 10:49 PM | |
| 1 | 08-13-2024 09:52 PM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|