|
POST
|
Nope. Just saying that is how you would shift the dataframe once you know how far you want to move it. My data is in State Plane meters, so the output of my df.extent(s) are: >>> df.extent.YMin
150602.61868704704
>>> df.extent.YMax
152774.79701295635
>>>
## So, after you have done whatever if statements you need to determine how far to shift it, you use the code.
if MyShiftNorthTest == true:
deltaY = 5 # this is my variable set to 5 "map units" that I want to shift my extent North
if MyShiftEastTest == true:
deltaX = 5 # this is my variable set to 5 "map units" that I want to shift my extent East
##Then (and I'll break it up to read it more easily):
df = arcpy.mapping.ListDataFrames(mxd)[0]
newExtent = df.extent
newExtent.XMin = df.extent.XMin + deltaX
newExtent.YMin = df.extent.YMin + deltaY
newExtent.XMax = df.extent.XMax + deltaX
newExtent.YMax = df.extent.YMax + deltaY
df.extent = newExtent
So, since my map units are meters, that would shift my extent north and/or east by 5 meters. If I pass it a negative value, would shift the other way. R_
... View more
08-14-2013
07:58 AM
|
0
|
0
|
2999
|
|
POST
|
Braden, Kind of depends on which method you use. If you add them as attachments to the FC in the FGDB, then you would use the popup config files and enable attachments. Then, through the service, when one clicks on the feature with attachemnts, you will have the ability to open them. For the other method, you are putting the path to the standalone files themselves. In this case, you would set up a virtual directory on your server that "points" to the location of the files. Then, you would use an URL (http://yourserver/folder/filename.ext) as the attribute value and set this up as a hyperlink in the popupconfig. R_
... View more
08-13-2013
04:13 PM
|
0
|
0
|
2021
|
|
POST
|
Melissa, Was in a hurry when I posted that, and wasn't sure if the filenames list from da.walk is a "normal" python list, so wasn't sure if insert would work correctly. But, after testing, I see that it does. Could have done it this way:
baseFC = r"c:\pathto\dataset ## set to FC that has the desired output SR
## then, after you do your da.walk,
filenames.insert(0,baseFC) ## this would ensure the baseFC is the first in the list when passing it to the merge function
Then, you could use the original code (for file in filenames: ) rather than having to use the (for fcs in fcList) Either way works, but this method is more "clean", R_
... View more
08-13-2013
12:11 PM
|
0
|
0
|
1678
|
|
POST
|
You can't modify the extent object directly. Once you figure out where you want to move it, you will need to make a copy of the extent object. From the docs: Provides the ability to get or set the data frame's map extent using map coordinates (i.e., map units). A copy of the Extent object must be made before modifying its properties. The modified copy is then used to set the new extent properties. Note: If you try to set the extent by simply referencing the Extent object, changes won't be saved. For example, df.extent.xMin = some value won't work. If the aspect ratio of the extent does not match the shape of the data frame, the final extent will be adjusted to fit the new extent within the shape of the data frame. In other words, if you set explicit X, Y coordinates, you may not get the same values returned if you attempt to read them later. Note: The properties of the Extent object are by default read-only in the help system. A special exception was made for the arcpy.mapping scripting environment to enable changing extents during a map automation process. df = arcpy.mapping.ListDataFrames(mxd)[0] newExtent = df.extent newExtent.XMin, newExtent.YMin = -180.0, -90.0 newExtent.XMax, newExtent.YMax = 180.0, 90.0 df.extent = newExtent from here: http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000003000000 Should be able to shift the Ymin Ymax by 5 feet north. R_
... View more
08-13-2013
07:56 AM
|
0
|
0
|
2999
|
|
POST
|
I just want to return the results within python, eg: - create selection - return sum area for a field within that selection - do something with the returned result Not sure why Waynes answer didn't work for you? I use this code all the time (in my case, I switch the scale of a map depending on how large my areas are). This will "return sum area for a field within that selection" for the selected features (or, features that match def query in mxd). Which is now just a number that you can "do something with". Just need to make sure that the selection or def query (however you are limiting your results) is put on the layer before you searchcursor the area.
warea = 0
with arcpy.da.SearchCursor(lyr1, "SHAPE@AREA") as cursor:
for row in cursor:
warea += row[0]
del cursor
R_
... View more
08-12-2013
03:29 PM
|
0
|
0
|
4459
|
|
POST
|
Does this work for you?
if self.centerline.getValue(suffix) is not None:
self.newStreet.S_suffix = self.centerline.getValue(suffix)
R_
... View more
08-12-2013
02:57 PM
|
0
|
0
|
1405
|
|
POST
|
Working just fine for me as long as OldField actually exists in the FC. Could change to this for help trouble shooting: with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
row[1] = "test"
cursor.updateRow(row)
If this works, and codes all values in NewField to "test", then it is just not getting the correct input. Are you sure OldField is not nulls here as I get exactly the same in my new column. R_
... View more
08-12-2013
02:38 PM
|
0
|
0
|
1800
|
|
POST
|
Melissa, The for file in filenames just takes the output in filenames (from da.walk) and appends them into a new list. The for fcs in fcList then iterates through this new list, so they are completely independant of one another. I did it this way so I could control the order of the list and ensure that baseFC is ALWAYS the first in the list so that merge pulls the spatial reference from that layer. If there were an easy way to just add that FC to the beginning of the original filenames list, would just use the one loop instead. Instead of using filename in your exp statement(s), use fcs. exp2 = str(os.path.join(dirpath, fcs))
R_
... View more
08-12-2013
08:39 AM
|
0
|
0
|
1678
|
|
POST
|
OIC. I thought you were running the deleteIdenticals on the final appendFC, but sounds like you used it to "fix" the polygons. Don't think the different schemas would matter as long as the fields you are concerned about are identical. I.e., if you add your three fields to each polygon FC first. Now that I think about it (even more), this is what I would try: merge will add them all together and add all fields from all input FC's. Will combine them if they are identical. So, if they have the three identical fields that you are interested in, the rows will be populated with the attributes. So,
appendFC = r"C:\TEMP\PDX_SAB\PDX_SAB.gdb\PDX_SAB_Centerpoint"
outFC = "in_memory\\centerPoints"
tmpFC= "in_memory\\tmpFC"
fieldList = ["ProjectNum", "OriginalPath", "ServiceArea"]
##Merge tool will honor the coordinate system of the first FC in the list to be merged, so I'd make my list something like:
fcList = ["baseFC"] # where BaseFC is a FC in your workspace that is in the correct coordinate system, this will set the output to the SR you want
layerList = []
then, after you do your walk,
for all file in filenames:
fcList.append("file")
for all fcs in fcList: ## these two look like duplication, but this is how I add to a list with a value already. For file in filenames is a list I can't control this way
layername = str(fcs) + "feature_layer"
layerList.append(layername) # append the new in memory layer names to a list so we can utilize it after iteration.
arcpy.MakeFeatureLayer_management(fcs,layername) # this will put them as in memory layers and are fast
arcpy.AddField_management(layername, "ProjectNum", "TEXT", "", "", 20, "", "NULLABLE", "REQUIRED")
arcpy.AddField_management(layername, "OriginalPath", "TEXT", "", "", 255, "", "NULLABLE", "REQUIRED")
arcpy.AddField_management(layername, "ServiceArea", "TEXT", "", "", 75, "", "NULLABLE", "REQUIRED")
arcpy.CalculateField_management(layername, "ProjectNum", "exp", "PYTHON_9.3")
arcpy.CalculateField_management(layername, "OriginalPath", "exp2", "PYTHON_9.3")
arcpy.CalculateField_management(layername, "ServiceArea", "exp3", "PYTHON_9.3")
Now, after iterating through all FC, and making the list of feature layers, combine them all so we can do the rest in one swoop.
arcpy.Merge_management(layerList, tmpFC) ### merges all the polygon in memory fc's with new calculated fields into an in memory fc
fields = arcpy.ListFields(tmpFC)
for field in fields:
if field not in fieldList:
arcpy.DeleteField_management (tmpFC, field) ## will drop all the "extra" fields if not in the fieldsList.
arcpy.FeatureToPoint_management(tmpFC, appendFC, "INSIDE") ## this will make point FC in same SR as first input with your three fields appended.
unless you run out of memory or something, I think this approach would be much faster. Of course, this is just the basic outline, you would need to incorporate the expression code and such in there, so this code isn't "run ready" Also, as far as converting the SR of the polygons, if you have the need to convert them for some other reason, then probably worth doing that first. however, both append and merge will honor coordinate systems (if defined) and will on the fly re-project them to the ouput datasets SR (to the SR of first input for Merge). R_ also, could easily skip the two list builders if you make sure that the first one being read to your list is in the proper SR.
... View more
08-01-2013
03:53 PM
|
0
|
0
|
1678
|
|
POST
|
Analyze Datasets - Updates database statistics of base tables, delta tables, and archive tables, along with the statistics on those tables' indexes. This tool is used in enterprise geodatabases to help get optimal performance from the RDBMS's query optimizer. Stale statistics can lead to poor geodatabase performance. �?�The option Include System Tables is used to determine if the states and state lineage tables will be analyzed. When the option is unselected, these tables are not analyzed; when selected, the tables are analyzed. �?�The input workspace must be an enterprise database. Analyze Datasets does not work with file or personal geodatabases. Analyze - Updates database statistics of business tables, feature tables, and delta tables, along with the statistics of those tables' indexes. �?�This tool updates the statistics of business tables, feature tables, raster tables, adds table, and deletes table, along with the statistics on those tables' indexes. �?�This tool can only be used with data stored in an ArcSDE Geodatabase. Guessing your data is ArcSDE Geodatabase? R_
... View more
08-01-2013
02:32 PM
|
0
|
0
|
1015
|
|
POST
|
Thanks for the update. Sorry I didn't get back to my testing. This fell off the burner. R_
... View more
08-01-2013
02:23 PM
|
0
|
0
|
1686
|
|
POST
|
Well, your script is stand alone, and not controlling a map document, so don't think the data driven pages has anything to do with it. you are working with the FC's directly. From what you have told me, perhaps each polygon feature class has duplicate polygons? In the attribute table of the polygon FC, in ArcMap, how many records do you see? each one would be made to a point. If you are getting identical points, probably identical polygons. This is real common if the data at one time came from autoCAD. As far as a different approach, not sure if it would be faster, but here is one method. Create a list of all the input polygon FC's, iterate them and add your fields to them directly, calculate the fields to thier respective source. Then, since you already have the list, use that as the input to arcpy.Merge_management(fcList, outFC) # not sure if you would need to deal with field mappings. I think it will keep all fields that have identical schema. Then, run the FeatureToPoint on the outFC and do it all in one swoop. Like I said, not sure if it would speed it up or not, but I have noticed that the append tool is very slow, and involking it each loop could be painfully slow. R_
... View more
08-01-2013
02:06 PM
|
0
|
0
|
1678
|
|
POST
|
OIC, that makes sense. Any reason you can't just delete that 'extra' copy of the toolbox from your project drive? or, if it has been modified, move it somewhere? Or, could try something like this:
for dirpath, dirnames, filenames in arcpy.da.Walk(p):
for filename in filenames:
if filename != "con":
arcpy.AddMessage('adding ' + os.path.join(dirpath, filename) + ' to list............')
descr = arcpy.Describe(os.path.join(dirpath, filename))
Since it is looking for that file and is haveing issues with it or the path, this should just make it move on to the next one if the current filename is "con". R_
... View more
08-01-2013
01:51 PM
|
0
|
0
|
609
|
|
POST
|
I know this is about automating it, but if you right-click on the mxd in ArcCatalog and "change data source" does that crash also? R_
... View more
08-01-2013
12:27 PM
|
0
|
0
|
937
|
|
POST
|
So, what are your polygon datasets in "C:\TEMP\PDX_SAB" ? You are not doing a selection or anything, so it should make a point for each polygon feature from each input dataset. If you have more than one polygon in the FC, you will get more than one point. Is this what is going on, or are you getting the same point entered multiple times? R_
... View more
08-01-2013
12:25 PM
|
0
|
0
|
1678
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-14-2026 04:00 PM | |
| 1 | 09-14-2022 07:53 AM | |
| 1 | 09-14-2022 08:23 AM | |
| 1 | 05-21-2026 08:53 AM | |
| 1 | 05-14-2026 04:28 PM |
| Online Status |
Offline
|
| Date Last Visited |
Wednesday
|