POST
|
Hello All, I have a seemingly minor problem which likely requires some Python coding. I am not currently familiar with python (more of a Matlab person), and was wondering if anyone had any advice. I am attempting to use the Feature Class Z to ASCII tool to make text files with my Z elevations. This tool performs correctly in all respects except 1: It names the text files based on the OID (or FID) column instead of a unique column (named 'Id') that is in my attribute table. Up until this point we have had a separate, hand made file that converts from FID to Id in subsequent analysis, but it is incredibly prone to error and confusing to use. Is there any simple way to modify this tool so that it outputs names based on a chosen column instead of the default OID column? I have attached a zip file of a z-interpolated shapefile below. The 'Id' column is the desired naming column. The Code is below: '''****************************************************************************
Name: FeatureClassZToASCII Example
Description: This script demonstrates how to use the
FeatureClassZToASCII tool to create generate files for all
z-aware point features in a given workspace.
****************************************************************************'''
import arcpy
import exceptions, sys, traceback
from arcpy import env
try:
# Obtain a license for the ArcGIS 3D Analyst extension
arcpy.CheckOutExtension('3D')
# Set environment settings
env.workspace = 'C:/data'
# List all points in the target workspace
fcList = arcpy.ListFeatureClasses("*", "POINT")
if fcList:
# Set Local Variables
outFolder = "C:/output"
outFormat = "GENERATE"
delimeter = "SPACE"
decimal = "FIXED"
digits = 3
dec_sep = "DECIMAL_POINT"
for fc in fcList:
# Use Describe method to evaluate whether the feature class is z-aware
desc = arcpy.Describe(fc)
if desc.hasZ == True:
# Define the output file name by replacing '.shp' with _ascii.txt
outName = fc.replace('.shp', '') + "_ascii.txt"
#Execute FeatureClassZToASCII_3d
arcpy.FeatureClassZToASCII_3d(fc, outFolder, outName, outFormat, delimeter, decimal, digits, dec_sep)
else:
print "There are no feature classes in the " + env.workspace + " directory."
except arcpy.ExecuteError:
print arcpy.GetMessages()
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate error information into message string
pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
.format(tbinfo, str(sys.exc_info()[1]))
msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
# Return python error messages for script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs) I assume that the root of the problem is the 'fclist' variable. Any help in solving this problem is appreciated. Ps. Bonus points if anyone can give some guidance on how to include this as a tool in arcgis so I don't have to run it in an IDE
... View more
03-12-2019
10:17 AM
|
0
|
1
|
562
|
POST
|
I'm not entirely certain what you mean by checking a coordinate system is 'defined' as well as 'projected'. I will try and look into this more! Coordinate systems and projects are something I always struggle with when working with GIS data, so its no surprise that they're giving me trouble now.
... View more
01-08-2019
07:23 AM
|
0
|
3
|
1003
|
POST
|
Hello All, I am trying to project raster elevations onto transects of points from 2-3 different DEMs which I will provide the details to below. The issue I'm having is I keep getting the following error: Messages Executing: ExtractMultiValuesToPoints OI_Points_1m_sandy_RP "20121011__clip.tif F201210111;fmp_SPM_clip_RP.tif fmp_SPM_cl" BILINEAR Start Time: Mon Jan 07 16:37:18 2019 ERROR 999999: Error executing function. ("esri.Envelope") All geometries involved in this operation must have the same spatial reference. ERROR 000546: Input spatial references do not match. Failed to execute (ExtractMultiValuesToPoints). Failed at Mon Jan 07 16:37:18 2019 (Elapsed Time: 0.05 seconds) I have tried removing DEMs until the tool will run and its effective only on the 20121011__clip.tif DEM. Things I have tried: I have attempted to reproject my point shapefile, and all 3 DEMS into the same XY coordinate systems, but I am still running into the same issue. This may be perhaps due to my shotty ArcGIS work causing me troubles I can't identify, but I've checked out all the obvious things I might be able to fix. I would love to get this tool to run with all 3 DEMs, but only the 20121011... DEM and the fmp... DEM. 20121011__clip.tif DEM: NAD_1983_StatePlane_North_Carolina_FIPS_3200 Meter (1.000000) D_North_American_1983 fmp_SPM_clip_RP.tif DEM: NAD_1983_StatePlane_North_Carolina_FIPS_3200 Meter (1.000000) D_North_American_1983 OI_Points_1m_sandy_RP Shapefile: Projected Coordinate System: NAD_1983_StatePlane_North_Carolina_FIPS_3200 Projection: Lambert_Conformal_Conic False_Easting: 609601.22000000 False_Northing: 0.00000000 Central_Meridian: -79.00000000 Standard_Parallel_1: 34.33333333 Standard_Parallel_2: 36.16666667 Latitude_Of_Origin: 33.75000000 Linear Unit: Meter Geographic Coordinate System: GCS_North_American_1983 Datum: D_North_American_1983 Prime Meridian: Greenwich Angular Unit: Degree Let me know if additional information is required!
... View more
01-07-2019
02:19 PM
|
0
|
5
|
1550
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|