|
POST
|
I understand how to do it through ArcCatalog and manually, i was trying to do this trough python. The "Subject_property" needs to be updated before the "NOTIFBUF1" because of the processes.
... View more
08-27-2015
11:42 AM
|
0
|
0
|
1679
|
|
POST
|
The mxd template has four layers that need the datasource updated. I just put two on the script i posted cuz i was trying to figure out what was going on.
... View more
08-27-2015
11:38 AM
|
0
|
1
|
1679
|
|
POST
|
When i first open my mxd the layers "Subject_property" & "NOTIFBUFI" data source are not there, it has a red exclamation point. I run the script which creates the "Subject_property" & "NOTIFBUFI" to the mxd folder, then i been trying to use the lyr.replaceDataSource process to set the data source to the newly created "Subject_property" & "NOTIFBUFI". I guess i am confused i should be using something else and why does It works if i remove the two arcpy.MultipleRingBuffer_analysis
... View more
08-27-2015
11:24 AM
|
0
|
3
|
1679
|
|
POST
|
I am having issues with lyr.replaceDataSource, I have an mxd that has layers with symbol that i need to just update the layers after some process are ran, there is a few layers i need to update but for some reason it only replace the first lyr.replaceDataSource but after the first one it removes the layer from the TOC, then it adds it back. The script runs and updates both layers fine if i remove both arcpy.MultipleRingBuffer_analysis (lines 20&21), but when i add it back it does what i described. Any help would be gratefully appreciated. import arcpy, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "SUBJECT_PROPERTY")[0]
arcpy.env.workspace = os.path.dirname(mxd.filePath)
wp = os.path.dirname(mxd.filePath)
SP = "SUBJECT_PROPERTY"
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
if lyr.name == "SUBJECT_PROPERTY":
lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", SP, "")
del mxd, lyr
arcpy.MultipleRingBuffer_analysis(SP, "1_2",[1,2],"Miles","ToBufDist","ALL" )
arcpy.MultipleRingBuffer_analysis(SP, "NOTIFBUF1",[600],"Feet","ToBufDist","ALL")
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "NOTIFBUF1")[0]
NF = "NOTIFBUF1"
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
if lyr.name == "NOTIFBUF1":
lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", NF, "")
#mxd = arcpy.mapping.MapDocument("CURRENT")
#lyr = arcpy.mapping.ListLayers(mxd, "NOTIFBUF1")[0]
#lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", "NOTIFBUF1", True)
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
... View more
08-27-2015
10:32 AM
|
0
|
8
|
4562
|
|
POST
|
ok, so if no records are found in line 35, then at 39 it's selecting all records because nothing was found. So how can i by pass line 35 in case nothing is found?
... View more
08-20-2015
02:32 PM
|
0
|
1
|
1003
|
|
POST
|
I have a script here and seems simple enough but for some reason after the script is done it creates an empty feature class. I don't get any errors.. Am i missing something? # Import arcpy module
import arcpy
import os
from arcpy import env
from datetime import datetime as d
startTime = d.now()
arcpy.env.workspace = "C:\GIS\weeds\Weeds.gdb"
arcpy.env.overwriteOutput = "True"
arcpy.env.qualifiedFieldNames = False
CITY = "C:\GIS\weeds\Weeds.gdb\City_Limits"
Taxparcels = "C:\GIS\weeds\Weeds.gdb\Parcels"
ADMIN = "C:\GIS\weeds\Weeds.gdb\ADMIN"
temp = "C:\GIS\weeds\Weeds.gdb"
# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(Taxparcels, "In_memory\Par")
# Process: Analysis Erase
arcpy.Erase_analysis("In_memory\Par", CITY, "In_memory\Par_ERASE","")
arcpy.MakeFeatureLayer_management("In_memory\Par_ERASE", "In_memory\Par1")
# Process: Add Join
try:
arcpy.AddJoin_management("In_memory\Par1", "ACCOUNT", ADMIN, "Acct", "KEEP_ALL")
except BaseException as e:
pass
#arcpy.FeatureClassToFeatureClass_conversion("In_memory\Par1", temp, "TaxWeed1")#working
arcpy.MakeFeatureLayer_management("In_memory\Par1", "In_memory\Par2")
# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management("In_memory\Par2", "NEW_SELECTION", "\"TEXT\" = 'common area'")
# Process: Delete Features
if int(arcpy.GetCount_management("In_memory\Par2").getOutput(0)) > 0:
arcpy.DeleteFeatures_management("In_memory\Par2")
# Process: Make Feature Layer (2)
TaxPar2 = "weedtax"
arcpy.MakeFeatureLayer_management("In_memory\Par2", TaxPar2)
arcpy.FeatureClassToFeatureClass_conversion(TaxPar2, temp, "TaxWeed")
arcpy.Delete_management("In_memory\Par")
arcpy.Delete_management("In_memory\Par1")
arcpy.Delete_management("In_memory\Par2")
arcpy.Delete_management("In_memory\Par_ERASE")
#arcpy.Delete_management("In_memory\ParCel")
try:
print '(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')'
except Exception, 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
... View more
08-20-2015
02:02 PM
|
0
|
3
|
3885
|
|
POST
|
I am making sure that i am in the same spatial reference with the following. mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
dfsr = df.spatialReference
fcsr = arcpy.Describe(pointFC).spatialReference
if dfsr.name == fcsr.name:
... View more
08-14-2015
07:23 AM
|
0
|
2
|
2221
|
|
POST
|
I have tried to edit my original and my second post with firefox, explorer and Chrome and they all do the same thing. When i select the python text and click on insert syntax highlighting then select python it puts the code in python format but once i hit save reply it shows my post but it's back to plan text. WTH is going on?
... View more
08-14-2015
07:03 AM
|
0
|
0
|
1196
|
|
POST
|
For some weird reason it lets me format the code to python when i first posted but noticed that it was just plain text after i posted, i tried to go edit my first post and it seems like it will let me format the text to python but when i hit post it goes back to plan text. #import modules import arcpy # Allow overwrite arcpy.env.overwriteOutput = True arcpy.env.qualifiedFieldNames = False # Script user input parameters pointFC = "CCA parcel = "Parcels1" #Taxparcels arcpy.env.workspace = r"C:\Temp\Default.gdb" parcel_lyr = 'parcel_lyr' sjpoints = "C:\Temp\Default.gdb\sjpoints" poly = "ACCOUNT_1" Pnt = "Account" 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) insCursor = arcpy.da.InsertCursor(pointFC,'SHAPE@XY') # create insert cursor arcpy.MakeFeatureLayer_management(parcel,parcel_lyr) arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",point) #Run the Spatial Join tool, using the defaults for the join operation and join type arcpy.SpatialJoin_analysis(point, parcel_lyr , sjpoints) #arcpy.FeatureClassToFeatureClass_conversion(parcel_lyr, "C:\Temp\Default.gdb", "parcel_lyr") # define the field list from the spatial join sourceFieldsList = ["TARGET_FID", poly,"SiteAddress",'SiteNum_1', 'SiteStreet_1','SiteStreet_1','SiteNumSfx_1','Predir_1','Postdir_1', 'SiteCity_1', 'SiteZIP_1', 'OwnerName_1'] # define the field list to the original points updateFieldsList = ["OID@", Pnt,"SiteAddres",'SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName'] # populate the dictionary from the polygon valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)} with arcpy.da.UpdateCursor(point, updateFieldsList) as updateRows: for updateRow in updateRows: keyValue = updateRow[0] if keyValue in valueDict: for n in range (1,len(sourceFieldsList)): updateRow = valueDict[keyValue][n-1] updateRows.updateRow(updateRow) #arcpy.FeatureClassToFeatureClass_conversion(point, "C:\Temp\Default.gdb", "p_lyr") with arcpy.da.SearchCursor(point,('Account','SiteAddres','SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName')) as cursor: # loop through feature set for row in cursor: row = [] insCursor.insertRow(row) arcpy.RefreshActiveView() edited by Xander Bakker, formated code
... View more
08-14-2015
06:50 AM
|
0
|
12
|
2221
|
|
POST
|
i have a code that has two issues 1. only one point gets updated with the parcel attributes no other points get updated and 2. the insertRow i currently have does not work it give me . line 63, in <module> insCursor.insertRow(row) TypeError: sequence size must match size of the row basically i am trying to create multiple points that spatially joins the new created points to parcels and updates the points attributes based on what parcel the points are created i am not sure why i am getting the following error. line 63, in <module> insCursor.insertRow(row) TypeError: sequence size must match size of the row I have checked to see if the "point" is being updated by the updatecursor with arcpy.FeatureClassToFeatureClass_conversion(point, "C:\Temp\Default.gdb", "p_lyr") after updateRows.updateRow(updateRow) and it looks like only one point gets updated. Separate question, Can i use the SpatialJoin to "In_memory" instead of to a gdb? I would really appreciate some help please. working with. #import modules import arcpy # Allow overwrite arcpy.env.overwriteOutput = True arcpy.env.qualifiedFieldNames = False # Script user input parameters pointFC = "CCA parcel = "Parcels1" #Taxparcels arcpy.env.workspace = r"C:\Temp\Default.gdb" parcel_lyr = 'parcel_lyr' sjpoints = "C:\Temp\Default.gdb\sjpoints" poly = "ACCOUNT_1" Pnt = "Account" 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) insCursor = arcpy.da.InsertCursor(pointFC,'SHAPE@XY') # create insert cursor arcpy.MakeFeatureLayer_management(parcel,parcel_lyr) arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",point) #Run the Spatial Join tool, using the defaults for the join operation and join type arcpy.SpatialJoin_analysis(point, parcel_lyr , sjpoints) #arcpy.FeatureClassToFeatureClass_conversion(parcel_lyr, "C:\Temp\Default.gdb", "parcel_lyr") # define the field list from the spatial join sourceFieldsList = ["TARGET_FID", poly,"SiteAddress",'SiteNum_1', 'SiteStreet_1','SiteStreet_1','SiteNumSfx_1','Predir_1','Postdir_1', 'SiteCity_1', 'SiteZIP_1', 'OwnerName_1'] # define the field list to the original points updateFieldsList = ["OID@", Pnt,"SiteAddres",'SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName'] # populate the dictionary from the polygon valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)} with arcpy.da.UpdateCursor(point, updateFieldsList) as updateRows: for updateRow in updateRows: keyValue = updateRow[0] if keyValue in valueDict: for n in range (1,len(sourceFieldsList)): updateRow = valueDict[keyValue][n-1] updateRows.updateRow(updateRow) #arcpy.FeatureClassToFeatureClass_conversion(point, "C:\Temp\Default.gdb", "p_lyr") with arcpy.da.SearchCursor(point,('Account','SiteAddres','SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName')) as cursor: # loop through feature set for row in cursor: row = [] insCursor.insertRow(row) arcpy.RefreshActiveView()
... View more
08-13-2015
02:01 PM
|
0
|
15
|
6379
|
|
POST
|
ok, your using arcpy.ImportMetadata_conversion try using MetadataImporter_conversion try something like. # Local variables... sde_DEVGIS_Wetlands = "Database Connections\\HOU-SRVRNPRD2 (devgis - sde).sde\\sde.DEVGIS.DevelopmentAndTesting\\sde.DEVGIS.Wetlands" Wetlands_xml = "K:\\GIS Data\\Metadata\\Wetlands.xml" arcpy.MetadataImporter_conversion(Wetlands_xml, sde_DEVGIS_Wetlands)
... View more
08-13-2015
01:18 PM
|
0
|
2
|
1846
|
|
DOC
|
you first said "after you have done that then go configure the app in app builder" but i have already configured the app, then you said change the name of a eSrach layer, sybmology any of the options, does it have to be an actual layer or a made up one? So after i replace the eSearch file in stemapp i change change a layer name in the eSarch/config_EnhancedSearch.json file i save it, do i go back and undo the change and re-save. please forgive my ignorance. What i did was replace the eSearch folder in the stemap folder then the appbuilder and opened the eSarch/config_EnhancedSearch.json changed a layers URL from FeatureSever/2 to Feature Server/3 and saved. I exited out of appbuilder and change FeatureServer/3 back to FeatureServer/2 and saved, then re-opend appbuilder. is this acquit enough?
... View more
07-27-2015
12:27 PM
|
0
|
0
|
7471
|
|
POST
|
sorry, i was out for the weekend. I was not able to get the code to allow me to create multiple points. i a not sure what if sr ==sr: is doing other then comparing two values.
... View more
07-27-2015
09:05 AM
|
0
|
0
|
1449
|
|
POST
|
I was able to get to work with the following. I couldn't get to work correctly with the arcpy.PointGeometry.projectAs my apologies as i am trying to learn python, thanks to all who replied. #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
arcpy.env.qualifiedFieldNames = False
point = arcpy.GetParameterAsText(0) #point boolen
targetpoint = "CCAP2" #target point feature class
parcel = "parcels" #target feature class
parcel_lyr = 'parcel_lyr'
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
x,y = prow[0]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
latLonRef = "Coordinate Systems\Geographic Coordinate Systems\North America\NAD 1983.prj"
featureClasses = point
featureClassesList = featureClasses.split(";")
for featureClass in featureClassesList:
rows = arcpy.UpdateCursor(point, "", latLonRef)
for row in rows:
feat = row.getValue("shape")
centroid = feat.centroid
x= centroid.X
y= centroid.Y
rows.updateRow(row)
CC_list = []
with arcpy.da.SearchCursor(targetpoint, ["AddressID"]) as cursor:
for row in cursor:
try:
if "CC" in row[0]:
CC_list.append(int(row[0].strip("CC")))
except TypeError:
pass
del cursor
CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['ACCOUNT','OwnerName','SiteAddres','SiteNum','siteNumSfx','Predir','SiteStreet', 'StreetType', 'Postdir', 'SiteCity', 'SiteZip']
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 = ['ACCOUNT', 'OwnerName', 'SiteAddres', 'SiteNum', 'siteNumSfx', 'Predir', 'Postdir', 'SiteCity', 'SiteZip',
'SiteState', 'FacltyType', 'StructType', 'GIS_STEW', 'UpdateBy', 'Verified', 'Status', 'StructCat', 'APA_CODE',
'AddressID', 'POINT_X', 'POINT_Y', 'StreetName','SHAPE@XY']
tprows = arcpy.da.InsertCursor(targetpoint, targetFields)
row = []
#Attributes from parcels
row.append(fldDict['ACCOUNT'])
row.append(fldDict['OwnerName'])
row.append(fldDict['SiteAddres'])
row.append(fldDict['SiteNum'])
row.append(fldDict['siteNumSfx'])
row.append(fldDict['Predir'])
row.append(fldDict['Postdir'])
row.append(fldDict['SiteCity'])
row.append(fldDict['SiteZip'])
#Preset attributes
row.append('ID')
row.append('Single Family Home')
row.append('Primary, Private')
row.append('CanyonCo')
row.append('TA')
row.append("Yes, GRM, TA")
row.append('Active')
row.append('Residential')
row.append('1110')
row.append(AddressID)
row.append(x)
row.append(y)
row.append(fldDict['SiteStreet'] + " " + fldDict['StreetType'])
row.append(point1)
tprows.insertRow(row)
arcpy.RefreshActiveView()
del tprows
#convert x,y to lat & long
... View more
07-22-2015
03:37 PM
|
0
|
2
|
1010
|
| 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
|