|
POST
|
We can't check your loop unless you [thread=48475]post your code in a code block![/thread] Python indentation is significant!
... View more
03-19-2012
02:34 PM
|
0
|
0
|
2109
|
|
POST
|
For example, right now I'm trying to figure out how to take a list of tables in a geodatabase and combine the contents into a single table. In R with common column names the command is rbind. In Python maybe I'd need to use vstack... If the tables are in a geodatabase already, why not just use the Merge tool? The field mapping object gives you an awful lot of extra functionality - for example, if the column names don't match you can build mappings.
... View more
03-19-2012
08:06 AM
|
0
|
0
|
2155
|
|
POST
|
This is a cross-post from the [post=181728]Geoprocessing forum:[/post] Hello, I have constructed a model that uses an OLS regression towards the end. I would like the values for two of the coefficients to be used as part of a raster calculator equation that rebuilds the regression and outputs to a raster. I have entered the equation that I want to use in the Raster Calculator tool, but cannot figure out how to make the two coefficients from the OLS regression become part of the equation (they are not listed as options under the Layers and Variables section of Raster Calculator). Part of the problem is that the model is designed to have those two coefficients be different every time the model is run. Is there any way that I can have the two coefficients become part of the equation? I have attached a screen shot of the model for clarity. Any help is greatly appreciated... [ATTACH=CONFIG]12790[/ATTACH] There is some missing information here.... I'm assuming your "variables" output from the script tool is a string right? Say it's a space delimited text with two numbers: "234.2 -12.4". Add two Calculate Value tools to your model (right click / model tools/ calculate value) and set "variables" as a precondition to both so they will run after your OLS script. The expressions (one for each Calculate Value) would look like this, using the default output type (Variant) would be fine. Note the correct use of quotes and "%" characters in Calculate Value, this is important and took me a while to figure out. (The % substitution happens before any python interpretation happens, the quotes are part of Python syntax designating the values between the quotes compose a text string.) "%variables%".split()[0] # python sees "234.2 -12.4".split()[0] (== "234.2")
"%variables%".split()[1] # == "-12.4" (BTW, if you use path variables in Calculate Value you must use the syntax r"%input dataset%" to make sure the Windows path back-slashes are interpreted correctly by Python.) ModelBuilder will give them default names "output_value" and "output_value (2)". Rename them to "regval1" and "regval2". At this point you can precondition these two on a second calculate value expression, when does python string manipulation to create your map algebra expression, or you can enter the values %regval1% and %regval2% directly into the Map Algebra tool. I'm not sure which will work better in this situation, though I like the second approach better as you can connect raster inputs into the tool which makes for a prettier ModelBuilder presentation.
... View more
03-18-2012
12:46 PM
|
0
|
2
|
2837
|
|
POST
|
There is some missing information here.... I'm assuming your "variables" output from the script tool is a string right? Say it's a space delimited text with two numbers: "234.2 -12.4". The key to this is use of the Calculate Value tool to parse this output into new model variables that can be used in your Raster Calculator expression. Calculate Value is the glue that really makes ModelBuilder more than a handy macro and demo toy. Unfortunately, it is unavailable if you just have an ArcView license (but it does get added with Spatial or 3d Extensions). I posted [thread=182131] my complete answer[/thread] over on the Spatial Analyst forum because I think this is really a Raster Calculator tool question.
... View more
03-18-2012
12:30 PM
|
0
|
0
|
1307
|
|
POST
|
If kriging is the optimal interpolator (under certain conditions), wouldn't it also be the optimal method for making contour maps? If the point of your contour map is to demonstrate a trend, you may want random noise or the effect of outliers to be removed from your contours -- as this would obstruct what you're trying to show with the contours. However, the cell by cell unbiased estimate of value, although it may make very ugly and maybe even nonsensical contours, may be what you want if you want a best estimate of a value over a drainage basin or over a groundwater model cell. Remember for every output gridcell that doesn't land exactly on a point of input data (pretty much everywhere, in most cases!) you will be "making up data" -- the surface you are generating is a model, and as one of my colleagues likes to say: "all models are wrong, some are useful."
... View more
03-18-2012
12:19 PM
|
0
|
0
|
2809
|
|
POST
|
Okay, I'll jump in. You probably will have better luck if you convert your land area polygon to raster first using Polygon To Raster. This gives you more control and also is more likely to succeed with your complex polygon feature. 1. Set the output Coordinate system to your output raster "myraster" 2. Set extent to your raster dataset (or smaller area if you want), set snap and cell size to your raster dataset 3. Run Polygon To Raster, this will make a raster ("mask1") with NoData outside. Take a good look at "mask1" and make sure it's what you want, at this point you can go back to the Results and rerun Polygon To Raster until you have it just right. 4. Try either (both approaches require a Spatial Analyst license): -- a. Reclassify "mask1" to remap "value cells" to NoData ("mask2") and NoData cells to 1 -- b. Extract By Mask with "myraster" and the mask dataset "mask2" or, -- Map algebra tool: Con(IsNull("mask1"),"myraster") (in English: for each cell, if "mask1" is NoData, output value of "myraster") With map algebra you can build some pretty complex processing that runs very efficiently compared to doing it with the equivalent tools one-by-one. (After all, "raster is faster, but vector is correcter".) Happy Saturday!
... View more
03-17-2012
06:19 AM
|
0
|
0
|
3416
|
|
POST
|
The quotes matter The reason the quotes matter is arcpy.env.overwriteOutput is a boolean value, not text, no matter how you set it.
>>> arcpy.env.overwriteOutput = 'True'
>>> arcpy.env.overwriteOutput
True
>>> arcpy.env.overwriteOutput = 1
>>> arcpy.env.overwriteOutput
True
Fortunately for you, it seems, Esri has set things up so if you set it this property to 'False' (string) it evaluates to False. (Normally in Python, any non-null string evalulates to boolean True.) >>> arcpy.env.overwriteOutput = 'False'
>>> arcpy.env.overwriteOutput
False
>>> bool('False')
True Also since it is boolean type your original test can be written more simply: if arcpy.env.overwriteOutput:
print "It is true!"
else:
print "It is false!"
... View more
03-16-2012
11:38 AM
|
0
|
0
|
1093
|
|
POST
|
Ok, let me try again. We have about 20 of sites in Africa, each defined by lat, long and a third variable. Instead of elevation our 'z' variable is a measurement of the ecological distance between each site and an archaeological site. We want to display this visually by plotting contours on a map, but we aren't sure what interpolation method to use to plot the contours between the sites. One suggestion we have gotten is nearest neighbour, but I've also tried IDW and Global Polynomial. Does that help at all? There really is no hard and fast rule about which is most appropriate, it kind of depends on what you're trying to do. Global Polynomial is normally used to find overall trends (so you can isolate local effects). However, with really noisy data, overall trends (although unlikely to pass through your points if you choose a low order polynomial) may be exactly what you want to calculate -- the trend will be smooth and obvious. IDW is the simplest interpolator (really a family of interpolators based on neighborhood and power choices). Nearest neighbor is a special case of IDW (when you choose to use only 1 neighbor for each estimate) -- and is equivalent to creating Thiessen polygons. It doesn't always make very pretty surfaces. "Natural Neighbor" is a nice general-purpose interpolator Esri provides that is sort of a hybrid of IDW and a nearest-neighbor approach - it weights by shared "territory" as defined by the thiessen polygons instead of merely distance. If your data show a clear pattern and you want your contours to completely agree with your input points, spline interpolators are a worth trying. You can tweak splines to model the amount of local variablity in your data. Since they are a curve fit through points, outliers can give you some very unhelpful surfaces (doing a spline can help you identify such unhelpful points, as they can warp your surface horribly). Kriging is more for parameter estimation than making contours, say if you are estimating values that go into another model and you want the best linear unbiased estimate at every gridcell. (This is usually not a very "pretty" trend suface.) Your mileage may vary, but I hope this quick overview helps! Its best to read up on each interpolator so you have a better idea of their strengths and weaknesses for your task and your dataset.
... View more
03-16-2012
09:25 AM
|
0
|
0
|
2809
|
|
POST
|
We basically need to connect regions with the lowest z values, then those with the next lowest, etc, with interpolation between our points. Can you try explaining this again? I think you lost us here.
... View more
03-16-2012
07:39 AM
|
0
|
0
|
2809
|
|
POST
|
Will File Geodatabase have the same limitations? I do not know if my problem which is basically I can't get extract values to work on my larger files when it works on my smaller flies. Extract Multi Values to points has been a little more squirrelly about things like spaces in pathnames, but the biggest issue you may be running in with your large files of millions of points is that if the workspace is a folder, you may run into the 2.1GB limit of file size (with .dbf files). I'm assuming that's where this advice was coming from - from tech support? Other posts? At 9.3, no matter the ultimate desination, the output would be written to a .dbf in the scratch workspace (or a the folder above it) and then copied to the eventual output location -- so there was no way around the 2.1GB limit and tiling your data was the only way around it. You could monitor the scratch workspace (which should be in the same .gdb for quickest processing). If the .dbf size is the issue, if you monitored a file scratch workspace, you'd see the temporary .dbf file grow until the tool crashes. Since ArcGIS 10.x Spatial Analyst tools now do native read write, the current and scratch workspace can both be set to file geodatabase, and no .dbf is written, so you may have a little more luck with your large files. Sample is an older tool (from Arcinfo GRID) that is a little clunkier but sometimes will work with EVTP will not. BTW, you can look at issues addressed on the service pack page, searching though the NIMs for things you are interested in. Also, if you have a NIM, sometimes you can find it on the support site by searching by its number to check on its status. If it's not there, tech support is usually happy to check on the status of a known NIM for you.
... View more
03-16-2012
07:34 AM
|
0
|
0
|
735
|
|
POST
|
If your post is really about general geoprocessing, please consider going to the Geoprocessing forum instead. This will help get better answers posted for both Python and geoprocessing questions.
... View more
03-16-2012
07:13 AM
|
0
|
0
|
572
|
|
POST
|
Two thoughts - 1. You can easily undupe a python list like this. >>> x
[4, 4, 1, 2, 2, 3]
>>> list(set(x))
[1, 2, 3, 4]
>>> 2. I know this is the Python forum -- but want to note you could also do this task with no code using a unique fields iterator in model builder connected to the Make Feature Layer tool. The expression would include the model variable Value output by the iterator at each unique value of your field. You could cap it off using the Collect Values tool piped into AddLayerToGroup to do that final step Jake suggests. However, my experience with model builder is it is usually in my interest not to "gild the lily" so to speak, and focus on setting it up to automate tasks - not create exceedingly complex tools. Though every version adds a little more oomph!
... View more
03-16-2012
06:21 AM
|
0
|
0
|
1670
|
|
POST
|
It looks like you're not using delimeters around field names. Please check the tool help - and maybe use the calculation builder wizard (click on the little calculator icon) for guidance.
... View more
03-15-2012
05:59 PM
|
0
|
0
|
3710
|
|
POST
|
How does this calculation calculate 49.2 back to 49? VBScript's Int() does not round, it truncates. (49.2 + .5 = 49.7; Int(49.7) = 49.) You're welcome!
... View more
03-15-2012
03:13 PM
|
0
|
0
|
3728
|
|
POST
|
I had been trying to do something similar with the SnapPointPoint. I am converting from the gp to arcpy. What I found was I was trying to create a grid and it didn't like it. So I created a filegeodatabase for my results to go into. This seems to have solved my issue. All of my original data is in GRID from arcgis 9.3 I plan to convert it, but I wanted to get the python scripts working first. The grid data format is very path sensitive - you need to be very careful to avoid long grid names or names that do not follow the very restrictive grid/coverage naming rules. On the plus side, the grid data format is usually faster to process (though this depends on the tool).
... View more
03-15-2012
01:46 PM
|
0
|
0
|
1307
|
| 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
|