|
POST
|
It sounds like you are trying to replicate an existing workflow so I'm going to go back to Expand. The 10x Expand syntax is: Expand (in_raster, number_cells, zone_values)
where zone_values is a python list of integers. You can make a unique list from the VAT and use that variable with the Expand tool in Python like this. (If in_raster doesn't work, you may have to create a table view of the raster with MakeTableView and pass that in its place.) vlist = [v[0] for v in arcpy.sa.SearchCursor(in_raster, "VALUE")]
exp = arcpy.sa.Expand(in_raster, 1, vlist)
exp.save("exp_raster.tif") Within Model Builder I think this is a good use case for the Calculate Value tool so you don't need to build a string representation of your many thousand integer values: # Calculate Value expression
f(r"%Input raster%")
# Code block
def f(in_raster):
vlist = [v[0] for v in arcpy.sa.SearchCursor(in_raster, "VALUE")]
exp = arcpy.sa.Expand(in_raster, 1, vlist)
exp.save("exp_raster.tif")
return exp.catalogPath
# Data type
Raster Dataset
... View more
08-06-2019
09:01 PM
|
0
|
0
|
4399
|
|
POST
|
Does in_memory still work for you as long as you don't need to add the result to the map? The page you referenced seems to say so.
... View more
08-06-2019
10:11 AM
|
0
|
2
|
1953
|
|
POST
|
Isaías Santos you posted to the ModelBuilder space so I here is an example to use Xander's cursor code in the Calculate Value tool. A little bit of Python can go a long way in ModelBuilder. # Calculate Value tool
# Expression (Feature layer and Field are model variables)
f(r"%Feature layer%", "%Field%")
# Code Block
def f(fc, fld):
prev = None
with arcpy.da.UpdateCursor(fc, (fld)) as curs:
for row in curs:
if row[0] == None:
row[0] = prev
else:
prev = row[0]
curs.updateRow(row)
return(fc)
# Data Type
Feature Layer
... View more
08-06-2019
09:07 AM
|
1
|
1
|
2296
|
|
POST
|
In Excel insert pivot table with this table of data and use ID and School as Row variables and City as a column variable. Note there is a Pivot Table tool in ArcGIS that isn't as flexible as the Excel functionality but may be helpful to you inside the ArcGIS environment.
... View more
08-06-2019
08:59 AM
|
0
|
0
|
1325
|
|
POST
|
Sorry, look above for an update, I modified the code to add the newlines (chr(10)) for you. (Unfortunately you can't use "\n" inside a Calculate Value code block you need to use chr(10) instead.)
... View more
08-06-2019
08:44 AM
|
2
|
1
|
2253
|
|
POST
|
Since this is the ModelBuilder space, I thought I'd go ahead and provide some code to use with the Calculate Value tool that would do this. This assumes you have model elements named 'Feature layer', 'Field', and 'Output text file'. If 'Feature layer' has a selection active on it, only field values from the selected rows would be written to the text file. UPDATE added needed trailing new lines and return value # Expression
f(r"%Feature layer%", "%Field%", r"%Output text file%")
# Code Block
def f(tbl, field, textfile):
# extract data to a list of text strings (with trailing newlines)
lst = []
with arcpy.da.SearchCursor(tbl, field) as rows:
for row in rows:
lst.append(str(row[0]) + chr(10))
# unique-ize and sort the list
lst = sorted(list(set(lst)))
# write to file
with open(textfile, "w") as f:
f.writelines(lst)
return textfile
# Data Type
File
... View more
08-05-2019
11:44 PM
|
2
|
3
|
2253
|
|
POST
|
To understand the tools, please read up each of the tools so you know what they do and their syntax. "Value" is the value field in the raster table, and "AREA" is an option for the zonal geometry tool. Again I suggest experimenting with these tools individually first instead of copying and pasting map algebra code so you know what you are doing. BTW "dem" would be a raster layer in your map, not a path to disk.
... View more
07-26-2019
07:42 AM
|
1
|
0
|
3440
|
|
POST
|
Glad you found a fix! All kinds of things can go wonky when your Windows drive is full. In fact back in the days of smaller hard drives, we would set the windows env variables TMP and TEMP to D:\TEMP (off the Windows system drive). So Garrett, I recommend cleaning up your C drive even now that you have archydro working! Open windows explorer, type %TEMP% in the address window, and try to delete some stuff, especially with old modify dates.
... View more
07-25-2019
04:42 PM
|
0
|
0
|
13316
|
|
BLOG
|
I do not attend as a Fed any more, I attend in my role as an educator. As the article I linked points out, Feds cannot go even if they take vacation time and use their own funds (a reasonable rule protecting Feds from conflicts of interest). I am retired (Jan 2018) so I made my way to the UC the last few years without federal support. I don't know a solution except perhaps a little more sane treatment of Federal employees by Congress. I sense the public is starting to the feel the pain of years of destructive Federal staff policies so I am hopeful the tide will turn. The only way it will change is if people vote against politicians who make their careers trashing the best government workforce the world has ever known. Surprisingly the worst of these politicians seem to hail from states that get a lot more Fed jobs and services than they pay for in taxes! </soapbox>
... View more
07-25-2019
10:42 AM
|
3
|
0
|
6521
|
|
POST
|
The raster tools have capabilities that make this pretty straightforward. Check out the following tools: Slope Con Region Group Zonal Geometry I suggest trying them on your data (using a smaller environment extent to save time) until you get a workflow that gets you what you want. Laster, you can expand the extent to process the full study area. You can use the magic of map algebra to do this analysis in Raster Calculator, using an expression that combines these tools. This may be helpful if you want to easily tweak your parameters once you have the process working. In this example I am assuming your xy coordinates are in meters so 1e6 is a 1 km2 (1000x1000 m2) minimum area. RegionGroup(Con(ZonalGeometry(
RegionGroup(Con(Slope("dem") < 10, 1)),
"Value", "AREA") > 1e6, 1)) Once you have these zones defined, you can convert them to polygons with the Raster To Polygon tool. A good way to then identify the "rounder" polygons would be to calculate the area / perimeter ratio (larger ratios are "rounder" polygons).
... View more
07-25-2019
10:08 AM
|
3
|
4
|
3440
|
|
BLOG
|
Thanks Adrian great summary. I noticed that most of the talks are from Esri personnel. PERSONAL OPINION: One reason there isn't as much energy in the user presentation part of the conference is that Federal employees have been strongly restricted from coming for years. (See this great summary by WaPo.) I have seen an agency go from ~100 attendees five years ago to only eight. Feds are a huge part of the geospatial landscape and their lack of participation hurts their mission and all of us. It's really too bad.
... View more
07-25-2019
09:41 AM
|
2
|
0
|
6521
|
|
POST
|
You cannot generate a pick list from values in a table in Model Builder as you can't do dynamic (ie run time) parameter validation. You can do that with a Python script tool however. See my response on the other thread: https://community.esri.com/thread/235176-what-can-i-do-to-build-a-model-for-a-related-database-table#comment-865901
... View more
07-21-2019
07:18 PM
|
0
|
1
|
1924
|
|
POST
|
You cannot do this with ModelBuilder, to get a custom list you need to do parameter validation. One approach to this would be write a small Python script that imports the toolbox and calls the model after doing parameter validation.
... View more
07-21-2019
07:14 PM
|
0
|
0
|
3851
|
|
POST
|
Open the bubble and enter: %output_value%. The text will be substituted there. Though, you need to provide a folder variable as well so you can give a full path: %output folder%\%output_value%
... View more
07-19-2019
07:56 AM
|
2
|
0
|
3722
|
|
POST
|
My experience is that if you have the resources Pro will use them (unlike 32-bit ArcMap which is limited to 4G per process, in a single thread). The best way to test is what you are doing, give it a try and see how well it performs.
... View more
07-15-2019
11:37 AM
|
0
|
1
|
2700
|
| 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
|