|
POST
|
Make sure len(Bld_list) > 0. If the list is empty, there is no item at Bld_list[-1].
... View more
09-10-2015
09:36 AM
|
0
|
2
|
3132
|
|
POST
|
You can modify Jake Skinner's code as below to accommodate DDPs (mostly tested): import arcpy
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\temp\Test.gdb"
extents = []
mxd = mapping.MapDocument(r"C:\temp\python\Philadelphia.mxd")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
dataframe = mapping.ListDataFrames(mxd, "*")[0]
frameExtent = dataframe.extent
XMAX = frameExtent.XMax
XMIN = frameExtent.XMin
YMAX = frameExtent.YMax
YMIN = frameExtent.YMin
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)
polygon = arcpy.Polygon(array)
extents.append(polygon)
arcpy.CopyFeatures_management(extents, "Polygon_Extent")
... View more
09-10-2015
09:22 AM
|
0
|
10
|
6536
|
|
POST
|
I agree you don't need Exists. You could check the length of the returned list of feature classes to see if any match. len(wlFclass)
... View more
09-09-2015
04:02 PM
|
1
|
0
|
3016
|
|
POST
|
For what it's worth, running the built-in feature class level tools (Copy, then Append) seems to work about twice as fast as adding fields individually. See below where Test A uses feature class level tools and Test B uses field level tools (I believe these are comparing apples to apples, but I could be wrong). For small feature classes, the differences are pretty small, but for large datasets, the time difference could be considerable. I'd say the code is somewhat simpler, as well. import arcpy, time
# Set up shared conditions
arcpy.env.workspace = r'C:\junk\new_fields'
arcpy.env.overwriteOutput = True
template = 'template.shp' # the template FC
fcs = arcpy.ListFeatureClasses('*Copy*') # the "other" FCs
#############################################
# Test A
starttime1 = time.time()
outCounter = 1
for fc in fcs:
newCopy = "output_" + str(outCounter) + '.shp'
arcpy.Copy_management(template, newCopy)
arcpy.Append_management(fc, newCopy, 'NO_TEST')
outCounter += 1
endtime1 = time.time() - starttime1
print 'Total time: ' + str(endtime1) +'s' # about 3.5 seconds
############################################
# Test B
starttime2 = time.time()
fields = arcpy.ListFields(template)
allfields = []
for field in fields:
if field.name != 'FID' and field.name != 'Shape':
allfields.append([field.name , field.type , field.precision , field.scale, field.length, field.aliasName , field.isNullable , field.required])
for shape in fcs:
for field in allfields:
arcpy.AddField_management(shape , field[0] , field[1] , field[2], field[3], field[4] , field[5], field[6] , field[7])
endtime2 = time.time() - starttime2
print 'Total time: ' + str(endtime2) +'s' # about 7 seconds
... View more
09-09-2015
03:36 PM
|
0
|
5
|
10244
|
|
POST
|
You could: 1.) Copy your template shapefile 2.) Append the features from one of 20 shapefiles to the copy (Schema type = NO_TEST) ...and repeat.
... View more
09-09-2015
01:19 PM
|
1
|
0
|
1349
|
|
POST
|
Your expression would be: CityworksID=
myFunction(!CityworksID!, !Field1!, !Field2!) and the code block: def myFunction(cw, f1, f2):
if 'CP' not in cw:
return cw # or some other default
else:
return 'CP-' + f1 + str(f2)
... View more
09-09-2015
09:20 AM
|
0
|
1
|
2233
|
|
POST
|
Yes, but... - if he's already using the Aggregate tool, he must have ArcInfo - if you're automating the aggregate by attribute, then you may as well carry over the attribute at the same time (using Python)
... View more
09-08-2015
03:18 PM
|
1
|
7
|
1625
|
|
POST
|
Click the word "Count" to refresh the counts (not sure why this doesn't update automatically, but it doesn't). Have you added the values you want symbolize? Click "Add Values" or "Add All Values" to do so.
... View more
09-08-2015
02:47 PM
|
1
|
0
|
1540
|
|
POST
|
Since you mention Aggregating polygons and that Dissolve doesn't work, I assume you've tried the Aggregate tool...? Does it produce the results you're after, and you're looking for a way to automate cycling through each district, or does it not produce the results you want at all? Is this the situation you're describing?:
... View more
09-08-2015
02:16 PM
|
1
|
9
|
3307
|
|
POST
|
There's a link to download the .prj file: http://spatialreference.org/ref/epsg/31277/prj/ If that doesn't work, are you sure you're defining the coordinate system, rather than (incorrectly) trying to reproject the data?
... View more
09-03-2015
02:57 PM
|
1
|
1
|
2154
|
|
POST
|
If you want all maps to be 1in:100ft, then zoom to that scale and use "Center And Maintain Current Scale." If you need map scale to vary between maps, and need to control the exact scale on each, then make a new column in your index, populate with the scale values, and use "Data Driven Scale."
... View more
09-03-2015
01:38 PM
|
1
|
0
|
5624
|
|
POST
|
Are you using data driven pages, perhaps? If so, refresh your data driven pages. Otherwise, it will print at the scale you used to originally create those DDPs.
... View more
09-03-2015
01:06 PM
|
2
|
3
|
5624
|
|
POST
|
Similar to the definition query idea, you can use label classes to turn on/off labels for groups of features.
... View more
09-02-2015
03:37 PM
|
0
|
0
|
1838
|
|
POST
|
It's a little murky in the documentation, but judging from the example " Hawaii Albers Equal Area Conic " the name of your coordinate system should be: outSR = arcpy.SpatialReference("NAD 1983 StatePlane Virginia North FIPS 4501 (US Feet)")
... View more
09-02-2015
10:37 AM
|
0
|
1
|
2747
|
|
POST
|
# Local variables:
Output_Table__2_ = Output_Feature_Class
Output_Table = Output_Table__2_
Output_Layer = Output_Table
Output_File = Output_Layer ^ this makes 4 copies of Output_Feature_Class. I'm guessing that's not what you're going for. Can you post an error message or more explanation as to what exactly is going wrong?
... View more
09-01-2015
10:05 AM
|
0
|
0
|
1112
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-25-2015 01:51 PM | |
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|