POST
|
Hello, I'm batch-processing some watershed stuff and wish to automatically export the values in a raster table to anything useful outside of GIS, such as a .txt, .csv or .xls file. I cannot locate this command. It was once upon a time quite easy with Arc/INFO but those days have passed. Also, the ability to append to the output file (rather than write 100s of different files) would be very nice. Any advice? Thanks! Ryan
... View more
02-13-2012
10:55 AM
|
0
|
1
|
4321
|
POST
|
Hello, I am very new to Python scripting- and used to program in Arc/INFO (how I miss it so these days). All I am trying to do is write a script that will 1) import a list of integers from a CSV file, 2) use this list to select points in a shapefile with matching values, and 3) run the hydro tool "Snap pour point" & save the pour point. I thought that I had made great progress yesterday and had the code completed (thanks to Curtis). However, the code below produces nonsensical, non-existent pour points and, for some reason, the code deleted all of the entries in the point shapefile I pointed it to!!! The shapefile still exists, but is completely empty. And the SnapPourPoint command seems reasonably easy enough; thus I have no idea why it results in completely empty entities... Please help a newcomer!! This is driving me crazy and I am really not becoming a Python fan... -CSV file: "E:/Weathering_GIS/Sheds.csv", point shapefile [that gets emptied for some reason]: "E:/Weathering_GIS/Working.gdb/USGS_Points", flow accumulation grid: "FAC_NORTHEAST" Thanks, Ryan Code: import csv, arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
env.workspace = 'E:/Weathering_GIS/Working.gdb'
try:
f = open('E:/Weathering_GIS/Sheds.csv')
sheds = csv.reader(f)
for row in sheds:
arcpy.MakeFeatureLayer_management('E:/Weathering_GIS/Working.gdb/USGS_Points', 'Shedpoints')
where = "GageCode = %s" % int(row[0])
arcpy.SelectLayerByAttribute_management("Shedpoints","NEW_SELECTION",where)
snapped = SnapPourPoint("Shedpoints","FAC_NORTHEAST",0.0001)
out = "X%s" % str(row[0])
snapped.save("E:/Weathering_GIS/Working.gdb/"+out)
except:
del sheds
f.close()
raise
... View more
02-10-2012
06:28 AM
|
0
|
2
|
236
|
POST
|
Curtis, Wow... very perceptive guess on what was the problem. Indeed, "GageCode" was an integer. Thanks for helping; perhaps I'm not going about this the right way, but I've taught myself other languages in the past and always gotten along. Thanks! Ryan
... View more
02-09-2012
01:26 PM
|
0
|
0
|
1793
|
POST
|
Curtis, Thanks very much for the feedback. I wasn't anywhere near that. However, I'm still getting the error: ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute). even if I just cut-and-paste your code. I'm amazed that this is so challenging...
... View more
02-09-2012
01:10 PM
|
0
|
0
|
1793
|
POST
|
Hello, I'm valiantly attempting to teach myself Python scripting, and not enjoying this very much so far... All I am trying to do is import a list file (.csv) that corresponds to a field in a shapefile and batch-process some basic GIS functions in a loop. I cannot figure out how to call up the .csv entry in a list for use in an arcpy command. Forgive me if this is a very basic problem, but I've scoured the web for hours trying to figure this out and am getting nowhere fast. When one is for-looping with arcpy commands, how in the world do you get Python to accept the value in the loop?? Below I can successfully import the .csv list, get one arcpy command (MakeFeatureLayer_management) to go, but then when I want to insert the first value from the .csv list (in the SelectLayerByAttribute_management command) , nothing I try satisfies Python. What am I doing wrong here?!? Here's the code: import csv, arcpy sheds = csv.reader(open('E:/Weathering_GIS/Sheds.csv','rb')) from arcpy import env from arcpy.sa import * arcpy.CheckOutExtension("Spatial") env.workspace = 'E:/Weathering_GIS/Working.gdb' for row in sheds: print row arcpy.MakeFeatureLayer_management('E:/Weathering_GIS/Working.gdb/USGS_Points', 'Shedpoints9') arcpy.SelectLayerByAttribute_management("Shedpoints9", "NEW_SELECTION", "GageCode='"+row.insert) #here's where it's breaking. How can I insert the first of the "sheds"?!? Thanks, Ryan
... View more
02-09-2012
12:32 PM
|
0
|
4
|
6201
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|