Tag Info

Hot answers tagged

4

I would approach this issue in this way. One can create a feature layer consisting of just one point feature and check whether it intersects the polygon feature layer (using arcpy.da.SearchCursor). However, this would be a bit inefficient since you are dealing with so many features. However, we could create a feature layer and check whether it intersects ...


3

If 10.1+, you can use arcpy.da.Walk and not touch the global arcpy environments: from os.path import join import arcpy def find_all_fcs(workspace): """ return list of all fcs """ fcs = [] for dirpath, dirnames, filenames in arcpy.da.Walk( workspace, topdown=True, followlinks=False, ...


3

you cannot use equal with more than one value use either in or OR to do this "\"STATION_ID\" IN ('CAP', 'DDM')" "\"STATION_ID\" = 'CAP' OR \"STATION_ID\" = 'DDM'" note that I recommand using """ to clarify your strings """ "STATION_ID" IN ('CAP', 'DDM') """


3

I have only tested this very briefly (and with a limited variety of data), but this script demonstrates one way this might be accomplished: import arcpy import csv import os import codecs import cStringIO def batch_convert_dbf_to_csv(input_dir, output_dir, rename_func=None): """Converts shapefiles and standalone DBF tables within the input directory ...


3

If you look for a full arcpy solution (without dbf) you can use import glob glob.glob('S:\\output_tables\\*.dbf') for listing you tables, then arcpy.ListFields() for the field names and outname = os.path.basename(inputtable)[3:-4] + ".csv" to create your output names and finally arcpy.da.SearchCursor() to get a Python iterable that you can ...


3

When you bring in a csv, Arc does its best to determine the appropriate field types and as you have found it doesn't always get it right. One solution is to use a schema.ini file (see bottom of page) to explicitly set the field types for your columns. There are several related (duplicate?) questions here on the GIS SE if you search for 'schema.ini'. More ...


3

Below is a ToolValidator class (in its entirety so it will make sense) where I needed not only for input datasets to have a spatial reference defined, BUT the datum could only be either WGS84 or NAD83. If validation failed, they got little messages informing them of the issues. class ToolValidator: """Class for validating a tool's parameter values and ...


3

I think you're getting the error because the fieldnames list still contains the field LABEL, but you said you're not adding it to the output_fc. for field in fields: fieldnames.append(field.name) Right here you're getting all the field names. If you do a print statement above this line: cursor = arcpy.da.InsertCursor(output_fc, fieldnames) I ...


2

You need to use tool validation for this. For custom Python script tool (that has two input parameters - string with filter value list and string with filter value list for feature layers in the currently open map document). import arcpy class ToolValidator(object): """Class for validating a tool's parameter values and controlling the behavior of the ...


2

Just been looking at this thread and followed the link to the other thread which showed Numpy being used. I've personally never used this approach before so I started reading the help file about it and I think this can all be done in 5 lines! The dataset I tested this on was a polyline layer representing the rivers of the Amazon. So my code is as: InFc = ...


2

If it were me I would pass into your function the Featureclass and create and destroy the search cursor within the function. I would not pass a cursor as a parameter into it. If you use the new da module you can use the with statement to ensure that it is released releasing memory rather than have some object floating around in memory locking the data ...


1

The documentation only makes mention of being able to use shape.area on Python expressions. You will need to use a Python expression to do this. I would very strongly recommend reinstalling ArcGIS. Python not working is indicative of a corrupt installation of ArcGIS, and working around it will not alleviate the problem in other areas.


1

Code looks OK to me so I guess its down to formatting of the string especially with "\" or "/" or "\\" . This line: lyr1 = arcpy.mapping.Layer("C:\ArcGis\Aerial_Imagery.lyr") should really be: lyr1 = arcpy.mapping.Layer(r"C:\ArcGis\Aerial_Imagery.lyr") or it could be: lyr1 = arcpy.mapping.Layer("C:\\ArcGis\\Aerial_Imagery.lyr") So the full path ...


1

At the Esri Discussion Forums I found a 2011 response from @JasonScheirer which says: Arcpy is built on arcgisscripting, which is in turn a CPython extension. You will not be able to use arcpy in IronPython.


1

I actually had this exact same issue. I had a script that would search through sub folders in a root directory, check if they had shapefiles, convert the shapefiles to feature layers then to kmls. It would run through about 20-40 conversions and then just stop, no error codes, just the script would end. It would end at different places each time. My ...



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