Hot answers tagged

3

If you want to get the matching rasters you can zip both lists so you iterate over a list of tuples containing two rasters (one red, one nir) at a time. for rotesband, nirband in zip(liste_rotesband,liste_nirband): print 'red band: {}'.format(rotesband) print 'nir band: {}'.format(nirband) Regarding your edit, you are attempting to use the Float() ...


3

A few things to note: If you are expecting the changes to be visible when you open the MXD file in ArcMap, save the MXD at the end of your script using the newmxd2.save() method. If you want to export the map (e.g. PNG of PDF) and want to see the changes in the exported file, you don't need to save the MXD as you are only using it as a template. If you are ...


3

Assuming you have all your features in the same folder or GDB you can try the following: import arcpy arcpy.env.workspace = r'path\to\your\folder' feature_classes = arcpy.ListFeatureClasses() clip_feature = r'path\to\clip_feature' # this would have to be on a different folder for fc in feature_classes: arcpy.Clip_analysis(fc, clip_feature, 'clip_{}'....


2

The structure of a Standard Toolbox (TBX) is quite different to that of a Python Toolbox (PYT). You should be able to re-use most of your execute functions but parameter handling is very different. I recommend reviewing the help on writing Python Script Tools e.g. Understanding script tool parameters.


2

I've had similar problems when writing to shapefiles where some characters in the filename causes issues (in this case the hyphen). My suggestion is to use the function to validate table names in arcpy: arcpy.Select_analysis(inShapefiles,arcpy.ValidateTableName(os.path.join(outputworkspace,z)),where_clause)


2

You can specify the GDB as your workspace and then use the arcpy.ListFeatureClasses() function to get all the names of the features in that GDB: import arcpy arcpy.env.worskapce = r'C:\path\to\my.gdb' for fc in arcpy.ListFeatureClasses(): arcpy.MakeFeatureLayer_management(fc, "lyr") arcpy.SelectLayerByAttribute_management("lyr", "NEW_SELECTION", '"...


2

Method "within" works fine, because this script import arcpy import itertools as itt lines="LINES" pgons="PGONS" d=arcpy.Describe(pgons) SR=d.spatialReference g=arcpy.Geometry() curT=arcpy.da.InsertCursor(lines,"Shape@") with arcpy.da.SearchCursor(pgons,"Shape@") as cursor: for row in cursor: pgon=row[0] gList=arcpy....


1

In your code Polygon_Neighbors is a table. You'll need a table view to perform your selection. Polygon_Neighbors_tv = arcpy.MakeTableView_management (Polygon_Neighbors, "Polygon_Neighbors_tv") [0] # Process: Select Layer By Attribute arcpy.SelectLayerByAttribute_management(Polygon_Neighbors_tv, "NEW_SELECTION", "src_MapUnit = nbr_MapUnit") Note that you ...


1

The solution turned out to be that I was trying to run the script from a py file inside a toolbox that I created, and not as a saved pyt file.


1

I'd make use of Validate Table Name and GISPro's Alter Domain. You can alter your domain names using Validate Table Name to remove spaces. Untested since I don't have ArcGIS Pro: inGdb = r"Domained\gdb" outGdb = r"output\gdb" #---- print ("importing") import arcpy import os print ("listing domains") domains = [d.name for d in arcpy.da.ListDomains (inGdb)]...


1

It has been a while since I post this question. The script has been updated since then and I post my answer in the following part for other users. list = [] rows = arcpy.SearchCursor(bufferclip) SumArea = bufferclip + "Area" for row in rows: area = row.getValue("Shape_Area") list.append(area) SumArea = sum(list) print SumArea arcpy....


Only top voted, non community-wiki answers of a minimum length are eligible