|
POST
|
The link that you posted is not functioning for me It is apparent to me that some NIMs are not visible to all. I'm a beta tester, and have right-to-call support, so I may be able to access more NIMs than you do. The important thing is the NIM number, which is helpful when talking to Esri support. I already tried using the clip management tool, the problem is that it does not create an attribute table and I need the breakdown of pixel counts to run stats. If the raster is not integer, integerize it, then use the Build Raster Attribute table tool to build a RAT. Then you'll have your count values. You can join any extra raster attributes from the source (if needed) using the Join Field tool. Hope that helps.
... View more
04-23-2012
12:14 PM
|
0
|
0
|
3439
|
|
POST
|
I saved a python module that has the syntax pre-set What a neat idea! Your function can be easily tweaked up to work with all data sources (mdb's use brackets) using the arcpy [URL=http://help.arcgis.com/en/arcgisdesktop/10.0/help/000v/000v0000004n000000.htm]AddFieldDelimiters[/URL] function. I also added a tweak to add quotes around strings and handle IS NULL constructions:
def BuildQuery(table, field, operator, value=None):
"""Generate a valid ArcGIS query expression
arguments
table - input feature class or table view
field - field name (string)
operator - SQL operators ("=","<>", etc)
"IS NULL" and "IS NOT NULL" are supported
value - query value (optional)
examples
>>> BuildQuery("x.dat","FIELD1","=", "spam")
u'"FIELD1" = \'spam\''
>>> BuildQuery("x.dat","FIELD1",">",42)
u'"FIELD1" > 42'
BuildQuery(r"E:\tables.mdb\table1","PwsID","IS NOT NULL")
u'[PwsID] IS NOT NULL'
"""
# Use correct field delimeter (depends on table type)
# For 9.3, use "gp" instead of "arcpy" in the following line
qfield=arcpy.AddFieldDelimiters(table,field)
# tweak value delimeter for different data types
if type(value) == type("string"):
# add single quotes around string values
qvalue = "'" + value + "'"
elif value == None:
# drop value when not specified (used for IS NULL, etc)
qvalue = ""
else:
# numeric values are fine unmodified
qvalue = value
sql = "%s %s %s" % (qfield,operator,qvalue)
return sql.strip()
A few helpful references for the good of the order Arc 10.0 help: Building a query expression Specifying a query in Python ArcGIS Map Automation forum
... View more
04-23-2012
11:09 AM
|
0
|
0
|
2540
|
|
POST
|
A tricky part about this task is dealing with the fact that there is no neighborhood notation in the new Python map algebra. The workaround would be to use the flow direction and elevation grid together with the tools Con and Shift to get at the neighborhood cell values to do the necessary calculations... This could be a job for numpy arrays - but only for rasters of limited size.
... View more
04-23-2012
11:05 AM
|
0
|
0
|
7365
|
|
POST
|
I'm trying to determine the slope length of a DEM, but cannot find any tools that would be sufficient for this purpose. The Spatial Analyst Flow Length tool calculates length down a slope. This is of course limited to D8 flow directions (up down left right diagonal). If you're looking for slope length from each cell to the cell downstream, the easiest way would compare the flow length value compared to the cell downstream, using map algebra with the flow direction grid, your Flow Length output, and the tools Con and Shift. (Back in the day we'd use GRID's nifty neighborhood notation, but that is no longer with us.)
... View more
04-23-2012
10:52 AM
|
0
|
0
|
7365
|
|
POST
|
Have you tried generating the table using spreadsheet software (like Excel)? If you need to automate this, you could generate the table in Python easily enough: >>> for k in range(0,181): ... print "%6d %s" % (k,k ** 0.5) ... 0 0.0 1 1.0 2 1.41421356237 (snip) 177 13.3041346957 178 13.3416640641 179 13.3790881603 180 13.416407865
... View more
04-23-2012
10:38 AM
|
0
|
0
|
1256
|
|
POST
|
Extract by mask worked perfectly well for 2 out of the 4 viewshed raster layers. The extract by mask fails everytime for the other two There is a recently entered NIM on this, the workaround is to use the Clip_management tool. NIM078864 The Extract by Mask tool returns a 99998 error when clipping certain rasters. If that doesn't work, just a shot in the dark, if your scratch workspace is a folder, there is a known limit when the COUNT field hits 2.1 billion cells. You may have better luck if your scratch workspace is a file gdb.
... View more
04-23-2012
08:49 AM
|
0
|
0
|
3439
|
|
POST
|
I have used concatenate function in excel to prepare the list of the calculator expressions [not sure if it is in the true format] and their output directories and file names as below. "J:\sp1\sp1_Thresholded_0_3.img" + "J:\sp1\sp1_A2a_2020_Thresholded.img" ==> "J:\sp1\sp1_CCCMA_A2a_2020_GainLoss.img" As described in the help for the Raster Calculator tool, these are python expressions, so you need to be careful to escape your strings. The correct format for your expression in the Python window would be: from arcpy.sa import *
rst = r"J:\sp1\sp1_Thresholded_0_3.img" + r"J:\sp1\sp1_A2a_2020_Thresholded.img";rst.save(r"J:\sp1\sp1_CCCMA_A2a_2020_GainLoss.img") (Using the ";" to join multiple lines in python is generally frowned upon [it kind of takes away Python's elegance can introduce bugs] but in your case of creating command lines to paste in the python window it is a workable trick.) Note the use of "r" for raw strings. This prevents recognized escape expressions from being used, for example, "\t" is recognized by Python as a tab character (without the prefix "r"). I still think [post=191665]using the ModelBuilder Iterate Rasters,[/post] with the Calculate Value tool used to set up your pathnames, is far preferable to generating arcpy code in Excel.
... View more
04-23-2012
08:25 AM
|
0
|
0
|
1494
|
|
POST
|
please explain for me which iteration method is best useful in my case and how to use the Calculate Value tool to generate the input and output pathnames... Ahmed - Since you're iterating on rasters, it seems to me Iterate Rasters would worth a try. see the Callculate Value tool help and that other [thread=55358]thread[/thread] for some examples. Parse Path is also a handy tool in MB 10.0 for manipulating pathnames Good luck!
... View more
04-20-2012
08:49 AM
|
0
|
0
|
5572
|
|
POST
|
That is a samples of what I need: "J:\sp1\sp1_Thresholded_0_3.img" + "J:\sp1\sp1_A2a_2020_Thresholded.img" ==> J:\sp1\sp1_CCCMA_A2a_2020_GainLoss.img I will repeat the previous steps more than 1000 times and it will take me huge time to run them individulaly. A modelbuilder iterator should do this nicely for you. Just set up raster calculator tool and pipe the output of your iterator into it. You may have to use the Calculate Value tool to generate the input and output pathnames you need on each iteration using a python expression. [thread=55358](See this thread.)[/thread]
... View more
04-18-2012
09:26 AM
|
1
|
1
|
5572
|
|
POST
|
I'd check your environment - cell size, mask, extent, snap raster - and avoid any projecting-on-the-fly, which can really cause problems with your raster environment setup.
... View more
04-17-2012
02:10 PM
|
0
|
0
|
1506
|
|
POST
|
This, however, does not change the integer data format to a floating point. Is there any way to specify or convert the output Euclidean distance data format to FP so I can get an output as FP? As was pointed out, the output of EucDistance should be floating point. And, integer * float should give you float. But if you want to make triple sure, you can always convert a grid to float using the Float tool. from arcpy.sa import *
...
OutEucDistance = Float(EucDistance(src_layer, "", resolution, "")) * 0.000621371192
... View more
04-17-2012
01:57 PM
|
0
|
0
|
2008
|
|
POST
|
This, however, does not change the integer data format to a floating point. Is there any way to specify or convert the output Euclidean distance data format to FP so I can get an output as FP? As Dapper Dan pointed out, the output of EucDistance should be floating point. And, (integer * float) should always give you float. But if you want to make triple sure, you can always convert a grid to float using the Float tool. One thing that may be messing you up is the artificial ArcGIS designation of a raster as "discrete" or "continuous", which is used for symbology but can be unrelated to the pixel data type. from arcpy.sa import *
...
OutEucDistance = Float(EucDistance(src_layer, "", resolution, "")) * 0.000621371192
... View more
04-17-2012
01:50 PM
|
0
|
0
|
2008
|
|
POST
|
Should the line of code be encapsulated with f() ? No, the f() is how you call a function in the code block (if you need one). You need to run the tool to get the result, and you need to run them in order (for example, Value need to be set before you run your Calculate Value tool that uses it).
... View more
04-17-2012
12:22 PM
|
0
|
0
|
4535
|
|
POST
|
Due to some downstream processing, my rasters end up with names like bnd1_raster_tpi, bnd2_raster_tpi, etc. I need to clip these again by the perspective shapefile feature. Was thinking that using calculate field on %Value% (%Value% = bnd1_raster_tpi) and stripping the "_raster_tpi" and adding ".shp" would be the easiest way to specify the right shapefile to clip by in each iteration. Calculate Value can do this for you, using an expression like this r"%temp_raster%".replace("_raster_tpi","") Set the output to String type set it as a precondition to the clip, and you can use that varaible embedded in the pathname for the shapefile. I know this would be MUCH easier if I would just script it in Python, but now the Calculate Field tool is gettign the best of me and I can't have that happen... 🙂 There is a point where you have to hang it up and write a Python script, but a good grasp of Calculate Value makes ModelBuilder much more flexible and useful.
... View more
04-17-2012
11:36 AM
|
0
|
0
|
4383
|
|
POST
|
In the interest of making it a bit more universal for future use, would the following remove the last 4 characters from a string stored in %Value% ? Almost got it -- refer to the examples of slicing strings in that Python tutorial I referenced. (BTW Calculate Value is the tool you want, not Calculate Field, which calculates fields in tables, not variables in ModelBuilder.) If you're just doing string manipulation you don't need the os module, so you can just snip off the last four characters of a path in the expression itself using built-in Python string slicing syntax and leave the code block empty: r"%Value%"[:-4] One of the really nice things about the python command line (including the one in ArcMap) is you can test these things easily before you put them in your model:
>>> "file.tif"[4]
'.'
>>> "file.tif"[:-4]
'file'
>>> "file.tif"[-4:]
'.tif'
>>>
... View more
04-17-2012
11:31 AM
|
0
|
0
|
4536
|
| 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
|