|
POST
|
From what I can tell, setting 'update symbology only' is set to False' tells it to update everything in the layer, including name. In fact, if you point to a different FC, it would replace it even. As the help doc says, basically, it is doing a remove layer/add layer with the new properties as defined in the layer file. I think, if you want to use the updatelayer for this, you might either have to re-create the layer file with python before applying it so that the name is representative of your data, OR, keep the original layer name in a variable, updateLayer, then rename the layer back to what it was before moving on to the next one. R_
... View more
07-22-2013
03:00 PM
|
0
|
0
|
1533
|
|
POST
|
It sets the scale properly into ArcMap, but not when it goes into the PDF. arcpy.mapping.ExportToPDF(mxd, dir + "\FILE.pdf") In where in ArcMap? The layout or the dataframe as you are setting? Unless you have went into the dataframe properties in ArcMap and set the extent to "Fixed Scale", you will likely never get the same scale for the dataframe that you have for the Layout (which is what is exported to pdf unless you specify otherwise). If you want it to be 1:20000 all the time, just set it in the dataframe properties as fixed scale. R_
... View more
07-22-2013
12:53 PM
|
0
|
0
|
7125
|
|
POST
|
Are you sure it isn't being set? normally, when you export to pdf, you export the Layout, not the dataframe. After it has run, open the mxd in ArcMap, switch to data view and see what your "dataframe" scale is set to. Depending on your constraints, etc. the Layout view scale is not the same as Data frame scale. R_
... View more
07-22-2013
09:52 AM
|
0
|
0
|
7125
|
|
POST
|
If you mean it runs "inside" of Arc, but not as stand alone, would really suspect it is related to feature layers. ArcGIS will on-the-fly create the feature layers for tools that require it for input, silently (if running within Arc). If you pick from the drop-down list, you never know if you are getting the layer or feature class itself. The help on the create random points is not quite right, as it says Random points will be generated inside or along the features in this feature class. The constraining feature class can be point, multipoint, line, or polygon. Yet, immediatly next to it, says Data Type = Feature LAYER???? (what is it, can't be both) The cost distance/path both say they need feature layer. Hope this gets you going, R_
... View more
07-22-2013
09:46 AM
|
0
|
0
|
2634
|
|
POST
|
Without the other code, hard to tell what you are loading as your "polygon" layer, but I see the cost tools do not support feature classes. Only raster and feature layers. Are you running MakeFeatureLayer on your polygon before you use it as input to your script? R_
... View more
07-22-2013
08:14 AM
|
0
|
0
|
2634
|
|
POST
|
Allison: You are trying to open an image from the FlexViewer application? If so, what program is used to open the image? Where is the program to open the image defined? Is it the default image viewer application that is installed on the client machine, something like Paint? Michael, This widget just makes it a URL link and opens in a new browser window on click. So, whatever your default browser is. R_
... View more
07-17-2013
05:08 PM
|
0
|
0
|
300
|
|
POST
|
Though, I now see a bunch of weird python stuff going on now. I'd better re-test this after a re-boot...... Especially since I know I have had the MakeFeatureLayer working properly in the past.. More results later, R_
... View more
07-16-2013
10:52 AM
|
0
|
0
|
1666
|
|
POST
|
Weird, if I calculate my "other" field equal to OBJECTID, it won't honor that now either. Set it back to sequential numbers and it works. However, the makefeaturelayer never seems to report the same number of features that the same select query, on the same dataset in ArcMap. Makefeature either seems to ignore my query and returns all results (as if I use OBJECTID) or, will return fewer results than actually match the query. (Finds 129 where "rec" <= 150 after sequentially calculating the rec field from 1 to 2110) Exact same "select by attributes" in ArcMap returns the 150 that actually match the query. R_
... View more
07-16-2013
10:48 AM
|
0
|
0
|
1666
|
|
POST
|
do you only have 99 features in that fc? I can't seem to get the where clause to take on my FC, it always returns all records in the data. It seems to work if I put my where clause on a different field, but can't get it to honor a where clause on OBJECTID ????? R_
... View more
07-16-2013
10:37 AM
|
0
|
0
|
1666
|
|
POST
|
Your sorted updateCursor will allow you to "update" values in a field, and would be based on the "sorted" table. I.e, if you setValue of a new field = 1000, then when you look at your table, after the update, the "last" record (highest FID) would be updated to 1000 (since you've done a cursor.next(), you have the "first" row (in decending order) selected so would actually be the "last" row of the table). So, if you create the new attribute field before you establish the updateCursor, you can easily update the record based on the sorted table. Just do your updates before you exit the sorted updateCursor. however, you can't make a table sort of a feature class permenant without creating a new dataset. The "order" of a shapefile is determined by the order that the features are added. If you are actually after a "sorted" shapefile, not just a sorted table, you would want to use the arcpy.sort function which does create a new feature class. So, could sort the shapefile into a new fc, delete your existing shapefile, then convert the FC back to shapefile with your original name. That is, of course, if you really, for some reason need a shapefile, otherwise, you can just use the new FC (since output of Sort doesn't support shapefiles). http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000057000000 http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000057000000 R_ If this doesn't get you going, maybe some input of what the other variables would be, and how you want it "filled" would give me a better idea. Are these variables coming from other fields, static input, etc.?
... View more
07-16-2013
09:57 AM
|
0
|
0
|
3339
|
|
POST
|
uCursor = arcpy.gp.UpdateCursor (stream_in,"","","", "LINKNO D")
urow = uCursor.next()
fidStart = urow.FID
print "fid start"
print fidStart
Not sure what you mean here. They way you have it above, the uCursor object IS your entire table sorted by LINKNO descending. the uCursor.next() just grabs the next (in this case the first) value.
for row in uCursor:
print row.FID
Should print all your FID's sorted descending. R_
... View more
07-16-2013
09:22 AM
|
0
|
0
|
1194
|
|
POST
|
The LINKNO attribute counts up to 449 and it is the line with 449 as the attribute that I want the script to read first. When I call the fid it still reads as fid 0, not 115 as I was shooting for. arcpy.gp.UpdateCursor (stream_in,"","","", "LINKNO D")
count1 = arcpy.gp.GetCount_management(stream_in)
cursor = arcpy.SearchCursor(stream_in)
row = cursor.next()
fid = row.FID
print "naming fid"
print fid See this post for syntax using the sort in a normal cursor. Examples for both hard coding the attribute and using a variable for it. http://forums.arcgis.com/threads/88186-To-select-a-record-based-on-the-highest-value-of-a-field also, I see you are sorting your updateCursor, yet you are grabbing the cursor.next() on the cursor object created by the searchcursor. I don't see a sort on the searchcursor, so should get the first fid each time. Perhaps try setting the cursor = to the update cursor and see if it grabs the correct value. R_
... View more
07-16-2013
08:22 AM
|
0
|
0
|
2145
|
|
POST
|
Something like this might work:
if "-" in Filename:
then do your split
So it would only do the split if the hyphen is in the string. R_
... View more
07-16-2013
08:15 AM
|
0
|
0
|
7740
|
|
POST
|
import arcpy
from arcpy import env
import os
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "RevisedGroundZones", df)[0]
lyr.definitionQuery = ' "Grounds_GSC_Zones" = \'2\''
So, similar to your code, could do it this way as well if you wanted to iterate through the list instead of just grabbing the first item (normally first of one):
for lyr in arcpy.mapping.ListLayers(mxd, "*"):
if lyr.name == "RevisedGroundZones":
lyr.definitionQuery = ' "Grounds_GSC_Zones" = \'2\''
The "List"Layers and "List"DataFrames create a list of matching objects, so, all Dataframes with name "Layers" would be appended to the df list, and all layers, within the specified dataframe, that match "RevisedGroundZones" would be appended to the lyr list. However, putting the [0] actually makes it grab the first item in the list. I am assuming here that you only have one dataframe named "Layers" and one layer within that named "RevisedGroundZones". That way, there would only be one item in each list, so putting the [0] on the end grabs it without having to iterate through a list of one. I have successfully ran this and it applies the definition query (of course, this is for text field, if your RevisedGroundZones attribute is a number field, the quotes need to dissapear from the definition query. So, if you only have one dataframe name "Layers" (or "layers" as list function here is not case sensitive), and within that only one layer named RevisedGroundZones, it should be applying the definition query. If you have more than one with this name, it would only apply to the first on in the list. Would then need to iterate through if you wanted it applied to all with that name. Of course, you can always throw a mxd.save() in there after the definition query, then open the mxd with arc map and see what the actual def query being applied is (and if there are any drawing errors related). Once you get the def query working, then let it move on to the clipping. R_
... View more
07-16-2013
08:04 AM
|
0
|
0
|
1573
|
|
POST
|
I would normally put something like this in there so it only needs run once:
if arcpy.Exists(compactFileName2):
arcpy.Delete_management(compactFileName2)
Also, keep in mind that if you are saving as a FGDB raster, you can't start the filename with a number or special character. R_
... View more
07-15-2013
02:03 PM
|
0
|
0
|
1643
|
| 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 |
Online
|
| Date Last Visited |
2 weeks ago
|