|
POST
|
I would check to make sure you have the full UNC path to the server. \\\\server\\folder\\folder\\ And you might consider using, scheduler has to have the full server path. At least that is the case for me. pyodbc.connect import pyodbc conn = pyodbc.connect('Driver={SQL Server};' 'Server=server_name;' 'Database=db_name;' 'Trusted_Connection=yes;')
... View more
10-31-2019
10:41 AM
|
2
|
0
|
5269
|
|
POST
|
If you layers in are an sde database you might need to include the full path of the layer in your script. From Database Connections\Geodatabase_blah_blah.sde To C:\Users\blah\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\Geodatabase_blah_blah.sde\featuredataset\feature class.
... View more
10-30-2019
01:21 PM
|
0
|
4
|
5269
|
|
POST
|
I've never been able to really understand that filed mapping syntax. Here is what i use. import arcpy,sys
from datetime import datetime as d
startTime = d.now()
start_time = time.time()
Fet1 = "blah1"
Fet2 = "Blah2"
Fet3 = "Blah3"
FieldMapString = '''
DXF_TEXT "DXF_TEXT" true true false 11 Text 0 0 ,First,#, {0}, DXF_TEXT,-1,-1;
ACCOUNT "ACCOUNT" true true false 11 Text 0 0 ,First,#, {0}, ACCOUNT,-1,-1;
PIN "PIN" true true false 13 Text 0 0 ,First,#, {0}, PIN,-1,-1;
ACRES "ACRES" true true false 4 Double 0 0 ,First,#, {0}, ACRES,-1,-1;
Instrument "Instrument" true true false 10 Text 0 0 ,First,#, {0}, Instrument,-1,-1;
SiteAddres "SiteAddres" true true false 106 Text 0 0 ,First,#, {0}, SiteAddres,-1,-1;
SiteCity "SiteCity" true true false 32 Text 0 0 ,First,#, {0}, SiteZip,-1,-1;
SiteZip "SiteZip" true true false 10 Text 0 0 ,First,#, {0}, SiteZip,-1,-1
'''
def Layers1(Fet1):
"""pass the variable and the constant into
the function
"""
fieldmappings = arcpy.FieldMappings()
fieldmappings.loadFromString(FieldMapString)
return fieldmappings
def main(args=None):
if args is None:
args = sys.argv
# Process: Feature Class to Feature Class
arcpy.Append_management(Fet1,Fet2,Fet3 "C:\Temp\Blah.gdb\Fe_ALL","NO_TEST", Layers1(Fet1))
try:
print ('(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')')
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print ("Line %i" % tb.tb_lineno)
print (e.message) I had trouble using this field mapping with Merge until Randy Burton posted some code and can be found here. Merge with field mapping
... View more
10-30-2019
11:56 AM
|
0
|
0
|
2908
|
|
POST
|
If you just want to keep certain fields i would just use drop/delete fields. I use filed mapping if I want to change a field or do more complex things. Here is the example import arcpy,os, sys
#drop feilds
fc = r"D:\GIS Folder\Roads.gdb\Roads"
keep_fields = ['STREET','ROAD_TYPE'] #fields to keep
fieldNameList = []
fieldObjList = arcpy.ListFields(fc)
for field in fieldObjList:
if (not field.name in keep_fields) and (not field.required):
fieldNameList.append(field.name)
arcpy.DeleteField_management(fc, fieldNameList)
... View more
10-30-2019
11:02 AM
|
0
|
2
|
2908
|
|
POST
|
I've ran into this and for me I have to put the full path of the database\featuredataset\featureclass. It might be helpful if you posted your python code. C:\Users\***\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\***_***_***.sde\yourfeaturedataset\featureclass
... View more
10-18-2019
11:59 AM
|
1
|
0
|
1360
|
|
POST
|
I have learned a lot from all you guys on this forum. It's nice to know there are people willing to help out! @Joshua Bixby @Randy Burton @Joe Borgione @Dan Patterson
... View more
09-26-2019
11:55 AM
|
1
|
0
|
1159
|
|
POST
|
I am confused as to how you are got the parcel numbers into the list, i am trying this based on what you posted but get parcels = [row[2] for row in arcpy.da.SearchCursor(fc, field1)] IndexError: tuple index out of range. I thought about duplicates since it doesn't matter which one i can first occurrence. There is two fields before the PARCEL_NO field. fc = 'C:/Temp/ParcelNumberSample2.dbf'
field1 = "PARCEL_NO"
parcels = [row[2] for row in arcpy.da.SearchCursor(fc, field1)]
parentFound = {} # empty dictionary
childFound = {}
# order by objectid
for p in parcels:
parent = p[1][:6]
# print parent
if len(p[1]) > len(parent):
if parent in childFound.keys():
childFound[parent] = (p[0], 1 + childFound[parent][1] )# this will be last child found (by objectid)
else:
childFound[parent] = (p[0], 0)
else:
parentFound[parent] = p[0] # this will be last parent found (by objectid)
# print parentFound
# print childFound
for k in parentFound.keys():
if k not in childFound.keys():
print (k, parentFound , "parent is orig") # this is the parcelid and objectid of parent parcels, add to a list
for k in childFound.keys():
if k not in parentFound.keys():
if childFound [1] < 1:
print (k, childFound [0], "child is orig") # this would be the parent parcelid that was NOT found, add to the list also
... View more
09-25-2019
03:58 PM
|
0
|
1
|
1876
|
|
POST
|
Joshua i really appreciate the code you posted. I am not sure if worked because i am having a hard time getting the a filed marked if it is an original but here are some things i noticed from the print. For example the code printed R37422 and when i cross check it with the parcel's there is no R37422, there is in fact an R37422010. So i am not sure as to why it indicated that there was R37422 as an original when there is no R37422 in the parcel's. The same thing for R39509, there is no R39509 but there is a R39509500. It appears as there is complete set of duplicate parcel numbers. tbl = 'C:/Temp/ParcelNumberSample2.dbf'
parcel_count = Counter(
(pid[:6] for pid, in arcpy.da.SearchCursor(tbl,"PARCEL_NO"))
)
for pid,cnt in parcel_count.items():
if cnt == 1:
print(pid)
with arcpy.da.UpdateCursor(tbl,["PARCEL_NO","Org_Par"]) as cursor:
for row in cursor:
if cnt == 1:
row[1] = "Orig"
cursor.updateRow(row)
else:
pass
... View more
09-25-2019
09:10 AM
|
0
|
0
|
1876
|
|
POST
|
Joshua, i appreciate the help. I am getting error, see below. Also how can i get this to this to put a mark in a another field vs just printing them? line 10, in <module> for pid,cnt in parcel_count.items(): AttributeError: 'generator' object has no attribute 'items' import arcpy
from collections import Counter
tbl = 'C:/Temp/ParcelNumberSample2.dbf'
parcel_count = (
(pid[:6] for pid, in arcpy.da.SearchCursor(tbl,"PARCEL_NO"))
)
for pid,cnt in parcel_count.items():
if cnt == 1:
print(pid)
... View more
09-24-2019
12:09 PM
|
1
|
4
|
2495
|
|
POST
|
Your assumption is correct, i haven't thought about marking duplicate original numbers. If there is a duplicate but no child parcel numbers then I would like this one marked as original parcel.
... View more
09-24-2019
08:06 AM
|
0
|
0
|
1876
|
|
POST
|
Yes it's always 6 characters, R00062 would seem like it's an original parcel but there could be R00062010 or R00062010 or R00062011 or R00062012 (These would be considered child parcels) but some how it needs to check to see if R00062 (6 characters) are used in other parcel numbers. This parcel would not be considered an original parcel because it's has child parcel numbers.
... View more
09-24-2019
08:04 AM
|
0
|
8
|
2495
|
| 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 |
09-10-2024
10:42 AM
|