|
POST
|
The way raster tools work, it really makes sense to keep attributes in a separate table if you can, as any subset or clipping of the raster data in most cases will lose all attributes except VALUE and COUNT. That said, I believe the Join Field tool will do what you want.
... View more
01-19-2012
01:50 PM
|
0
|
0
|
3522
|
|
POST
|
If you want to have the tool simply not tromp any already-set values, within your model you could run a select features by attribute on the input table view (for blank or null values) before running calculate field. Input table -> Select Layer By attribute -> (table) -> Calculate Field -> (table) -> Select Layer By Attribute (clear selection) This would be less complicated than setting up a script tool and doing parameter validation as I suggested. Another thing you may want to try in your model is not do anything if zero or more than a certain amount of rows are selected, so you don't accidentally calculate all rows. This would be done using the Get Count tool, sending its output to calculate value with an expression like "%Count% > 0 or %Count% < 100", and using the output as a precondition: Input table -> Select Layer By attribute -> (table) -> Get Count -> (count) -> Calculate value -> (output) -> [precondition] -> Calculate Field -> (table) -> Select Layer By Attribute (clear selection)
... View more
01-18-2012
12:00 PM
|
0
|
0
|
3485
|
|
POST
|
Rob, There is a hierarchy to the scope of environment settings; setting environments within a script or custom tool is the lowest in the hierarchy. Also, tool parameter validation (of which the "pop" of paths you are observing is a part) happens before your script starts, so setting arcpy.env.workspace setting in the script will not affect which path "pops" in the dialog. If you want to have the path "pop" to T:/Data/Survey_Shapes you need to either set your environment current workspace to that path in ArcCatalog, or using the environments button on the tool -- or modify the tool validation python code (in the script tool properties validation tab) to populate the same path as the input. Rather than dink with the validation to fill in paths, I go with the flow and set the current workspace in ArcCatalog/ArcMap to where I'm working so the script tool will have the maximum flexibility. That's my recommendation. As you suggested, you could just remove this parameter from the script and generate the output path within your python script, but this makes your script not work very well within ModelBuilder. I also don't recommend naming two objects (your example: output.txt, output.shp) the same thing -- this can cause confusion when scripting and even in your directory listing. Hope this helps. Curtis, All of my work is located in a folder called Survey_Shapes, so in order to try and set my current workspace I started my script as follows: import arcpy arcpy.env.workspace = "T:/Data/Survey_Shapes"
... View more
01-18-2012
05:32 AM
|
0
|
0
|
1908
|
|
POST
|
I want to extract the columns and rows into their own fields such that "23-999" becomes "23" and "999" using "-" as a delimiter. The problem is that the lengths are variable, eg the field can contain values like "1-2", "351-7", "81-253" which makes substring, trim, left and right commands tricky. I suggest doing the Calculate Field using Python syntax instead of VBScript (the default for Calculate Field). The split function makes this easier:
!Col_Row!.split("-")[0]
!Col_Row!.split("-")[1]
... View more
01-17-2012
04:43 PM
|
0
|
0
|
2377
|
|
POST
|
So it appears that my while loop isn't looping. You skipped the first record, so you're only getting the second.
InputRasters = gp.ListRasters()
## InputRasters.reset() NOT NECESSARY, the enumeration is new
## InputRaster = InputRasters.next() # DELETE - this skips to the second record
... View more
01-17-2012
08:54 AM
|
0
|
0
|
342
|
|
POST
|
What parameters must I input in the parameters tab to get this to work? I am new to scripts and getting them to work. This script is hard coded - it does not take parameters.
... View more
01-17-2012
08:47 AM
|
0
|
0
|
2503
|
|
POST
|
The Z units in NED grids are often stored in centimeters so that that full precision can be maintained while taking advantage of the run-length compression used in integer grids. You can either convert the grids to meters by dividing by 100 or use a z factor of .01 to compensate for the difference between meters and centimeters.
... View more
01-17-2012
08:40 AM
|
0
|
0
|
888
|
|
POST
|
You can enter whatever output name you want once it fills in the first time. If you set the current workspace to the same as the input text file, you'll at least see the path you want. (The default workspace is Default.gdb if it hasn't been setup otherwise.) If you want to modify what the default output path name to be the same as the input, you can do this using parameter validation in the updateParameters module: Arc 10 help: Customizing Script Tool Behavior
... View more
01-17-2012
08:36 AM
|
0
|
0
|
1908
|
|
POST
|
What you're trying to do is is something called parameter validation -- and you can only do this with a script tool. You could write a very short Python script tool that just imports arcpy and calls your model, so you can set up validation on its arguments.
... View more
01-17-2012
07:35 AM
|
0
|
0
|
3485
|
|
POST
|
IMHO, using substitution syntax makes for more readable code, whether you're using the old or new tools. Note the %s substitution converts numbers to strings for you if that is required.
expression = "(Raster(%s) < %s) & (Raster(%s) > %s) & "
"(Raster(%s) <> %s) & (Raster(%s) == %s)"
expression = expression % \
(inRaster1,var1[0],inRaster2,var1[1],inRaster3,var1[2],inraster4,var1[3])
NewRaster=eval(expression).
NewRaster.save("outRaster")
... View more
01-17-2012
07:24 AM
|
0
|
0
|
1354
|
|
POST
|
I'd do something a little more dramatic - reset all ArcGIS settings, not just the Normal.mxt. 1) close ArcGIS 2) Windows-Run... 3) enter "%APPDATA%" in the input box, this opens windows explorer in your %APPDATA% folder (XP or W7) 4) rename "ESRI" folder to "ESRIold" 5) Start ArcGIS again and see if anything is better. Note almost all your settings will be reset so you will have to re-create them. Another thing to try is to make sure your ArcGIS search options are set to only run every 9999 days, ie only when you tell it to work. The search functionality can really slow things down. If you are working over the network (remote file system) and the network has any latency, validation can slow to a crawl.
... View more
01-12-2012
10:31 AM
|
0
|
0
|
1212
|
|
POST
|
That's VBScript, you need to do one of the following. (This is documented in the Calculate Field tool documentation.) VBScript (the default BTW): gp.CalculateField_management(nn_file, "p_area", "[F_AREA] / 1000") Python: gp.CalculateField_management(nn_file, "p_area", "!F_AREA! / float(1000)","PYTHON") It is best practice (in Python 2.x anyway) to recast one of the operands to float to ensure you get floating division. (Even though if !F_AREA! is a float field python will know that, it's a good idea.) Mathew's comment about different field syntax for different dataset types does not apply here -- that applies only to SQL expressions used in tools like Select and MakeFeaturelayer. In Calculate Field, fields are always surrounded by [] or !!, depending on the choice of script language.
... View more
01-12-2012
09:31 AM
|
0
|
0
|
2512
|
|
POST
|
Try something like this in the field calculator. Expression: ReplaceLastNumber(!textfield!, !numberfield!)
Code block: import re
def ReplaceLastNumber(text_value, number_value):
numbers = re.findall("\d+", text_value)
if numbers:
last_number = numbers[-1]
last_number_index = text_value.rfind(last_number)
return text_value[:last_number_index] + str(number_value) + text_value[last_number_index + len(last_number):]
else:
return text_value Thanks Jason! The re module is very useful but rough going when you don't use it often, so the code snippet is very much appreciated. (posting with a new subject line so others can find it!
... View more
01-12-2012
09:19 AM
|
0
|
0
|
2377
|
|
POST
|
Thanks for your input, The problem is that I cannot do any sort of geoprocessing (Clip_management) on the raster. It is Read-Only in its native state. What I am actually viewing is a layer file pointing to the data that is housed in a server in New Mexico and the file is too large (437GB) to export in order to "make it my own". Hmm I would think setting the environment extent first would only pull across the part the raster you'd need. Have you tried that? If Clip_management doesn't work you may want to try CopyRaster_management - it isn't a spatial analyst tool so it may work better with a your raster web service. The doc for Copy_Raster says it honors the extent and snap raster environment.
... View more
01-12-2012
09:04 AM
|
0
|
0
|
780
|
|
POST
|
I think the easiest approach would be to use model builder instead of Python: Use the Iterate Features with your PLSS sections polygon feature class as input On each iteration, use CopyFeatures_management to the feature class to a intermediate polygon feature class(say, "in_memory\clip_poly") Connect the temporary polygon and the input raster to the Clip_management tool as input parameters. Connect the temporary polygon to the tool for environment extent, and connect the input raster to set the environment for snap raster and cell size. Set the output path of the Clip_management tool be something like "raster%Name%.jpg", this will uniquely name the outputs with the field iterator value. (Make sure the field you're iterating on on is nice and short, starts with a letter, and only includes characters: a-z,0-9,_)
... View more
01-12-2012
08:46 AM
|
0
|
0
|
780
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-11-2021 01:26 PM | |
| 5 | 12-10-2021 04:58 PM | |
| 1 | 02-27-2017 09:30 AM | |
| 2 | 12-04-2023 01:05 PM | |
| 1 | 04-12-2016 10:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-19-2024
12:10 AM
|