|
POST
|
Could you send me a subset of the data? You can send me a private message with zipped attachment by clicking on my user name > Private Message.
... View more
07-03-2012
10:18 AM
|
0
|
0
|
2622
|
|
POST
|
Here are a couple functions you can use to get the prefix, street name, and suffix. You would need to make some minor changes to get this to work in the field calculator. def prefix(): rows = arcpy.UpdateCursor(table) for row in rows: if len(row.FullAddr.split(" ")[0]) == 1: row.Prefix = row.FullAddr[0] rows.updateRow(row) del row, rows def suffix(): rows = arcpy.UpdateCursor(table) for row in rows: row.Suffix = row.FullAddr.split(" ")[-1] rows.updateRow(row) del row, rows def street(): rows = arcpy.UpdateCursor(table) for row in rows: if len(row.FullAddr.split(" ")[0]) == 1: row.Street = ' '.join(row.FullAddr.split(" ")[1:-1]) rows.updateRow(row) else: row.Street = ' '.join(row.FullAddr.split(" ")[0:-1]) rows.updateRow(row) del rows, row prefix() suffix() street()
... View more
07-02-2012
08:15 AM
|
0
|
0
|
3375
|
|
POST
|
Try changing your Search and Update cursors to:
rows = arcpy.SearchCursor(infc,"","","","ID A")
rows = arcpy.UpdateCursor(tbl,"","","","ID A") The 'A' after ID will sort the fields in Ascending order. Let me know if you receive the same error.
... View more
07-02-2012
02:50 AM
|
0
|
0
|
2622
|
|
POST
|
Hi Susie, Are you trying to update a field within a table with a field within a feature class, where the table and feature class share a common ID? If that is correct, you could do this using data dictionaries. The code below is going to update a field called 'Name' within the Airports_Info table from a field also called 'Name' in the Airports feature class. The unique ID between the two is the field OBJECTID in the feature class, and ID in the table. table = "Airports_Info"
fc = "Airports"
fcDict = {}
rows = arcpy.SearchCursor(fc, "", "", "", "OBJECTID A")
for row in rows:
fcDict[row.OBJECTID] = row.Name
del rows, row
x = 0
rows = arcpy.UpdateCursor(table, "", "", "", "ID A")
for row in rows:
if row.ID == fcDict.keys() :
row.Name = fcDict[row.ID]
rows.updateRow(row)
print "Successfully updated row"
x += 1
del rows, row
... View more
06-29-2012
11:12 AM
|
0
|
0
|
2622
|
|
POST
|
Have you tried using a different workspace. The number of spaces that are in your current workspace may be causing issues. Attached is a File Geodatabase and MXD that you can test with. Create a folder called 'Temp' on you C: drive and extract the contents of the zip there, then execute the following within ArcMap while the MXD is open:
import arcpy
import os
mxd = arcpy.mapping.MapDocument("CURRENT")
arcpy.env.workspace = "C:/Temp"
arcpy.env.overwriteOutput = True
arcpy.CopyFeatures_management("Trapper Lines","Trapper_copy")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
extent = df.extent
array = arcpy.Array()
array.add(extent.lowerLeft)
array.add(extent.lowerRight)
array.add(extent.upperRight)
array.add(extent.upperLeft)
array.add(extent.lowerLeft)
poly = arcpy.Polygon(array)
arcpy.Clip_analysis("Trapper_copy",poly,"Trapper_Extent")
... View more
06-28-2012
01:25 PM
|
0
|
0
|
995
|
|
POST
|
It doesn't look like you are specifying the .shp extension when you are executing the 'CopyFeatures' function. Since your workspace is set to a folder, you will need to specify the extension. Try the following and see if it works:
arcpy.CopyFeatures_management("LINE DATA & DISPOSITIONS/Trapper Lines","Trapper_copy.shp")
... View more
06-28-2012
01:11 PM
|
0
|
0
|
995
|
|
POST
|
Try changing your workspace to the following: env.workspace = "database connections\connection to db.sde" You are missing the '.sde' for the connection file, and you will not have to specify the database name and owner. Python will use the credentials stored within the SDE connection file.
... View more
06-27-2012
04:28 AM
|
0
|
0
|
4393
|
|
POST
|
Hi Devon, What is the input you are using for the Clip GP tool (i.e. shapefile, feature class)? I noticed there is a space in the name (Trapper Lines). Try renaming the shapefile/feature class and remove the space. When naming a shapefile, feature class, or table you should follow the 3 rules below: 1. Should not contain spaces 2. Should not begin with a number 3. Should not contain any special characters
... View more
06-26-2012
08:22 AM
|
0
|
0
|
524
|
|
POST
|
Hello, I need to load some geometries in an Oracle Locator database 11g using the native format sdo_geometry. 1. Am I able to load some shapefiles using ArcCatalog into sdo_geometry (without an SDE schema)? Thanks in advance, Ganael Yes, at 10.1 you can load shapefiles into a database just as you could for a geodatabase. http://events.esri.com/uc/QandA/index.cfm?fuseaction=answer&conferenceId=DD02CFE7-1422-2418-7F271831F47A7A31&questionId=3949
... View more
06-25-2012
08:45 AM
|
0
|
0
|
874
|
|
POST
|
Also, I noticed in your original code, you have the output dbf and kmz file as the same index for the arcpy.GetParameterAsText:
# OUTPUT DBF WITH CUSTOM NAME ##output_dbf = arcpy.GetParameterAsText(6) ##arcpy.TableToDBASE_conversion(MTM_shp, output_dbf) #OUTPUT KMZ WITH CUTOM NAME output_kmz = arcpy.GetParameterAsText(6) #output_kmz = arcpy.AddMessage("Output KMZ File: ") arcpy.LayerToKML_conversion(output_lyr, output_kmz, 10000) Change the OUTPUT KMZ to: output_kmz = arcpy.GetParameterAsText(7)
... View more
06-21-2012
06:28 AM
|
0
|
0
|
4319
|
|
POST
|
Hi Zack, It looks like you set the Input Coordinate system as the second parameter, so this will have an index of 1. Therefore, you will need to increase all of your index values for arcpy.GetParameterAsText (excluding arcpy.GetParameterAsText(0)) by 1 within your code. The ToolValidator should appear as below: def updateParameters(self):
if self.params[0].value:
sr = arcpy.Describe(self.params[0].value).spatialReference
self.params[1].value = sr.name
self.params[1].enabled = 0
return
... View more
06-21-2012
06:25 AM
|
0
|
0
|
4319
|
|
POST
|
Hi Matt, No reasoning, just wrote it out when I replied to the thread so I didn't have time to simplify the script. Yours will do exactly the same, just less lines of code.
... View more
06-20-2012
12:07 PM
|
0
|
0
|
2164
|
|
POST
|
One thing I forgot to mention is to make sure your data frame coordinate system matches that of your feature class.
... View more
06-20-2012
11:31 AM
|
0
|
0
|
2164
|
|
POST
|
Hi Devon, You could create a polygon object based on the MXD's data frame extent, and then use the object to clip the feature class. Here is an example: import arcpy
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\temp\python\test.gdb"
mxd = mapping.MapDocument(r"C:\temp\python\County.mxd")
df = mapping.ListDataFrames(mxd)[0]
xmin = df.extent.XMin
ymin = df.extent.YMin
xmax = df.extent.XMax
ymax = df.extent.YMax
pnt1 = arcpy.Point(xmin, ymin)
pnt2 = arcpy.Point(xmin, ymax)
pnt3 = arcpy.Point(xmax, ymax)
pnt4 = arcpy.Point(xmax, ymin)
array = arcpy.Array()
array.add(pnt1)
array.add(pnt2)
array.add(pnt3)
array.add(pnt4)
array.add(pnt1)
poly = arcpy.Polygon(array)
arcpy.Clip_analysis("Hospitals", poly, "Hospitals_clip")
del mxd
... View more
06-20-2012
09:11 AM
|
0
|
0
|
2164
|
|
POST
|
Can you send a screen shot of your Properties tab within the script properties? Depending on where you have the parameter set up for the coordinate system you will have to change index values for the 'arcpy.GetParameterAsText' function, and the self.params within the ToolValidator.
... View more
06-20-2012
03:09 AM
|
0
|
0
|
4319
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 4 | 05-07-2020 05:14 PM | |
| 1 | 03-25-2026 04:16 AM | |
| 1 | 03-16-2026 01:00 PM | |
| 1 | 12-22-2025 10:39 AM |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|