POST
|
Could probably do a TableToTable_conversion on your input file. the TableToTable allows an expression so you could only copy the rows without nulls/blanks to the new table (possibly in memory) and use that table for your input. Just a thought that doesn't need an if/then statement for each iteration. R_ yeah, that is what I've done.. but it would be nice to know where the nulls are or how many there are.. I'm working on trying to figure out how to run a cursor and check values.. but for now this works.. I first convert the csv file to a table within a gdb and then convert the gdb table to another table minus the nulls.. here is the code.. #convert csv to table
table1 = "C:\\temp\\GIS_projects\\Sample_tripData\\TEST_HAUL_DATA.csv"
gdb = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb"
table2 = "testHaul"
table3 = "cleantestHaul"
fieldName = "HaulSeqNum"
print "Converting CSV table to GDB table..."
arcpy.TableToTable_conversion(table1, gdb, table2)
expression = arcpy.AddFieldDelimiters(arcpy.env.workspace, "DLONGDD") + " IS NOT NULL"
print "Excluding null values..."
arcpy.TableToTable_conversion(table2, gdb, table3,expression)
fc = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines" Thanks..
... View more
06-11-2013
10:02 AM
|
0
|
0
|
365
|
POST
|
I am not certain, but did notice your spatial reference parameter is not set... you should try specifying that. Sorry that's all I can think of that looks suspicious to me - oh, and I'd also avoid writing to the temp directory. The 'table not found' error can be sort of cryptic... If you are still having difficulty, you can try attaching a portion of your csv (or all if small enough to attach here) and I'll see what I can do with it later, possibly tomorrow... Enjoy, Wayne EDIT I was curious for you to test something - see what happens if you can specify shapefile output. This may not be allowed for this tool. You can set up a different kind of test to see if you can make an event layer out of the point coordinates, then copy to a shapefile... not sure, but if you can do this to create shapefile output but not file gdb output, chances are the spatial reference is problematic. Again, just guessing without experimenting. Wayne, As it turns out, the script runs, although I did add the spatial reference.. I looked into the shapefile output.. but it looks as though the tool only outputs a feature class. I think I found the problem though, and it wasn't the script per sa.. I found that some of the entries in the csv file I was using had some empty cells in the data fields I was using. So, the short of it is that I needed to make sure my data was complete and didn't include Null values.. A little embarrassing.. Thanks for your help on this though.. really appreciate the effort.. now I need to figure out how to get it to check for null values.. here is the updated code... # Import system modules
import arcinfo
import arcpy
import sys
if arcpy.CheckProduct("ArcInfo") == "Available":
print "ArcInfo available, processing script..."
print "importing modules and setting environment...."
#overwrite pre-existing files
arcpy.env.overwriteOutput = True
#delete old feature class
#if arcpy.Exists("c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines"):
#arcpy.Delete_management ("c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines")
#set workspace
arcpy.env.workspace = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb"
fc = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines"
fieldName = "HaulSeqNum"
# Set local variables
print "gathering input table data...."
input_table = "C:\\temp\\GIS_projects\\Sample_tripData\\TEST_HAUL_DATA.csv"
# tool variables
print "setting up variables for XY to Line management tool..."
in_table = input_table
out_featureclass = fc
startx_field = "DLONGDD"
starty_field = "DLATDD"
endx_field = "RLONGDD"
endy_field = "RLATDD"
line_type = "GEODESIC"
id_field = fieldName
print "setting the spatial reference..."
spatialRef = arcpy.SpatialReference("C:\\temp\\GIS_projects\\Sample_tripData\\TRIPs_GOA_STAT7.prj")
#XY To Line
print "running XY to Line Geoprocessing tool..."
arcpy.XYToLine_management(in_table, out_featureclass, startx_field, starty_field, endx_field, endy_field,line_type,id_field,spatialRef)
# Process to delete identical line features...
# Set the field upon which the identicals are found
fields = '"Shape;' + fieldName + ';Shape_Length"'
# Set the XY tolerance within which to identical records to be deleted
xy_tol = "0.0002 Miles"
# Set the Z tolerance to default
z_tol = "0"
print "Deleteing identical features..."
# Execute Delete Identical
arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol)
print "Dropping leading character..."
cursor = arcpy.UpdateCursor(fc)
field = fieldName
row = cursor.next()
while row:
# set value of field to only those values after the zero value location
# I want to strip off the first character within the value of the field
row.setValue(field, row.getValue(field)[1:])
cursor.updateRow(row)
row = cursor.next()
print "Processing Complete!"
else:
print "ArcInfo license not available"
sys.exit("ArcInfo license not available")
... View more
06-11-2013
08:16 AM
|
0
|
0
|
743
|
POST
|
@Wayne, thanks.. I tried it both ways.. this time it ran through the process and executed the xytoline_management tool.. I checked the env and it was correct this time.. thanks for the heads up.. :0) anyways, the tool ran and the csv was converted to lines.. but then it threw another error.. same as the first.. here is the error message... Traceback (most recent call last):
File "C:\temp\GIS_projects\Sample_tripData\test.py", line 22, in <module>
arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM")
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine
raise e
ExecuteError: ERROR 999999: Error executing function.
The table was not found. [tripLines]
Failed to execute (XYToLine). here is my new updated code... # Import system modules
import arcinfo
import arcpy
import sys
if arcpy.CheckProduct("ArcInfo") == "Available":
print "ArcInfo available, processing script..."
print "importing modules and set environment...."
#overwrite pre-existing files
arcpy.env.overwriteOutput = True
#set workspace
arcpy.env.workspace = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb"
fc = "tripLines"
# Set local variables
print "setting data input and output variables..."
input_table = "C:\\temp\\GIS_projects\\Sample_tripData\\A6_TEMP_ATL_TRIP_HAULx.csv"
#XY To Line
print "running XY to Line Geoprocessing tool..."
arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM")
# Process to delete identical line features...
# Set the field upon which the identicals are found
fields = "Shape;TRIPSEQNUM;Shape_Length"
# Set the XY tolerance within which to identical records to be deleted
xy_tol = "0.0002 Miles"
# Set the Z tolerance to default
z_tol = "0"
print "Deleteing identical features..."
# Execute Delete Identical
arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol)
print "Dropping leading character..."
cursor = arcpy.UpdateCursor(fc)
field = "TRIPSEQNUM"
row = cursor.next()
while row:
# set value of field to only those values after the zero value location
# I want to strip off the first character within the value of the field
row.setValue(field, row.getValue(field)[0:])
cursor.updateRow(row)
row = cursor.next()
del fc, input_table, row, cursor, out_lines, input_table, field
print "Processing Complete!"
else:
print "ArcInfo license not available"
sys.exit("ArcInfo license not available")
... View more
06-07-2013
01:28 PM
|
0
|
0
|
743
|
POST
|
Well, I've made the changes to the script that @Zufelt and @Wayne have mentioned.. Yet, I am still getting an error.. this time says "Cannot create Featureclass TripLines" Could it be that I'm not specifying the license? here is the error message... Traceback (most recent call last):
File "C:\temp\GIS_projects\Sample_tripData\test.py", line 20, in <module>
arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM")
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine
raise e
ExecuteError: ERROR 000206: Cannot create FeatureClass tripLines
Failed to execute (XYToLine). here is my modified code... # Import system modules
import arcpy
from arcpy import env
print "importing modules and set environment...."
#overwrite pre-existing files
arcpy.env.overwriteOutput = True
#set workspace
env.workspace = "c:\temp\gis_projects\sample_tripdata\test.gdb"
fc = "tripLines"
# Set local variables
print "setting data input and output variables..."
input_table = r"C:\temp\GIS_projects\Sample_tripData\A6_TEMP_ATL_TRIP_HAULx.csv"
#XY To Line
print "running XY to Line Geoprocessing tool..."
arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM")
# Process to delete identical line features...
# Set the field upon which the identicals are found
fields = "Shape;TRIPSEQNUM;Shape_Length"
# Set the XY tolerance within which to identical records to be deleted
xy_tol = "0.0002 Miles"
# Set the Z tolerance to default
z_tol = "0"
print "Deleteing identical features..."
# Execute Delete Identical
arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol)
print "Dropping leading character..."
cursor = arcpy.UpdateCursor(fc)
field = "TRIPSEQNUM"
row = cursor.next()
while row:
# set value of field to only those values after the zero value location
# I want to strip off the first character within the value of the field
row.setValue(field, row.getValue(field)[0:])
cursor.updateRow(row)
row = cursor.next()
del fc, input_table, row, cursor, out_lines, input_table, field
print "Processing Complete!"
... View more
06-07-2013
12:31 PM
|
0
|
0
|
743
|
POST
|
I am working on a script trying to plot lines from csv point data file.. It all seems to work until the end where I get an error stating that the table is not found.. when I open the FC in the map view, I see that I am getting the result I was expecting.. any help would be greatly appreciated.. here is the error... Traceback (most recent call last): File "C:\temp\GIS_projects\Sample_tripData\test.py", line 27, in <module> "TELATDD","GEODESIC","TRIPSEQNUM") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine raise e ExecuteError: ERROR 999999: Error executing function. The table was not found. [trip_lines] Failed to execute (XYToLine). here is my code.. # Import system modules import arcpy print "importing modules and set environment...." from arcpy import env env.workspace = "c:/temp/gis_projects/sample_tripdata/test.gdb" fc = "trip_lines" #overwrite pre-existing files arcpy.env.overwriteOutput = True # Set local variables print "setting data input and output variables..." input_table = "C:/temp/GIS_projects/Sample_tripData/A6_TEMP_ATL_TRIP_HAULx.csv" # check to see if FC exists, if so, delete. if arcpy.Exists(fc): print "trip_lines exists..." print "deleting trip_lines..." arcpy.Delete_management(fc) print "trip_lines deleted..." out_lines = "C:/temp/GIS_projects/Sample_tripData/test.gdb/trip_lines" #XY To Line print "running XY to Line Geoprocesseing tool..." arcpy.XYToLine_management(input_table,out_lines, "TSLONGDD","TSLATDD","TELONGDD", "TELATDD","GEODESIC","TRIPSEQNUM")
... View more
06-06-2013
10:08 AM
|
0
|
15
|
4873
|
POST
|
Okay, so.. I created this model to: select by location of one feature class to another. iterate through the selected features of the second feature class obtain the value from a field calculate the field in the selecting feature class with the value from the selected feature class Problem: Iterator goes through each selected row to obtain the value There are 34000 rows selected A calculation is being done as each row value is found The process it taking forever It would be faster to just do a spatial join in ArcMap Then calculate the field I want the values in Solution: I am looking for some solution that would be using Modelbuilder. Any help would be appreciated.
... View more
12-08-2011
06:59 AM
|
0
|
1
|
2270
|
POST
|
you could try using %Row Count% in the Calculate Field tool. I am guessing you are bringing the table into the model.. not sure if this is helpful to you or not but may help stir some ideas. see attached images
... View more
11-30-2011
11:07 AM
|
0
|
0
|
330
|
POST
|
I want to use a label expression to; check for duplicate attributes. if none found calculate percentage = 100% if > 1 then calculate total divide into single attribute find percentage of total not sure if this is better done through vbscript or jscript.. Has anyone done this? If so, could someone please provide me with some example code? Thanks.
... View more
11-30-2011
10:39 AM
|
0
|
1
|
595
|
POST
|
I just installed FlashDevelop and imported the ArcGIS viewer for flex src code as a project. Everything looks fine.. I can see all the files I think I need to.. Tried to run the project, figured I needed to build the project first..So, I clicked "build project".. Starts building the project.... Then I get the "Build Failed" messages below.. Z:\flexviewer-2.2-src\src\com\esri\viewer\IBaseWidget.as (103):col: 28 Error: Type was not found or was not a compile-time constant: Map. Z:\flexviewer-2.2-src\src\com\esri\viewer\IBaseWidget.as (104):col: 24 Error: Type was not found or was not a compile-time constant: Map. Z:\flexviewer-2.2-src\src\com\esri\viewer\IInfowindowTemplate.as (15):col: 20 Error: Definition com.esri.ags:Map could not be found. Z:\flexviewer-2.2-src\src\com\esri\viewer\managers\ConfigManager.as (465):col: 71 Error: Type was not found or was not a compile-time constant: WebMapEvent. Z:\flexviewer-2.2-src\src\com\esri\viewer\components\InfoPopup.mxml (37):Error: Type was not found or was not a compile-time constant: Map. Z:\flexviewer-2.2-src\src\com\esri\viewer\components\InfoPopup.mxml (42):Error: Type was not found or was not a compile-time constant: Map. Can anyone help me figure out how to fix these? Thanks..
... View more
04-15-2011
08:41 AM
|
0
|
5
|
2311
|
POST
|
Hey Paul, I am just looking into using Flex and wondered if your data was reprojected to Web Mercator in order to overlay onto ARCGIS services? You don't happen to know how to set it so one can use their data in its original projection do you? Thanks, Alex
... View more
04-14-2011
12:08 PM
|
0
|
0
|
184
|
POST
|
Hi Alex, one [sniffty] way to do it is: use the CalculateValue tool with the attached code. Set a Precondition on CalcValue to the output from SelectByLoc. Btw - in SelectByLoc: for the Relationship parameter I used the "Boundary Touches" option to get all adjacant parcels. Let me know if it works for you - it does for me. Barbara Bicking Barbara, Thanks.. this looks like I am heading in the right direction.. only problem I am running into is that arcpy.. isn't that used for ARCGIS 10? I am still using 9.3.. Its probably just a syntax problem I am running into for the zoom to selection script.. Thanks, Alex
... View more
03-22-2011
11:52 AM
|
0
|
0
|
336
|
POST
|
I am trying to create a model where someone has to Enter the Parcel ID they are looking for Select all the adjacent parcels Automatically zoom to the extent of the selected parcels. I think this is doable within Modelbuilder but its just not working.. Can't find the zoom tool to put into modelbuilder Any help is greatly appreciated.. Thanks, Alex
... View more
03-22-2011
06:06 AM
|
0
|
3
|
2321
|
POST
|
I am trying to get the user to type in a parameter to select and address within the field [ADDRESS] using the select geoprocessing tool. guess I missed the documentation where it says do this.. can someone provide me with some insight? Thanks
... View more
03-14-2011
11:00 AM
|
0
|
0
|
182
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|