Tag Info

Hot answers tagged

4

You can use Find Identical, using the geometry of the features. Alternately, you can spatially join a feature class to itself, and use the "ARE_IDENTICAL_TO" as your match option. This can be useful if you have a bunch of features stacked on top of each other and you want to deduplicate (features with a Join_Count > 1). I recently used this to clean up some ...


3

Use the geometry object's equals method. With polygons and polylines, if their symmetric difference is empty they are considered equal. So for example, in the below, g2 is the same as g1, it just has an extra vertex in the middle, and g3 is opposite to g1, so always equal. >>> g1 = arcpy.Polyline(arcpy.Array([arcpy.Point(1, 1), arcpy.Point(3, ...


3

You are collecting the extents for each polygon correctly, but need to zoom to them within the loop, or a later loop depending on what you want to do. For example to zoom in the same loop as the search cursor e.g. with arcpy.da.SearchCursor(SelLayer,"SHAPE@") as SCur: for feat in SCur: # I'm going to assume polygon/polyline ...


3

Or you could use a describe and .baseName fcs = arcpy.ListFeatureClasses("","","") for fc in fcs: desc = arcpy.Describe(fc) print fc print desc.baseName ActualName = desc.baseName


2

Since you know exactly what you want your new symbolization to be, I would suggest saving a layer file with that symbolization. In arcmap, add a test layer to your table of contents, and symbolize it as desired (1-100 orange, 101-200 red, 201-300 blue). Then right-click on the layer in the table of contents and 'Save As Layer File...' This lets you save the ...


2

The NULL values are in the table, not in the fields, the check for NULL occurs in the loop or when you create the cursor using a whereclause: for FCLASS in FCs: #Skip all Text. OID and Geometry Fields - unfortunately WID, Shape Area etv is still included AllFields = [f.name for f in arcpy.ListFields(FCLASS)] LeaveOutField = [f.name for f in ...


2

I suspect you have your extensions turned off and the database is U:\NRM_Base_Data.mdb.. on that basis: # Import arcpy module import arcpy # Set workspace arcpy.env.workspace = "C:\\Users\\mwisniewski\\My Documents\\DPIPWE" arcpy.env.overwriteOutput = True clipRegion = "?????" # what is your clipRegion? # Count the number of shapefiles clipped count1 = 0 # ...


2

I have no idea why you would receive that error but to move forward I would try running the test code below (with values from your own feature class) from IDLE (or your own IDE). It worked for me using ArcGIS 10.3.1 for Desktop. import arcpy oldFieldName = arcpy.Describe("C:/temp/test.gdb/testFC").fields[4].name oldFieldAlias = ...


2

Use Summary Statistics with the first field being the case field and use the maximum of field 2. arcpy.analysis.Statistics(in_tab, out_tab, [['Field2', 'MAX']], 'Field1')


2

This is really a Python rather than ArcPy question, so would be best researched at Stack Overflow. However, you can try changing: arcpy.CalculateField_management(fc, "Policy_Ref", "'" + fc + "'") to: arcpy.CalculateField_management(fc, "Policy_Ref", "'" + fc.replace(".shp","") + "'")


2

Probably the best way to do this is with a dictionary, this is an object that stores values like Key,Value (not an easy python concept so bear with me).. There are some tutorials that describe dictionaries and what they can do here and here. First thing we need to do is go through the 'to' database finding all the feature classes and storing their full ...


2

You can use an Update Cursor to delete rows based on your conditions. In this example, any rows where OBJECTID > 5 is deleted. import arcpy fc = r'C:\temp\test.gdb\tmp' with arcpy.da.UpdateCursor(fc, "OBJECTID") as cursor: for row in cursor: if row[0] > 5: cursor.deleteRow() Alternatively, use Select Layer By Attribute (Data ...


2

You're script above probably still has a lock onto the data. Specifically this line: rows = arcpy.SearchCursor(path, fields="alpha; beta") You've got two ways to get around the lock. Delete the rows variable after your loop rows = arcpy.SearchCursor(path, fields="alpha; beta") for row in rows: print("{0} => {1}").format(row.getValue("alpha"), ...


2

See comments below: import arcpy #Get data frame object mxd = arcpy.mapping.MapDocument(r'C:/test.mxd') df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0] #Get spatial reference object from data frame SR = df.spatialReference #List all layers in data frame layers = arcpy.mapping.ListLayers (mxd, "", df) #Iterator for naming files i = 0 #Iterate all ...


1

You can incorporate your code as above to include the following: Use arcpy.da.searchcursor() make a python list of those selected features Iterate through your python list using a unique ID to create and use an SQL expression letting you Select By Attribute, then zoom to selected features. Playing around I think something along these lines will work...it ...


1

There are remnant variables that have no value, as I remember the task you're trying to replace only the gdb feature classes that have new shapefiles: # Import arcpy module import os, sys, arcpy InGDB = "C:\\Users\\mwisniewski\\My Documents\\NRM_Base_Data.gdb" # this isn't the path in your question InShpFolder = "C:\\Users\\mwisniewski\\My ...


1

Since the given Spatial References in ArcGIS have got their own parameters for the vertical part, as far as I know there is no way of introducing vertical part by using the given factory codes or like sr = arcpy.SpatialReference(horizontal_wkid,vertical_wkid) that one may think it should work, but it is not. However, you can create your own spatial ...


1

As a cavaet, be very careful about doing any geometry comparisons particularly geometry objects. One should be aware that the geometric operations are 2D whether you have 3D objects. You will have to compare the individual values to check for equality, preferably in Python. On a second, but related point, be careful what the geometry means. Consider the ...


1

I think the comments on this question are worth placing into an answer which I'll make Community Wiki: Try applying the spatial reference to the shape -- poly = arcpy.Polygon(ar,wgs) – Vince Jun 25 at 12:08 Yes, I would do as Vince says and add a spatial reference, otherwise the polygon has no idea where it is supposed to be. Also, you can ...


1

An option that has worked for me is using the data source options you have from python. This has allowed me to write a script to transfer pie chart symbology, which isn't possible for some reason with standard tools. It also lets me repair broken links where symbology gets dropped when the data source is relinked from layer properties. You can also relink ...


1

Since arcpy doesn't let you customize your layers, and only load symbology from already-created layers, you'll need a library of layers for all your potential combinations of values. Then you're going to have to figure out a way to reference the correct layer file for your layer that suits your data. Something like this perhaps. I find the min and max ...


1

In you're code you're using a field name as the dataset parameter in your search cursor. Search cursors are a means of accessing data from a table. Try instead: rows = arcpy.SearchCursor(FCLASS) for row in rows: #Get field value value = row.getValue (attr) #Check if value is null if value == None: #skip row continue ...


1

here's some untested code that should give you close to what you're after. two main things... -make big empty numpy array and fill it one raster at a time EDIT...no surprise...big array didn't fit. -also store a year numpy array for easy masking of years. some suggestions in comments as I went. import arcpy import numpy as np import datetime # Define time ...


1

I am using something like this with great success. import arcpy, os, csv inTables = r"pathToWorkspace" for dirpath, dirnames, filenames in arcpy.da.Walk(inTables, datatype="Table", type="ALL"): for tableName in filenames: print "Appending tables from " + tableName + " to " + newTable ...



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