|
POST
|
Why not store the equations in the python script, which is also a text file... Then you only have one file to worry about.... But... Maybe you want to use the .readlines() method instead? If the text file looks like this: my cat is bad x = f.read() will produce: 'my\ncat\nis\nbad' where x = f.readlines() will producee a list of the lines like this: ['my\n', 'cat\n', 'is\n', 'bad'] Maybe even better, you can read the text file into a Dictionary object. For example if the text file looks like this: cat snipps+snails dog sugar+spice f = open(txtFile)
x = f.readlines()
f.close()
eqDict = {}
for i in x:
species = i.split(" ")[0]
equation = i.split(" ")[-1].replace("\n", "")
eqDict[species] = equation Then you have a in-memory look up table you can access like this: >>> print eqDict["cat"] 'snipps+snails'
... View more
02-01-2012
08:38 AM
|
0
|
0
|
3532
|
|
POST
|
Note sure what the issue is... Used to be in pre v10.0, you could run SpatialAnlayst tools in a loop for a year and they never had any memory issues. Maybe don't delete the scratch files every loop, just let arcpy overwrite them and delete them at the very end (unindent all your arcpy.Delete statements 1 tab), and include this line of code before your loop: arcpy.env.overwriteOutput = True Take note of the memory usuage in the task manger... Does it just build and build with each loop? How about calling a seperate process for each loop... See: http://forums.arcgis.com/threads/33602-Arcpy-Multiprocessor-issues You can look for other Python-based parallel processing examples in the forums using the keywords "os.spawnv", "subprocess", "multiprocessing", or "parallel python".
... View more
01-31-2012
03:37 PM
|
0
|
0
|
3589
|
|
POST
|
Seems if all these attributes are in the attribute table, it could simply be a tabular exercise... You would just query the records that fit your query, and then sum the COUNT field. Maybe just use the Frequency or SummaryStatistics tool.
... View more
01-31-2012
02:38 PM
|
0
|
0
|
573
|
|
POST
|
Could it be that you and your coworked have your "maximum number of unique values allowed in a raster attribute table" values set differently? http://support.esri.com/en/knowledgebase/techarticles/detail/35053 Maybe that would cause some discrepency? I notice that if I have a largerish .tif image (75 MB) and I delete the .aux file (it still has a .tfw file), and I run GetRasterProperties, I get: Executing: GetRasterProperties 18400_clp.tif MINIMUM Start Time: Tue Jan 31 16:00:04 2012 ERROR 001100: Failed because no statistics is available. Failed to execute (GetRasterProperties). Failed at Tue Jan 31 16:00:04 2012 (Elapsed Time: 0.00 seconds) When I build statistics 1st though, the tool runs fine... Seems like for whatever reason your coworker's computer is forgetting about the .aux file and/or the stat calculations contained in it. Is the 'Above_Freezing_Large_Non_Tss' variable pointing to an actual raster dataset (i.e. r"C:\temp\test.gdb\my_raster"), or a "raster layer", or some weird thing like a "layer package".
... View more
01-31-2012
02:29 PM
|
0
|
0
|
1367
|
|
POST
|
Know any Python scripting? I can think of a way to do thins using an iterative trial-and-error sort of thing that would seek to "get close" to the 25% goal. A possible algirithm might lolok like this: 1. Extract a single parcel 2. Buffer the road segment next to the parcel by 10feet (something small) and then 50ft (something larger) 3. Get the % overlap of each of those buffer distances - that is maybe the 10ft buffer covers 15% of the parcel and the 50ft buffer covers 75% of the parcel. Use Intersect tool to get the % overlap. 4. Using some basic linear interpolation (when y = 10 then x = .15, and when y = 50 then x = .75) solve for when x = .25. The script below might help. 5. Step 4 should get you close, and using some looping, you could then further refine the buffer distance so that you get to within some acceptabe tolerance of the 25% goal. 6. Then move on to the next parcel, rinse and repeat. def findLinearY(x1,y1,x2,y2,xValue):
#using the linear form of y = mx + b, solve for y...
slope = (y1 - y2) / float(x1 - x2)
b = y1 - (slope * x1)
return slope * float(xValue) + b #return a floating point mx + b! So, for example: >>> print findLinear(0,0,5,5,2) 2.0 >>> print findLinearY(0,0,1,2,500.3) 1000.6
... View more
01-31-2012
09:30 AM
|
0
|
0
|
681
|
|
POST
|
It might look something like this then... workspace = r"C:\temp\test.gdb"
myFC = workspace + "\\my_fc"
domainList = []
fieldList = arcpy.ListFields(myFC)
for field in fieldList:
if field.domain != '' and field.domain not in domainList:
domainList.append(field.domain)
domainDict = {}
for domain in domainList:
domainTable = workspace + "\\domain_table_for_" + domain.replace(" ", "_") #replace any blanks with an underscore
arcpy.DomainToTable_management(workspace, domain, domainTable, "CODE", "DESCRIPTION") #assuming code and description are the names
searchRows = arcpy.SerachCursor(domainTable)
for row in searchRow:
domainDict[domain, searchRow.CODE] = searchRow.DESCRIPTION
del searchRow, searchRows Then to rerieve the descriptions from the domainDict, the key is domain name and code value. For example: >>> print domainDict["BOAT_TYPE", 3] #access CODE = 3 from the 'BOAT_TYPE' domain 'Melges 24' >>> print domainDict["BOAT_TYPE", 4] #access CODE = 4 from the 'BOAT_TYPE' domain 'Laser 2' >>> print domainDict["BOAT_TYPE", 5] #access CODE = 5 from the 'BOAT_TYPE' domain 'Catalina 30'
... View more
01-31-2012
08:28 AM
|
0
|
0
|
677
|
|
POST
|
I did not think that I would need to include the workspace it had to be placed inside You actually don't if you 1st set the workspace using this comand. arcpy.env.workspace = r"C:\temp\test.gdb" So this "should" work I think: myWorkspace = r"C:\temp\test.gdb"
arcpy.env.workspace = myWorskpace
dsc = arcpy.Describe(arcpy.env.workspace)
for domain in dsc.domains:
domainTable = "domain_table_for_" + domain.replace(" ", "_") #replace any blanks with an underscore NOTE I ONLY INCLUDE THE TABLE NAME HERE, SINCE I ALREADY SET THE WORSKPACE
arcpy.DomainToTable_management(workspace, domain, domainTable, "code", "description") #assuming cosde and description are the name However, I generally don't set the workspace like that, and instead rely on proving the full paths to any input/output data files. Setting the workspace tends to be a tiny bit slower (takes > 0 second o set it) and it gets somewhat confusing when you are reading/writting data to many different workspaces. The only time I set the workspace is when I have to, for example when listing the featureclasses within a .gdb arcpy.env.workspace = r"C:\temp\test.gdb"
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
print fc
... View more
01-30-2012
02:12 PM
|
0
|
0
|
4832
|
|
POST
|
For the "workspace" variable, make sure you are specify the entire path. For example: workspace = r"C:\temp\test.gdb"
myFC = workspace + "\\my_fc"
domainList = []
fieldList = arcpy.ListFields(myFC)
for field in fieldList:
if field.domain != '' and field.domain not in domainList:
domainList.append(field.domain)
for domain in domainList:
domainTable = workspace + "\\domain_table_for_" + domain.replace(" ", "_") #replace any blanks with an underscore
arcpy.DomainToTable_management(workspace, domain, domainTable, "code", "description") #assuming cosde and description are the names If you want to export all the domains in a workspace: workspace = r"C:\temp\test.gdb"
dsc = arcpy.Describe(workspace)
for domain in dsc.domains:
domainTable = workspace + "\\domain_table_for_" + domain.replace(" ", "_") #replace any blanks with an underscore
arcpy.DomainToTable_management(workspace, domain, domainTable, "code", "description") #assuming cosde and description are the name
... View more
01-30-2012
01:37 PM
|
0
|
0
|
4832
|
|
POST
|
Is there a built-in function that will help me in finding the domain name of a field using the field's name so that I can use the domain name in the DomainToTable function? Yes there is. I've never done anything with it, but it'd look something like this: fieldList = arcpy.ListFields(myFC)
for field in fieldList:
print field.name + " - " + str(field.domain)
... View more
01-30-2012
12:38 PM
|
0
|
0
|
4832
|
|
POST
|
How about: inputTable = r"C:\temp\test\mytable.dbf"
outputWorkspace = r"C:\temp\test"
fipsLlist = ['001', '003', '005', '007', '009', '011', '013',
'015', '017', '019', '021', '023', '025', '027',
'029', '031', '033', '035', '037', '039', '041',
'043', '045', '047', '049', '051', '053', '055',
'057', '059', '061', '063', '065', '067', '069',
'071', '073', '075', '077', '079', '081', '083',
'085', '087', '089', '091', '093', '095', '097',
'099', '101', '103', '105', '107', '109', '111',
'113', '115', '117', '119', '121', '123', '125',
'127']
for fip in fipsList:
arcpy.TableSelect_analysis(inputTable, outputWorkspace + "\\fips_" + str(fip) + ".dbf", ","FIPS_PARIS = " + "'" + fip + "'")
... View more
01-30-2012
09:28 AM
|
0
|
0
|
2720
|
|
POST
|
Another way, which is faster and involves fewer lines of code... But for which you can't use derive other usefull stats such as mean or StdDev... myField = "MY_FIELD"
minValue = arcpy.SearchCursor(inlayer, "", "", "", myField + " A").next().getValue(myField) #Get 1st row in ascending cursor sort
maxValue = arcpy.SearchCursor(inlayer, "", "", "", myField + " D").next().getValue(myField) #Get 1st row in descending cursor sort
... View more
01-30-2012
07:41 AM
|
0
|
0
|
3484
|
|
POST
|
Is there a quick way to calculate the elevation difference between start- and endpoints? Nope - my outlined method is probably the fastest, unless you can find a script that someone wrote for the specifc purpose. Glad you got a solution. And as you proabably figured out there are some more detailed steps I neglected to mention...
... View more
01-30-2012
07:26 AM
|
0
|
0
|
2132
|
|
POST
|
Take your road arcs, export the start and end nodes (aka BOTH_ENDS) using the FeatureVerticesToPoints_management tool. Note that the points are tagged with the OID of the road segments. Using the Sample tool from SpatialAnalyst, get the elevation values of the street points. Note that output table has the OIDs of the points (but not the streets themselves). You now have the length of the street and the rise. Slope in % = rise / run. Requires ArcInfo and SpatialAnalyst license, but note this road slope analysis is also doable with other tools, there would just be more steps!
... View more
01-29-2012
12:31 PM
|
0
|
0
|
2132
|
|
POST
|
You would have to export the domain to a table 1st and use it as a look up table. Domain To Table tool: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000022000000 I'd recomend loading the domain table into a python dictionary and using like in this example: http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30010&viewfull=1#post30010
... View more
01-27-2012
12:20 PM
|
0
|
0
|
4832
|
|
POST
|
Try using this: q = "date_idx50 = " + "'" + str(tanggal) + "'" layer2 = arcpy.MakeFeatureLayer_management(layer1,"2010-12-01",q,"","")
... View more
01-27-2012
08:08 AM
|
0
|
0
|
926
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-25-2014 12:57 PM | |
| 1 | 08-29-2024 08:23 AM | |
| 1 | 08-29-2024 08:21 AM | |
| 1 | 02-13-2012 09:06 AM | |
| 2 | 10-05-2010 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|