POST
|
I was able to get around this by using a bounding box that is orthogonal to the projection I'm using (as opposed to diagonal). This can be accomplished by calculating a bounding box using the Envelope option rather than the Rectangle by Area option in the Minimum bounding Geometry tool. This reduces the area to be mislabeled as 0 or -37286 to nothing!
... View more
09-28-2016
10:04 AM
|
0
|
0
|
354
|
POST
|
I'd really like an answer to this question that was posted here: https://community.esri.com/message/557007 I too am trying to iterate through sub directories and extractbymask my study area from bands of Landsat data. I'm getting the same weird output of erroneous NoData values: 0 and -37268. Not sure why the arcpy version of this code won't work since the GUI tool works fine in arc, but I need to use arcpy to run this process on about 2000 rasters. Thanks for your help and let me know if I can provide anymore info. I'm using 10.4.1
... View more
09-28-2016
09:07 AM
|
0
|
1
|
686
|
POST
|
# set the workspace to whatever location this code is in. So as long as the code and
# the database are in the same place, this code can be run.
import os
#arcpy.env.workspace = os.getcwd()
# Allows Arc to overwrite files if a file with the same name already exists.
arcpy.env.overwriteOutput = True
# Since the initial data processing may have a few steps that can't be done in Python,
# this is what to run once you have the points layer with the necessary fields.
# Set the layers we're working with.
gaugePoints = "Testgroup1" #This is the river gauge points feature class.
rivers = "courses" #This is the rivers feature class
elevationLayer = "SRTM90_V4.elevation.tif" #This is the elevation raster.
def calculateMaxHead(RFID, GFID):
riverIDCDA = str(RFID) #Converts parameters to a string.
pointName = str(GFID)
# These expressions are a bit tricky. Check the tables and adjust accordingly.
# Preferably, use fields that are numeric types.
riverClause = ''' "IDCDA" = '''+riverIDCDA #For picking out a single river
pointClause = ''' "FID" = '''+pointName #For picking out a single point
#Sets objects and file names.
river = "River1"
gauge = "Gauge1"
bufferFileName = "Rings"
headFileName = "HeadPoints"
headFileName2 = "HeadPointsSingle"
elevationFileName = "ElevationPoints"
statsFileName = "MaximumHead"
#Selects the river and the point.
arcpy.Select_analysis(rivers, river, riverClause)
arcpy.Select_analysis("Testgroup1", gauge, pointClause)
#Generates the multiple ring buffers for that point.
#500 m intervals, the 1 m buffer is to include the point itself.
arcpy.MultipleRingBuffer_analysis(gauge, bufferFileName,
[1,500,1000,1500,2000], "Meters", "distance_m")
#Generates the points of intersection between the buffers and the river.
arcpy.Intersect_analysis([bufferFileName, river], headFileName,
"ALL", "", "POINT")
#Converts the multipoint output of intersect into single points.
arcpy.MultipartToSinglepart_management(headFileName, headFileName2)
#Extracts elevation values from the raster to the points.
arcpy.sa.ExtractValuesToPoints(headFileName2, elevationLayer, elevationFileName)
#Runs summary statistics to get the range of elevation.
#Picks out that statistic from the table using a cursor.
arcpy.Statistics_analysis(elevationFileName, statsFileName, [["RASTERVALU", "RANGE"]])
cursor = arcpy.SearchCursor(statsFileName)
headMax = 0
for x in cursor:
headMax = x.getValue("RANGE_RASTERVALU")
return headMax
#Iterates over the entire table and calculates head for each point.
fields = ["IDCDA", "FID", "Head"]
with arcpy.da.UpdateCursor(gaugePoints, fields) as cursor:
for row in cursor:
r = row[0]
g = row[1]
row[2] = calculateMaxHead(r,g)
cursor.updateRow(row)
Here is the error reading I get when I run the code: The script basically sets an initial starting point, generates heads (difference in elevation between two flow points in a river) based on end points set at regular (Euclidian) length intervals from the start point (out to 2 km), then moves the starting point and repeats the process. I'm not sure what "cannot acquire a lock" means or hwhy "FID"=0 is an invalid expression. I'm realtively new to using ARcGIs and especially Python in ArcGIS so any help/explanations are appreciated.
... View more
08-05-2015
11:50 AM
|
0
|
2
|
965
|
POST
|
Hi Darren, Thanks for your help. For some reason, when I run the buffer tool on a different computer, the output works and I have no problem. The buffer shapefile (Testgbuff) is able to be stored in the Default geodatabase and there is no more issue with the intermediate shapefiles being created and stored in the scratch geodatabase. Attached is a picture of the inputs I used for the tool as well as a visualization in the upper right corner of the rings created. Do you know what changed to make the script work now as opposed to before? Also, I have a python script that is supposed to run through these and other processes for a much larger set of points. I've been using the manual tools to try to trace back the issue but I am still receiving errors when running the script. I'll post the script I'm using and the error I'm receiving below this reply.
... View more
08-05-2015
11:09 AM
|
0
|
0
|
965
|
POST
|
I keep running up against an error where after running the MRB tool on a point shapefile or a point geodatabase feature class, I get an error code of 000210 because a file, "union.shp.shp" is invalid and can't be exported to the scratch workspace. How do I get around this? Attached is a picture of the error.
... View more
07-29-2015
12:50 PM
|
0
|
5
|
4306
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|