POST
|
I switched it to an array and it works very well. But I am having an issue inputting values on the attribute table. My code is receiving no errors but I believe it is only inputting the values at the end of the array. I have it looping 4 times but it is only filling in one row of the table. What is the main issue going on?
... View more
10-06-2017
11:50 AM
|
0
|
1
|
12956
|
POST
|
I am having an issue of creating an array of floats. I have a loop that is scanning the rows of an attribute table and extracting numbers from it. SARAarea, truearea and rasterarea are all extracted from an attribute table and they should be floats. I am trying to use these numbers and do calculations with them and then insert them back into the attribute table. My main issue is adding floats to the list. I keep getting error messages that a float is not iterable or a float is not an attribute to append or extend. What is the best way to do this? I tried to create one loop that would getvalue and insert value into the attribute without using a list. But the searchcursor function only allows me to create two separate loops because there is a seachCursor and a UpdateCursor, it only allows me to do one task at a time. This is my attempt at initializing the lists approxTen=['f']
approxremaining=['f']
lessperc=['f']
moreperc=['f'] This is where I am getting my errors. The code is in a while loop of a searchCursor. "While row:". approxTen=(SARAarea*truearea)/rasterarea
approxremaining=truearea-approxTen
lessperc=(approxTen/truearea)*100
moreperc=(approxremaining/truearea)*100
approxTen.append(approxTen)
approxremaining.append(approxremaining)
lessperc.append(lessperc)
moreperc.append(moreperc) Common error I am getting below. Line 50 is line 7 in the code above. I have tried extend and append but neither worked and I haved tried putting float() around the values of approxTen and the rest of them but it did not work. For example: approxremaining= float(truearea-approxTen) This is how I am inserting it back into the attribute table. Below is a separate loop then above code. I am trying to loop through the list and add it to the attribute table. while row3:
row3[0]=approxTen[row3]
row3[1]=approxremaining[row3]
row3[2]=lessperc[row3]
row3[3]=moreperc[row3]
cursoru.updateRow(row3)
... View more
10-06-2017
07:33 AM
|
0
|
6
|
55485
|
POST
|
So the In-Line Variable Substitution works great! but after the Model Builder is executed it delete the previous raster and only gives me the raster it created. How can I prevent it from deleting the previous rasters from the folder when it completes the raster builder?
... View more
08-15-2017
10:39 AM
|
0
|
1
|
2791
|
POST
|
I am trying to create a model builder and it creates various raster's while it runs. I want to have the option to pick what folder I want to save every thing in. Having the set up something like this. In the model builder I want the workspace to be connected to every raster output. It gives me the option to make this the "current workspace" when I try to connect it but the arrow does not stick with it. I have the arrows set to precondition. Is there anyway I can get around this? I want to be able to use this model builder on multiple map documents but with different folders where the layers will go.
... View more
08-14-2017
02:34 PM
|
0
|
3
|
3839
|
POST
|
I am trying to emulate the raster calculator that takes a flow accumulation raster and turns it into a stream raster. Where the number "849840" is the threshold value. How would I use the Set Null tool in the model builder that will give me the same results? What would I put in the fields?
... View more
08-11-2017
09:30 AM
|
0
|
2
|
1658
|
POST
|
A program that I created has a loop that runs and it constantly lowers the values of a flow accumulation Raster. There gets to a point where the Raster should hit the value zero or no data. The raster comes out with a positive big number and a negative big number, which messes up the calculate statistics function in the loop. Here it is below. This is an example of the error I would receive Is there a way I can create an if statement in the loop to check for a raster that looks like this and break away from the loop? Something like this but a statement that would work.
... View more
08-10-2017
12:29 PM
|
0
|
2
|
880
|
POST
|
I am using model builder and python to delineate all the major watersheds on a dem. I am using model builder to create the flow direction and flow accumulation. I am using a python script to delineate all the major watersheds. For the python script I have a loop that needs to end on a condition number and I would like that condition number to be one of the break values because if I have the condition number set to 0 it will start making watersheds that are really small and unimportant for my use. So I am going to remain consistent and use that code you provided for me and use the second value in the loop. I do have a problem using it in different documents. It works in one document but it does not work in another document. The document that does not work the code runs but it does not read the break values in the layer and the layer is already created and has break values. So I am not sure what is wrong with it. What would be the best way to fix this issue? import arcpy from arcpy.sa import * from arcpy import env Flowaccumulation=r"C:\Temp\ARCGIS_PROJECT\Tutorial\new\fa" flowdirection= r"C:\Temp\ARCGIS_PROJECT\Tutorial\new\fd" pointcount=50 mxd=arcpy.mapping.MapDocument(r"CURRENT") df=arcpy.mapping.ListDataFrames(mxd)[0] lyr=arcpy.mapping.ListLayers(mxd,"fa",df)[0] count=1 if lyr.symbologyType == "RASTER_CLASSIFIED": values= lyr.symbology.classBreakValues for val in values: if count==2: Condition=val break count= count + 1 maxValue= Condition + 1 while maxValue > Condition:
... View more
08-08-2017
09:55 AM
|
0
|
0
|
901
|
POST
|
I created a program that generates all the major watersheds that occur on a DEM using a flow accumulation raster. So the only problem that I have, is that my "while loop" depends on the weighted values of the flow accumulation raster. So the condition number I used was 0. This caused my program to create way too many watersheds and most of them I do not need. So I need a threshold number to use as my condition to end the loop. I noticed that I can use the break values that are stored in the classified section in the symbology tab and these values are calculated from a histogram. This would be an example of a threshold number I would use. Any number below the first break value would give me watersheds that I do not need. What would be the best way to extract this number? I would prefer not to use arcpy.mapping and just have an equation I can use on every Raster to give me a general threshold number in my program. Is there anyway I can use the Maximum,minumum,mean or std value to calculate it using statistics? is there a better threshold number I could use instead? Thank you for your help.
... View more
08-07-2017
07:56 AM
|
0
|
0
|
1324
|
POST
|
There are multiple inputs in my code and I was wondering how I can have those inputs made within model builder. I am going to have many outputs so I am not interested in adding a code that makes an output block in the model builder, just inputs. For example, the code below. I want to write a code that would replace Flowaccumulation and Flowdirection as my inputs in the code because its just reading a file that I told it to. I want to replace it with code that I can manually put inputs in them through model builder. Please show me a code and not just a link. Thank you. import arcpy
from arcpy.sa import *
from arcpy import env
Flowaccumulation="rC:\Temp\ARCGIS_PROJECT\Tutorial\LAYERS\dem_fa"
Flowdirection= "rC:\Temp\ARCGIS_PROJECT\Tutorial\LAYERS\dem_fd"
... View more
08-07-2017
06:03 AM
|
0
|
2
|
788
|
POST
|
If I were trying to read the break values. How would I do it? The code below would change the break values. Also I would I use raster in this example? import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Lakes")[0] lyr = arcpy.mapping.ListLayers(mxd, "lakene.tif", df)[0] if lyr.symbologyType == "RASTER_CLASSIFIED": lyr.symbology.classBreakValues = [1, 60, 118, 165, 255] lyr.symbology.classBreakLabels = ["1 to 60", "61 to 118", "119 to 165", "166 to 255"] lyr.symbology.classBreakDescriptions = ["Class A", "Class B", "Class C", "Class D"] lyr.symbology.excludedValues = '0' arcpy.RefreshActiveView() arcpy.RefreshTOC()
... View more
08-07-2017
05:52 AM
|
0
|
2
|
901
|
POST
|
Hey I am trying to write a python code and I want to use Break value number as a condition in a loop. I am planning on using many different rasters for this program, so I want the program to accomadate any break values. in this example I would like to use 1,076,856.8 as my condition number. in this example I would like to use 5,491,233.553 as my condition number. I understand that every raster will have different default classes depending on how the zonal histogram calculator works. But I would like for it to remain consistent for every Raster I use. What would be the best way to get this number while using the Python language?
... View more
08-04-2017
12:20 PM
|
0
|
4
|
1774
|
POST
|
I am having issues with loops and if statements in python. I keep getting an error on the last line. What am I doing wrong? import arcpy
from arcpy.sa import *
from arcpy import env
sorder=r"C:\Temp\ARCGIS_PROJECT\Tutorial\Final\layers\streamorder"
desc= arcpy.Describe(sorder)
xmin= desc.extent.XMin
ymin=desc.extent.YMin
xmax= desc.extent.XMax
ymax= desc.extent.YMax
count= 0
for columns in range (xmin, xmax):
pointval= arcpy.GetCellValue_management(sorder,"%s %s" % (columns++,ymin), "1")
if (pointval== 1, pointval==2, pointval==3):
count++
print "count= %s" % (count)
... View more
08-02-2017
08:55 AM
|
0
|
6
|
1314
|
POST
|
I want to know how I can put a point shape file where the most accumulated point on the flow accumulation raster without manually putting it in. So I can make a watershed from it. Is there anyway to do this in the model builder? Can the Snap Pour Point tool work? What would be the *input raster or feature pour point data* if that were the case?
... View more
08-01-2017
04:02 PM
|
0
|
1
|
912
|
POST
|
my goal is to add a point where the stream meets the bottom of the DEM and use those points to make watersheds. I used "dem_order.ymin+6941" because I havent made a variable yet that holds the number of rows and columns in that given raster. Adding +6941 will give me the last row in the raster where the stream touches the bottom of the page. In this example I would want two watersheds to be made. Am I using the right approach to do this?
... View more
08-01-2017
12:44 PM
|
0
|
0
|
273
|
POST
|
Hey I am trying to automate the process to add watersheds at the most accumulated points at the bottom of the dem layer. I created a stream order to provide as a template to place the points and a flow direction to create the watershed. The stream order has 9111 columns and 6941 rows. I am creating a point shapefile at every value (1,2,3) at the last row of the matrix. The main problem I have is saving multiple points and given them each a unique name and saving watersheds and giving them a unique name each time it goes through a loop. I am pretty novice at python. I need help with the last part of the code. I keep getting a syntax error on the last line. import arcpy
from arcpy.sa import *
from arcpy import env
demorder="C:\Temp\ARCGIS_PROJECT\Tutorial\LAYERS\dem_order"
flowdirection="C:\Temp\ARCGIS_PROJECT\Tutorial\LAYERS\dem_fd"
try:
for columns in range(0,9111):
point=arcpy.Point(demorder.xmin + columns, dem_order.ymin+6941)
pointval= arcpy.GetCellValue_management("dem_order","point", "2")
if (pointval==1 or pointval==2 or pointval==3):
pointgeom = arcpy.pointgeometry(point,"W:\ArcMap\Coordinate_Systems\NAD 1983 StatePlane Texas S Central FIPS 4204 (US Feet) SURFACE.prj")
Pshape= arcpy.CopyFeatures_management(pointgeom,"C:\Temp\ARCGIS_PROJECT\Tutorial\points")
watershed= arcpy.watershed(flowdirection,Pshape)
arcpy.CopyRaster_management(watershed,"C:\Temp\ARCGIS_PROJECT\Tutorial\points")
... View more
08-01-2017
11:46 AM
|
0
|
3
|
452
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|