|
POST
|
Sorry, but that's not true. The arcpy.ListFeatureClasses() will return a list that enables you to access the data without the need to put '.shp' at the end. See below an example of a list returned from a folder with shapefiles: [u'myShapefile1.shp',u'myShapefile2.shp']
... View more
08-08-2014
11:11 AM
|
0
|
3
|
2999
|
|
POST
|
There is still a potential risk in this code. If you loop through the points to create a where clause with your Object ID, you assume that the values of the ObjectID is a range without gaps in its values. This might be the case, but if you edit the featureclass and delete a feature, it will no longer be the case. To create a more stable way you could use something like:
fc_pnts = "C:/Users/Ryan/Documents/arcgis_folder/sitetwoworkarea.gdb/route_one_points"
# determine the ObjectID field name
fld_oid = arcpy.Describe(fc_pnts).OIDFieldName
# make a list of all the ObjectID's in the featureclass
lst_oid = [row[0] for row in arcpy.da.SeachCursor(fc_pnts, ("OID@"))]
# loop through oid's and create the where clause
for oid in lst_oid:
where = "{0} = {1}".format(arcpy.AddFieldDelimiters(fc_pnts, fld_oid), oid)
... View more
08-08-2014
11:03 AM
|
0
|
0
|
1003
|
|
POST
|
This is a good place to start reading on Accessing data using cursors and obviously SearchCursor (arcpy.da)
... View more
08-08-2014
10:39 AM
|
0
|
0
|
2194
|
|
POST
|
Although it seems as a lot of work to rewrite the code, it might pay off in the long run...
... View more
08-08-2014
10:35 AM
|
0
|
0
|
2194
|
|
POST
|
To get you started, have a look at the code below. Use this script by adding it as a script to a new toolbox. Define the 5 parameters as explained on line 18 - 22
#-------------------------------------------------------------------------------
# Name: clip_contour.py
# Purpose: clip raster and create contours
#
# Author: Sandrine Carmet
#
# Created: 08/08/2014
#-------------------------------------------------------------------------------
class LicenseError(Exception):
pass
def main():
import arcpy
import os
# read the parameters
fc_extent = arcpy.GetParameterAsText(0) # define as featurelayer, filter polygon, direction input
ras_in = arcpy.GetParameterAsText(1) # define as rasterlayer, direction input
ras_clip = arcpy.GetParameterAsText(2) # define as raster dataset, direction output
fc_contour = arcpy.GetParameterAsText(3) # define as featureclass, direction output
interval = arcpy.GetParameter(4) # define as Double, set min and max range, provide default
# configuration of contours
contour_interval = interval # not 4...
base_contour = 0
z_factor = 1
try:
if arcpy.CheckExtension("3D") == "Available":
arcpy.CheckOutExtension("3D")
else:
# raise exception
raise LicenseError
# set in memory workspace
arcpy.env.workspace = "IN_MEMORY"
# Determine the extent of the fc
extent = arcpy.Describe(fc_extent).extent
ext_txt = "{0} {1} {2} {3}".format(extent.XMin, extent.YMin, extent.XMax, extent.YMax)
# Clip the raster
arcpy.Clip_management(ras_in, ext_txt, ras_clip, fc_extent, "#", "ClippingGeometry")
# Create the contours
arcpy.Contour_3d(ras_clip, fc_contour, contour_interval, base_contour, z_factor)
# return license
arcpy.CheckInExtension("3D")
# outputs are automatically added to the TOC...
except LicenseError:
print("3D Analyst license is unavailable")
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
if __name__ == '__main__':
main()
Once you run the script successfully, you can go to the Results windows and see the syntax for executing the script.
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "pols", "DEMsmpro"
arcpy.ClipRasterCreateContours("pols","DEMsmpro","D:/Xander/grd/test_clip","D:/Xander/tmp/test2.gdb/test_contours","50")
You could create another script that simply executes this script or change the script to work with a list of inputs. Kind regards, Xander
... View more
08-08-2014
10:29 AM
|
2
|
0
|
4591
|
|
POST
|
I suppose that if you manually apply the definition query CROWN_LANDS_FILE = '2411100' to the layer, it works without any problems, right? If so, then the definition query is not the problem. It might be the layer itself or other aspects of the environment you're working in. Those are hard to solve without access to the data and mxd you're using. I would probably step away from using of classes and rewrite the code using the da cursors and set the extent using the geometry rather than selecting and zooming to the extent of the selection.
... View more
08-08-2014
09:15 AM
|
0
|
7
|
2194
|
|
POST
|
Don't worry about your English, it's fine. The help page with examples for the tool you need can be found here: Tiled Labels To Annotation (Cartography) Kind regards, Xander
... View more
08-08-2014
09:03 AM
|
0
|
0
|
1907
|
|
POST
|
It seems this is also suggested to you at your thread: How to use defined parameters in a tool ? I think it's better to continue this discussion at your own thread
... View more
08-08-2014
07:10 AM
|
0
|
1
|
1907
|
|
POST
|
I agree with Dan, what you describe can be done with a conventional toolbox that holds a simple python script to perform the analysis.
... View more
08-08-2014
06:46 AM
|
0
|
4
|
1907
|
|
POST
|
If you physically want to create a featureclass with tiles of specific size you can use the option: Create Fishnet (Data Management) If the purpose is to show this on the map layout, you can make use of a grid or a graticule
... View more
08-08-2014
06:27 AM
|
0
|
5
|
2157
|
|
POST
|
If you want to create a Shapefile, shouldn't you define the parameter type to be "DEShapefile" instead of "GPFeatureLayer"? Normally when using a tool inside ArcMap, the output result is added by default to ArcMap. Geoprocessing Menu \ Geoprocessing Options, checkbox "Add results of geoprocessing operations to the display".
... View more
08-08-2014
06:22 AM
|
0
|
0
|
1251
|
|
POST
|
Can you explain how and where your parameters list is defined? Does the "OutputSHPFile" exist? If it is a featureclass (type) you could describe it and use the dataSource (which points to the path) instead. I notice that you are using "CURRENT" keyword to define the mxd (which is the current one). This means your script can only run inside a session of ArcMap. Is this right? Maybe you can explain a little more about what you are trying to accomplish and reveal the rest of the code. That way it's easier to understand what might be going wrong. Kind regards, Xander
... View more
08-08-2014
05:47 AM
|
1
|
2
|
1251
|
|
POST
|
You could create an image of the text and flip the image, although it does not make sense to me...
... View more
08-07-2014
08:21 PM
|
1
|
3
|
2629
|
|
POST
|
I suppose it is not possible to flip text, since it would compromise the readability of the text. Why would you want to do that?
... View more
08-07-2014
08:20 PM
|
1
|
4
|
2629
|
|
POST
|
The Spatial Analyst toolbar used to be packed with functionality before 10.0 was launched. It might be that the tutorial or part of the tutorial has not been updated to the current version. The only functionality that remains on the toolbar are those with user interaction on screen. As explained by others in this thread the functionality you are looking for are all found in the ArcGIS Spatial Analyst toolbox.
... View more
08-07-2014
08:09 PM
|
1
|
0
|
2450
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|