POST
|
I have the following stand alone script but it deletes all the features in the feature class instead what I have in the query. It also only prints out that there is 9 records that meet the query criteria witch is not correct there are more than 9 records. Seems pretty straight forward but I am Not sure what I am doing wrong. I also tried using updatecursor but I get the same results, it deletes are the features in the feature class. TaxPar = r"C:\Temp\TaxParcels1.shp"
# Process: Make Feature Layer
query = "DXF_TEXT LIKE 'Q%' or DXF_TEXT = ' ' or DXF_TEXT IS NULL"
arcpy.SelectLayerByAttribute_management(TaxPar, "NEW_SELECTION", query)
result = arcpy.GetCount_management(TaxPar).getOutput(0)
print ('{} has {} records'.format(TaxPar, result[0]))
if int(arcpy.GetCount_management(TaxPar).getOutput(0)) > 0:
arcpy.DeleteFeatures_management(TaxPar) sql = "DXF_TEXT LIKE 'Q%' or DXF_TEXT = '' or DXF_TEXT IS NULL"
with arcpy.da.UpdateCursor(TaxPar, 'DXF_TEXT',sql) as cursor:
for row in cursor:
cursor.deleteRow()
else:
pass
... View more
08-20-2021
08:55 AM
|
0
|
6
|
821
|
POST
|
I tested the following and it worked for me. import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\MxdDataSourceTest.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Temp\BPs.gdb",r"C:\Temp\BPs_1.gdb")
mxd.saveACopy(r"C:\Temp\MxdDataSourceTest2.mxd")
print 'done'
... View more
08-11-2021
01:47 PM
|
0
|
3
|
1161
|
POST
|
You need to save it after. mxd.save() mxd.saveACopy(r"C:\Users\SMALIS\Documents\ArcGIS\pythonSwitchSourceNEW.mxd")
... View more
08-11-2021
11:13 AM
|
1
|
1
|
1175
|
POST
|
import arcpy
from arcpy import env
env.workspace = "c:/data/columbia"
# Create a value table that will hold the input feature classes for Merge
vTab = arcpy.ValueTable()
# Step through each dataset in the list
for fd in arcpy.ListDatasets("*", "CAD"):
layername = fd + "_Layer"
# Select only the Polyine features on the drawing layer b-railroad
arcpy.MakeFeatureLayer_management(fd + "/Polyline", layername, "\"Layer\" = 'B-RAILROAD'")
vTab.addRow(layername)
# Merge the CAD features into one feature class
arcpy.Merge_management(vTab, "c:/data/columbia/Columbia.gdb/Railroads")
... View more
07-29-2021
03:10 PM
|
0
|
0
|
726
|
POST
|
It would probably help to see what your current codes looks like.
... View more
07-29-2021
01:28 PM
|
0
|
0
|
732
|
POST
|
How would I pass the certain fields and query ( "IS NOT NULL") to use arcpy.CalculatorField?
... View more
06-28-2021
09:02 AM
|
0
|
1
|
2979
|
POST
|
I trying to figure out a better/simpler way of clear multiple fields(meaning making the attributes in fields " ") at once but not all, just specific fields. I can do it with field calculator but that means i would have about 70 field calculators in the scrip. How else can this be done, examples?
... View more
06-25-2021
03:05 PM
|
0
|
8
|
3101
|
POST
|
I need to format this Arcade code to include if statement but not sure how. The num field can be either 9 or 10 digits so I need to be able to include a statement if it's 9 digits do this or if it's 10 digits do this. How can I do this? var Num;
Num = $feature.Num;
// if 10 digit run this
//var txt = Left(Num, Count(Num)-6)
//var txt1 = Right(Num, Count(Num)-4)
//OR
// if 9 digit run this
var txt2 = Left(Num, Count(Num)-5)
var txt3 = Right(Num, Count(Num)-4)
var url = "https://rec-search.Yoyo/find/search.asp?dfYear="+ text(txt2) + "&dfDocumentStart=" + text(txt3);return url;
... View more
06-16-2021
01:57 PM
|
0
|
2
|
861
|
POST
|
Maybe something like this to get you started... fc = "fc"
fc1 = "fc1"
fcH_ID = []
fc1H_ID = []
with arcpy.da.SearchCursor(fc, ["House_ID"]) as cursor:
for row in cursor:
fcH_ID.append(row[0])
del row, cursor
with arcpy.da.SearchCursor(fc1, ["House_ID"]) as cursor:
for row in cursor:
if not row[0] in fcH_ID:
fc1H_ID.append(row[0])
del row, cursor
for ID in fc1H_ID:
arcpy.SelectLayerByAttribute_management(fc1, "ADD_TO_SELECTION", "House_ID = " + str(ID) # and House_ID = "Red"
... View more
06-07-2021
03:43 PM
|
0
|
0
|
515
|
POST
|
Sweet, thank you. SQL1 = "AppSubmitted >= DATE '{}'".format(from_date.strftime('%Y-%m-%d')) #'%Y-%m-%d %H:%M:%S'
SQL2 = "PNum LIKE 'RZ%' OR PNum LIKE 'OR%' OR PNum LIKE 'CR%'"
sql_expression = "({}) and ({})".format(SQL1, SQL2)
arcpy.TableToTable_conversion(table1, workspace,'tableTEST', sql_expression)
... View more
05-27-2021
10:02 AM
|
0
|
0
|
672
|
POST
|
I currently have two sql's queries in a script, is there a way to combine SQL1 & SQL2 so I am not doing two separate queries? table1 = r"C:\Temp\Table"
from_date = DT.date.today() - DT.timedelta(days=730)
SQL1 = "AppSubmitted >= DATE '{}'".format(from_date.strftime('%Y-%m-%d')) #'%Y-%m-%d %H:%M:%S'
SQL2 = "PNum LIKE 'RZ%' OR PNum LIKE 'OR%' OR PNum LIKE 'CR%'"
arcpy.MakeTableView_management(table1, 'tableview', SQL) #Include SQL2
... View more
05-27-2021
09:28 AM
|
0
|
2
|
677
|
POST
|
Here is one I have used but the layer has to be in the same folder. project = arcpy.mp.ArcGISProject('CURRENT')
layer1 = project.listMaps()[0]
lyr = layer1.listLayers('HOMES')[0]
arcpy.env.workspace = os.path.dirname(project.filePath)
wp = os.path.dirname(project.filePath)
#lyr1 = project.listLayers("SUBJECT_PROPERTY")[0]
try:
cp = lyr.connectionProperties
cp['connection_info']['database'] = wp
cp['dataset'] = 'HOMES2.shp'
lyr.updateConnectionProperties(lyr.connectionProperties, cp)
except:
pass
... View more
03-12-2021
01:52 PM
|
0
|
0
|
853
|
POST
|
Wow that is pretty involved unfortunately I am not an supper advanced python scripture but I do appreciate the the code. I was thinking more along creating points for each polygon and then doing a spatial join back to the polygons and using the x,y spatial location to order/sort them to a specific order then how using a field calculator counter to update the attributes. I have been able to create points for each polygon and spatially joining them back to the polygons but lack creating the complexity of the field calculator.
... View more
01-15-2021
10:19 AM
|
0
|
0
|
1435
|
POST
|
Thank you for the reply and suggestion but i am not sure how to incorporate your suggestion.
... View more
01-13-2021
07:28 AM
|
0
|
0
|
1467
|
Title | Kudos | Posted |
---|---|---|
1 | 10-27-2022 11:37 AM | |
1 | 10-31-2023 10:16 AM | |
1 | 02-16-2023 01:50 PM | |
1 | 08-11-2021 11:13 AM | |
1 | 01-06-2021 10:45 AM |
Online Status |
Offline
|
Date Last Visited |
01-23-2024
11:04 AM
|