POST
|
what i found was i had to include line 29, make feature layer from the feature class that was created after the join. I guess i can't use in_memory in the field mapping...? I swear it worked in 10.2.2
... View more
09-28-2016
02:45 PM
|
0
|
0
|
273
|
POST
|
If i add more than two quotations marks i get invalid Syntax. Did something change for filed mapping in 10.3.1? I am confused as to why this simple script doesn't run.
... View more
09-27-2016
03:37 PM
|
0
|
0
|
273
|
POST
|
i upgraded from 10.2.2 to 10.3.1 and now my script does not run properly. It runs all they way and doesn't give an error. The join runs fin and it creates the feature class but when i check feature class "NotifiLotsTest" all the fields are Null. It ran fine in 10.2.2 so i am not sure what's going on with it now, something to do with the field mapping???.. help please i am lost it's a simple script but i can't figure out what's going on.... arcpy.env.qualifiedFieldNames = False
arcpy.env.overwriteOutput = True
Taxparcels = r"Database Connections\Taxparcels"
Table = r"Database Connections\Table"
fc = "C:/Temp/Test.gdb/NotifLotsTest"
#Delete feature class if it exists
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
fc1 = "C:/Temp/Test.gdb/NotifTest"
#Delete feature class if it exists
if arcpy.Exists(fc1):
arcpy.Delete_management(fc1)
# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(Taxparcels, "In_memory\TaxPar")
# Process: Add Join
arcpy.AddJoin_management("In_memory\TaxPar", "ACCOUNT", Table, "Acct")
#check to make sure Joined Feature class is being generated
arcpy.FeatureClassToFeatureClass_conversion("In_memory\TaxPar","C:/Temp/Test.gdb/", "NotifTest")
TaxPar1 = "In_memory\TaxPar"
#arcpy.MakeFeatureLayer_management("C:/Temp/Test.gdb//NotifTest",TaxPar1)
#Field Mapping
def Layers0(TaxPar1):
FieldMapString = "" \
+ """DXF_TEXT "DXF_TEXT" true true false 20 Text 0 0 ,First,#,""" + TaxPar1 + """,DXF_TEXT,-1,-1;"""\
+ """ACCOUNT "ACCOUNT" true true false 11 Text 0 0 ,First,#,""" + TaxPar1 + """,ACCOUNT,-1,-1;"""\
+ """OwnerName "OwnerName" true true false 100 Text 0 0 ,First,#,""" + TaxPar1 + """,OwnerName,-1,-1;"""\
+ """Address "Address" true true false 64 Text 0 0 ,First,#,""" + TaxPar1 + """,Address,-1,-1;"""\
+ """City "City" true true false 32 Text 0 0 ,First,#,""" + TaxPar1 + """,City,-1,-1;"""\
+ """State "State" true true false 4 Text 0 0 ,First,#,""" + TaxPar1 + """,State,-1,-1;"""\
+ """ZipCode "ZipCode" true true false 10 Text 0 0 ,First,#,""" + TaxPar1 + """,ZipCode,-1,-1;"""\
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.FeatureClassToFeatureClass_conversion(TaxPar1, "C:/Temp/Test.gdb/", "NotifLotsTest", "", Layers0(TaxPar1),"")
... View more
09-27-2016
01:53 PM
|
0
|
5
|
965
|
POST
|
ok, i would like to create points to a point layer by mouse click . Some times i will only create one point and some times 5,10, etc. I need the points to update certain attributes from the parcels they are created on top of at that time. thanks for the reply.
... View more
08-14-2015
01:39 PM
|
0
|
3
|
330
|
POST
|
I have tried the following and both give me errors. with arcpy.da.SearchCursor(point,('Account','SiteAddres','SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName')) as cursor: # 'POINT_X', 'POINT_Y','SHAPE@XY'# loop through feature set
for row in cursor:
row =[
None, #Account
None, #SiteAddres
None, #SiteNum
None, #StreetName
None, #SiteStreet
None, #SiteNumSfx
None, #Predir
None, #Postdir
None, #SiteCity
None, #SiteZip
None,#OwnerName
]
insCursor.insertRow(row) error insCursor.insertRow(row) TypeError: sequence size must match size of the row AND with arcpy.da.SearchCursor(point,('Account','SiteAddres','SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName')) as cursor: # 'POINT_X', 'POINT_Y','SHAPE@XY'# loop through feature set
for row in cursor:
row [0] = row[0] #Account
row [1] = row[1] #SiteAddres
row [2] = row[2] #SiteNum
row [3] = row[3] #StreetName
row [4] = row[4] #SiteStreet
row [5] = row[5] #SiteNumSfx
row [6] = row[6] #Predir
row [7] = row[7] #Postdir
row [8] = row[8] #SiteCity
row [9] = row[9] #SiteZip
row [10] = row[10] #OwnerName
insCursor.insertRow(row) error row [0] = row[0] #Account TypeError: 'tuple' object does not support item assignment
... View more
08-14-2015
10:49 AM
|
0
|
6
|
747
|
POST
|
Have you tired using full paths for your parameters, unc pathnames? Pathnames explained: Absolute, relative, UNC, and URL Assigning UNC Path to arcpy.env.workspace - Geographic Information Systems Stack Exchange
... View more
08-13-2015
11:08 AM
|
0
|
4
|
607
|
POST
|
Hi Joshua. I was trying to understand how to create a point or multiple points and how those new points attributes populated from the parcel the new points are within. The x,y would be calculated at the time the new point or points are created. I am rather new to python so my first posted code was based on information i found.
... View more
08-12-2015
09:25 AM
|
0
|
3
|
357
|
POST
|
Randy i have a script that is pretty much identical to the one you posted. It currently only works for existing points. The script i am looking to build would create multiple points and uses dictionaries and list, they seem to run faster then actual joins. I am having a hard time coming up with the correct code to create multiple points. I do appreciate the response and suggestion.
... View more
08-11-2015
11:58 AM
|
0
|
0
|
786
|
POST
|
I tied change my code, i am close i don't get an error but the only thing that gets populated is the X,Y for each point. Current code, i have pieced some of these codes from other codes the best why i can. i really appreciate some help please... #import modules
import arcpy
arcpy.env.qualifiedFieldNames = False
pointFC = "Animal Sightings" #target point feature class Animal Sightings
parcel = "par"
parcel_lyr = 'parcel_lyr'
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
dfsr = df.spatialReference
fcsr = arcpy.Describe(pointFC).spatialReference
if dfsr.name == fcsr.name:
"""Now do your work"""
point = arcpy.GetParameterAsText(0) #click
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
x,y = prow[0]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
rows = arcpy.UpdateCursor(point)
for row in rows:
feat = row.getValue("shape")
cent = feat.centroid
row.POINT_X = cent.Y
row.POINT_Y = cent.X
rows.updateRow(row)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['Owner','Site']
fldDict ={}
#Check that we only have one parcel and get the attributes from it
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))>=1:
for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):
for w in range(len(fldList)):
fldDict[fldList ]=parrow
del parrow
targetFields = ['Owner', 'Site', 'POINT_X', 'POINT_Y','SHAPE@XY']
insCursor = arcpy.da.InsertCursor(pointFC, ('Owner', 'Site','POINT_X', 'POINT_Y','SHAPE@XY')) # create insert cursor
with arcpy.da.InsertCursor(pointFC, ('Owner', 'Site','POINT_X', 'POINT_Y','SHAPE@XY')) as cursor:
with arcpy.da.SearchCursor(point, targetFields) as s_cursor:
for s_row in s_cursor:
cursor.insertRow(s_row)
del cursor
... View more
08-07-2015
11:49 AM
|
0
|
3
|
786
|
POST
|
Hi 2CDSD 2C, i am trying to do something very similar to what you are doing with this code. I would like to be able to create multiple points on different parcels at once. the current code only allows you to only create one point. Do you have a copy of this code that will allow for multiple points on different parcels? I have tried to change the ==1 to >=1 but nothing happened, my python skills are very limited.
... View more
08-07-2015
10:03 AM
|
0
|
0
|
90
|
POST
|
Darren. thank you for your time and responses. i apologize for my python skills are not so great.
... View more
08-06-2015
03:57 PM
|
0
|
0
|
357
|
Title | Kudos | Posted |
---|---|---|
2 | 07-30-2015 01:52 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|