POST
|
Yes, instead of getting the statistics interactively, you can use the Summary Statistics tool Yes, that tool produces an output table. Yes, you have to look up the value of the MEAN for the field on which you requested statistics. A search cursor will do that quickly (there will only be one record). If you assign the value you have plucked from the table to a variable, you can use it in the subsequent where clause. You never mentioned using model builder before, so I gave you the interactive workflow. A Model Builder workflow will mirror the interactive one.
... View more
06-20-2014
03:33 AM
|
0
|
0
|
363
|
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))
... View more
06-19-2014
09:17 AM
|
0
|
0
|
282
|
POST
|
If I understand this correctly, you want something like this: result = [row[0] for row in arcpy.da.SearchCursor(
outFC,
("RegID_6k99"))]
unique = set(result)
lengthDict = {}
for uni in unique:
where = "\"RegID_6k99\" = '%s'" % (uni)
lengths = [row[0] for row in arcpy.da.SearchCursor(
fc,
("Shape_Length"),
where)]
lengthDict[uni] = sum(lengths)
for each in lengthDict.keys():
print "%s: %s" % (each, lengthDict[each]) This should print out the total lengths for each RegID_6k99 value. << no warranties expressed or implied >> note: use the '#' button to add code tags to your post
... View more
06-19-2014
06:58 AM
|
0
|
1
|
1623
|
POST
|
You say you have a cities "map" and an administrative boundary "map". I assume you mean that you have polygon shapefiles or geodatabase feature classes: the cities file has polygons with some sort of ID (name of the city, perhaps) The admin area file has polygons with admin area IDs (the name of the country, for example). In ArcToolbox, in the Analysis Tools > Overlay section is a tool called Union read the help on that tool. It will show you how you can get one set of polygons (in a new file) that has the shapes and attributes from both the other two files. Now you can use any of a variety of tools to select whatever polygons you want to use; say, the cities in Utopia, using a Select By Attribute operation. You can make a layer, using your query (example: cities in Utopia), that show just the features you want. If you need separate files of each set, you can copy the data out to a new file (but, as you write, you will then have more than 100 individual files). The union is just one operation; you then get a data set you can look at different ways to get all the different 'maps' you want. Doing it with clipping will require a lot more work: first select or make the hundred or more layer files of individual countries Then perform the hundred or more clips. Best of luck
... View more
06-18-2014
10:58 AM
|
0
|
0
|
792
|
POST
|
That is a lot of clipping. You will want to use a loop in model builder or python to do things that way. I would suggest, however, something simpler like union-ing the two polygon feature classes This will add the admin area attribute to the city area polys now, using the attribute of the admin area, and the city attribute, you can select the cities in a particular admin zone as a layer (or a selection) and export or copy just those polygons to a new featureclass, (if you want) Again, I would suggest just leaving all the intersected data in one FC and making individual layers as you need them.
... View more
06-18-2014
04:36 AM
|
0
|
0
|
792
|
POST
|
To get the average line length interactively, right click on the Shape_Length field in the attribute table and click statistics. let's say, for example, that the average is 5000 meters then you create a feature layer of the lines feature class, with a where clause: "Shape_Length" < 5000 You can make the layer interactively in ArcMap by adding that statement above as a Query Definition to the layer, or inside or outside of ArcMap by using the Make Feature layer tool and setting the statement as the where clause or Expression Now use the layer as the input to Feature To Polygon Only the lines of less than the average length (in our example, 5000 meters) will be used by the tool.
... View more
06-18-2014
04:12 AM
|
0
|
0
|
363
|
POST
|
She might want to try MakeRasterLayer_management (in_raster, out_rasterlayer, {where_clause}, {envelope}, {band_index})
... View more
06-18-2014
03:52 AM
|
0
|
0
|
412
|
POST
|
Look at the Select Layer By Attribute (Data Management) tool help..... pay attention to the part about the where_clause
... View more
06-16-2014
11:09 AM
|
0
|
0
|
196
|
POST
|
KMLs are always in lat/long coordinates. project your national system coordinate data to wgs84 geographic, and see how it lines up then. Compare it to other available data in lat/long coordinates, too; not just the stuff in Google Earth. (Remember too, that Google Earth fudges a lot of coordinate calculations in the interest of fast display.)
... View more
06-13-2014
04:09 AM
|
0
|
0
|
875
|
POST
|
I always distrust line continuation flags (especially as they are deprecated in python...) When I have a long string argument, I prefer to build it from a list Just because it is easier for me to see and debug, and because it gets re-assembled as I expect. for example fieldsLyrList = [
"KEY KEY VISIBLE NONE;",
"INSURED INSURED HIDDEN NONE;",
"LINE LINE VISIBLE NONE;",
"LATITUDE LATITUDE HIDDEN NONE;",
"LONGITUDE LONGITUDE HIDDEN NONE;",
"CONFIDENCE CONFIDENCE HIDDEN NONE;",
"SOURCE SOURCE HIDDEN NONE;",
"NOTES NOTES HIDDEN NONE;",
"PHYSADDRESS PHYSADDRESS HIDDEN NONE;",
"PHYSCITY PHYSCITY HIDDEN NONE;",
"BLDGTYPE BLDGTYPE HIDDEN NONE;",
"CSTR CSTR HIDDEN NONE;",
"CSTRYR CSTRYR HIDDEN NONE;",
"SIZE SIZE HIDDEN NONE;",
"EXPDATE EXPDATE HIDDEN NONE;",
"AGCY AGCY HIDDEN NONE;",
"AGT AGT HIDDEN NONE;",
"CIS CIS HIDDEN NONE;",
"FORMAE FORMAE HIDDEN NONE;",
"FORMC FORMC HIDDEN NONE;",
"VALAE VALAE HIDDEN NONE;",
"VALC VALC HIDDEN NONE;",
"DED DED HIDDEN NONE;",
"LIM LIM HIDDEN NONE;",
"PC PC HIDDEN NONE;",
"CORRECTPC CORRECTPC HIDDEN NONE;",
"ANOMALIES ANOMALIES HIDDEN NONE;",
"DISRKEY DISRKEY VISIBLE NONE"
]
fieldsLyr = ''.join(fieldsLyrList)
... View more
06-12-2014
04:17 AM
|
0
|
0
|
689
|
POST
|
If you have attributes that match for matching records in each file you could join the smaller table to the larger using Add Join with KEEP_ALL The records that do not have any attributes from the shapefile joined are the ones unique to the featureclass If you lack common fields for a table join, then Select Layer By Location in the management toolbox will do something similar again, it identifies the set common to both; the leftovers are the unique ones.
... View more
06-11-2014
10:46 AM
|
0
|
0
|
2426
|
POST
|
You could use CalculateField_management for the first problem using a code block that tests the existing value and if it is -1, change it to X and otherwise leave it alone. With 15 fields to test, an update cursor with a similar test may be advisable. for the second problem, you can accept the input as a string as (for example: 1, 01 or 001) and use zfill(3) to pad out the entered string with zeros. Now, whenever you want to use it as a number just convert it to an integer int("001") returns 1 Integers don't have leading zeros, so they get stripped off and however the user entered the string (for example, again: 1, 01 or 001) the string gets padded to "001"
... View more
06-10-2014
10:32 AM
|
0
|
0
|
150
|
POST
|
neither apnList[0].lstrip() nor apnList[1].lstrip (with or without the ()) will strip off the leading zeros. The default is to strip whitespace. apnList[0].lstrip('0') will strip zeros, as will str(int(apnList[0])) but the second option will preserve a single zero, instead of returning a blank string I don't know what you want the zfill(2) to do... perhaps it is a typo? Your logic in the length of apnList test is a little odd. first off, does a length test of 3-or-else cover all (or any of) your possible use cases? It does not look like it. then, your parser takes items 0, 1, & 2 (or 0 & 1) from apnList ... spliting "EBRI-000001-000000-000003" on the '-' gives ['EBRI', '000001', '000000', '000003'] so the length will be 4, and taking 0, 1 & 2 will give you EBRI-1- (if you use your lstrip parsing) nether of your parsing options will turn "EBRI-000001-000000-000003" into "1-3" Try debugging your function in IDLE by just passing it some sample strings.....
... View more
06-09-2014
04:36 AM
|
0
|
0
|
393
|
POST
|
It looks like when you go to update the symbolization (I hate that awful word: "symbology". ugh. It is neither a science nor a religion... anyway...) you are not operating on the ArcMap layers you just added. Instead, you are again looping through BasinList BasinList is a list of feature classes on disk even though you again make layers from the FCs, they are NOT the layers in your ArcMap data frame. For your symbolization loop, start with a new list of layers in the data frame, using: ListLayers (map_document_or_layer, {wildcard}, {data_frame}) This list will contain the objects you need to update. Then, when you do the arcpy.mapping.UpdateLayer(df,BasinFeatureClass,PORSymbologyLayer) make it arcpy.mapping.UpdateLayer(df,BasinFeatureClass,PORSymbologyLayer, True) Yes, the default is True, but, as it says in the Zen of Python (>>> import this): Explicit is better than implicit.
... View more
06-06-2014
05:05 AM
|
0
|
0
|
512
|
POST
|
Yes, it was pretty clear about using a codeblock, and that python cannot understand how to use the input argument. It is not helpful to 'generalize' the inputs, or to not bother with being explicit about the function code or the field values being fed to it. It is still not clear what the problem might be: I assume "CARV-000001-000001-B000000" is a value in the field PIN for a particular row... (if it is not, well, that could be a problem too) Obviously the function is not expecting that particular string: why? we don't know; we don't know what the function is trying to do (beyond that it will try to "format" it). One does not have a lot to go on here... Except that, as I wrote before, the prefixed u is not (at least in itself) the problem.
... View more
06-06-2014
04:44 AM
|
0
|
0
|
393
|
Title | Kudos | Posted |
---|---|---|
1 | 01-16-2014 08:15 AM | |
1 | 01-08-2014 02:38 AM | |
1 | 05-30-2014 10:56 AM | |
1 | 06-07-2013 04:43 AM |
Online Status |
Offline
|
Date Last Visited |
11-07-2023
12:08 AM
|