POST
|
I am trying to use the updateCursor but with little luck... What I would like to do is copy field values from an existing field in the table to a newly created field in the table. The issue I am having is that some tables have different name values and field types. I wonder if I am overcomplicating the whole issue or if I am setting something up incorrectly. I am just not sure at this point. Any insight and help with this will be greatly appreciated! I am getting error 999999 on "return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))". for filename in filenames:
if fnmatch.fnmatch(filename, "*Anno*") == True:
print "Skipped annotation file: " + filename
elif fnmatch.fnmatch(filename, "*grid*") == True:
print "Skipped grid file: " + filename
else:
#LOOP FIELDS
fieldList = arcpy.ListFields(os.path.join(dirpath, filename))
for field in add_Fields:
if field[0] in [f.name for f in fieldList]:
print "Field name: " + field[0] + " exists in " + filename + " DO NOT ADD"
else:
print "Adding " + field[0] + " name to table " + filename
arcpy.AddField_management(*(os.path.join(dirpath, filename),) + field)
#create field search list
possibleSearchFields = ["ENG_NAME", "Name"]
updateField = ["New_Name"]
searchFields = []
#Loop through possibleSearchFields
for psf in possibleSearchFields:
if psf in [f.name for f in fieldList]:
#add to searchFields
searchFields.append(psf)
#LOOP ROWS
cur = arcpy.UpdateCursor(os.path.join(dirpath, filename))
for row in cur:
for searchField in searchFields:
if row.getValue(updateField) == None:
print searchField + "exists in the table and is updating: " + filename
row.setValue(updateField, row.getValue(searchField))
else:
print " No name field in the search list: " + filename Thank you Chris
... View more
03-30-2015
08:33 AM
|
0
|
8
|
7712
|
POST
|
I am trying to setup a simple batch copy features tool. I would like to have a simple tool where the user adds input features and specifies the output location. I tested and it works like this: import arcpy
from arcpy import env
import os
arcpy.env.overwriteOutput = True
inFC = r"M:\Destinations"
outWorkspace = r"M:\OtherLayers"
variable = "TEST"
arcpy.env.workspace = inFC
fcList = arcpy.ListFeatureClasses()
#Export the feature classes
for fc in fcList:
print fc
outFC = os.path.join(outWorkspace, fc + "_" + variable)
arcpy.CopyFeatures_management(fc, outFC)
print "Finished" When I set it up as a tool with this code: import arcpy
from arcpy import env
import os
arcpy.env.overwriteOutput = True
inFC = arcpy.GetParameterAsText(0)
outWorkspace = arcpy.GetParameterAsText(1)
variable = arcpy.GetParameterAsText(2)
arcpy.AddMessage(inFC)
arcpy.env.workspace = inFC
fcList = arcpy.ListFeatureClasses()
#Export the feature classes
for fc in inFC.split(";"):
outFC = os.path.join(outWorkspace, fc + "_" + variable)
arcpy.AddMessage(outFC)
arcpy.CopyFeatures_management(fc, outFC) It runs but saves the copies in the input directory and ignores the outWorkspace all together. I have set the output parameters as: Datatype = folder & Direction = output. Am I setting this up incorrectly? Is there something with setting up as a tool that I am missing all together? Any help is greatly appreciated! *EDIT* I thought I would add the working code here to help anyone if they have a similar issue. import arcpy
import os
inFC = arcpy.GetParameterAsText(0)
addText = arcpy.GetParameterAsText(1)
outWorkspace = arcpy.GetParameterAsText(2)
arcpy.AddMessage(inFC)
for fc in inFC.split(";"):
outFC = os.path.join(outWorkspace, os.path.basename(fc).split(".")[0] + "_" + addText)
arcpy.AddMessage(outFC)
arcpy.CopyFeatures_management(fc, outFC) Thanks
... View more
12-08-2014
11:59 AM
|
0
|
2
|
2260
|
POST
|
That's what I would have thought, but it says username/password are incorrect (they are!). Maybe it has something to do with testing the HTML locally. Alright, well thanks again! Cheers Chris
... View more
08-15-2014
10:21 AM
|
0
|
0
|
628
|
POST
|
This might be a silly question but if I don't make the tiles public it's behind a password that aren't my login credentials(arc onlin). Any thoughts on this? -Chris
... View more
08-15-2014
09:53 AM
|
0
|
2
|
628
|
POST
|
is it the same URl I use here?
var tiles = new Tiles("https://tiles.arcgis.com/tiles/.../arcgis/rest/services/ECU_Tiles/MapServer");
... View more
08-15-2014
09:23 AM
|
0
|
5
|
628
|
POST
|
Do you know what I use in the require as my URL or where to find that? I am very new to ArcGIS Online
require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer("my URL?")", "dojo/domReady!"],
Thanks! -Chris
... View more
08-15-2014
09:20 AM
|
0
|
0
|
628
|
POST
|
Hello I am wondering if I can use ArcGIS Online similar to ArcServer? I am trying to upload tiles to arc online then use them with the API (see below):
<script>
var map;
require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer("my URL?")", "dojo/domReady!"],
function(Map, Tiles) {
map = new Map("map", {basemap: "streets",
center: [-78.785706, -1.774008], // longitude, latitude
zoom: 7});
var tiles = new Tiles("https://tiles.arcgis.com/tiles/.../arcgis/rest/services/ECU_Tiles/MapServer");
map.addLayer(tiles);
}
);
</script>
I am not sure what the the ("my URL") would be using arcgis online... unless I can't in which case it would make more sense. Any help and or suggestions are greatly appreciated! -Chris
... View more
08-15-2014
09:12 AM
|
0
|
9
|
1271
|
POST
|
Thanks for the idea! Working code below: var = ["'\'Name"]
... View more
07-28-2014
05:55 AM
|
0
|
0
|
770
|
POST
|
Hello How do I handle ' in an attribute table using python? Example
var = ["'Name"]
any help is greatly appreciated! Cheers Chris
... View more
07-25-2014
11:07 AM
|
0
|
3
|
1555
|
POST
|
for filename in filenames:
if "TOD" in [f.name for f in arcpy.ListFields(os.path.join(dirpath, filename))]:
for letter in ['A', 'B']:
newFC = r"C:/testGDB.gdb/Layer_%s/%s_%s" % (letter, filename, letter)
if arcpy.Exists(newFC):
arcpy.Delete_management(newFC)
arcpy.Select_analysis(os.path.join(dirpath, filename), newFC, '"TOD" = \'%s\'' % (letter)) Thank you for the reply. I get error: 000210. Which is strange as there is no lock, the path is right and the file does not currently exist.
... View more
06-19-2014
11:02 AM
|
0
|
0
|
282
|
POST
|
Hello I would like to use arcpy.Exists() to handle existing featureclasses in a file-GDB but am having a problem with the argument. The problem (for me) stems from splitting a single featureclass into 2 new layers into 2 separate geodatasets. ex. Layer1 becomes Layer1_A and layer1_B from attributes A and B and are placed into datasets A and B respectively. This is all good, but when I run the script again, the files would need to be either over written (arcpy.env.overwriteOutput = True) or ignored. So I turned to arcpy.Exists(). But since the select_analysis is running twice and adding '_A' and '_B' I am not sure how to handle the argument. Any help or suggestions are greatly appreciated! Sample code:
for filename in filenames:
if "TOD" in [f.name for f in arcpy.ListFields(os.path.join(dirpath, filename))]:
if not arcpy.Exists(#Something to handle A and B):
arcpy.Select_analysis(os.path.join(dirpath, filename), r"C:/testGDB.gdb/Layer_A/" + filename + "_A", '"TOD" = \'A\'')
arcpy.Select_analysis(os.path.join(dirpath, filename), r"C:/testGDB.gdb/Layer_B/" + filename + "_B", '"TOD" = \'B\'')
else:
print "Already exists"
... View more
06-19-2014
08:00 AM
|
0
|
2
|
799
|
POST
|
Hello This might be a silly question but what is the best way to define an urban center. Is there a certain threshold to consider? Is it best to classify it by using LANDSAT? Thanks for any help.
... View more
05-07-2014
01:27 PM
|
0
|
0
|
1550
|
POST
|
this is most likely due to how the controls behave in terms of the control being resized. You will need to look at the docking properties of each control to see how they are configured and change them to handle resizing. Thanks for your reply. Unless I'm not understanding your suggestion, that did not work.
... View more
12-04-2013
10:45 AM
|
0
|
0
|
213
|
Title | Kudos | Posted |
---|---|---|
1 | 04-09-2015 02:58 PM | |
1 | 04-09-2015 03:20 PM | |
1 | 04-10-2015 07:36 AM |
Online Status |
Offline
|
Date Last Visited |
11-29-2021
12:15 PM
|