Hot answers tagged

5

You can set the spatial reference of the data frame object in Python. mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] df.spatialReference = 31982 # SIRGAS_2000_UTM_Zone_22S However, I think it will be much more efficient to leave the data frame as is and just project the point geometry on the fly. sr = arcpy....


3

Python/ArcPy for ArcGIS Pro 1.3 is now installed in C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\ So your IDE needs to be pointed at that environment to pick up the link to arcpy. In Visual Studio open the Python Environments window, click "+ Custom..." and select "Configure". Give the new environment a name e.g. Python 64-bit 3.5 ArcPy and ...


2

This field calculator expression took 0.65 seconds to populate new field by 1 - first occurrence or 2 - twin in 10000 large table. aDict={} def FirstOrNot(a,b): key=tuple(set([a,b])) if key in aDict: return 2 aDict[key]=0 return 1 --------------------------- FirstOrNot(!FID!, !NEAR_FID! ) This is a very big zoom: Points symbolised by this ...


2

I think the most inefficient part of your code is Select by Attribute part which requires relatively high overhead to add marked item to your current selection. First create a new SHORT field in your table to mark the desired pairs. And then I suggest you to first create a Python set with row[0] and row[1] as converted to string and with a delimiter first, ...


2

If the first run works but the second run fails, the first thing to check would be to make sure you're not trying to create a new dataset where one already exists. Also, you've defined output_location at the top of the script but aren't using it anywhere. Perhaps you need to change the output_features assignment in your loop? output_features = os.path....


2

I didn't find a pre-built tool to do this, but ended up using the following code which was easy enough to then query the dictionary to pass to arcpy.ChangePrivileges_management() import arcpy def retrieve_permissions(db, fc): sdeDBConn = arcpy.ArcSDESQLExecute(db) permissionsQuery = """SELECT permission_name, state, pr.name FROM sys....


2

To dissolve down to Single-Part features your input features need to intersect (touching edges or overlapping), even when dissolving on an attribute. If the features don't intersect at all then the output will be the same as the input. If your features do not intersect you will need to set your dissolve to output Multi-Part features. This will dissolve ...


2

Use the field calculator. If you have a field (like start_x), use the field calculator with the expression !SHAPE!.firstPoint.X, and for a field like end_x you would use !SHAPE!.lastPoint.X. for your Y coordinates, you would use !SHAPE!.firstPoint.Y and !SHAPE!.lastPoint.Y Check out the arcpy geometry documentation(http://desktop.arcgis.com/en/arcmap/10.3/...


1

Looks like you want to use the first value in a field to rename the output feature class. I would use the feature class as an input rather than whatever C_parameters is. You can just make the input a user defined parameter and they can choose which input to use. Also set Field as a parameter to allow the user to choose which field this will work on. Copy ...


1

Because you have 42 tiles of 800,000 point you have more data than a TIN can hold-you will need to build and populate a Terrain. Using the tools available in the 3D Analyst toolbox-construct an ESRI Terrain dataset , populate the Terrain with your point data, then use the contour tool to construct 1 ft contours. Here is a link to working with Terrains in 10....


1

Try adding a few print statements to verify your values while testing. Something like for row in cursor: print "dmready = '{}'".format(row[0]) print "total_records = '{}'".format(row[1]) print "dm_stat = '{}'".format(row[2]) if row[0] == row[1] and row[2] == "Ready for DM": row[3] = "Y" cursor.updateRow(row) else: ...


1

In the result the expression it has returned two single quotes, it should be or with one single quote or with double quote. I suggest to try it: where = "{} in ({})"....... Also do not forget if the source is .gdb Expression should be: **Fieldname = 'value'** if the source is .mdb: Expression is: **[Fieldname] = value** And if it is shapefile: ...


1

As per my comment, why not just use a combobox for the layer list within the AddIn itself? Here is an example of how I have done this before in a Python AddIn: class LayerList(object): """Implementation for ClipAndShip_addin.combobox (ComboBox)""" def __init__(self): self.items = [] self.editable = True self.enabled = True ...


1

The Add Geometry Attributes tool will allow you to perform many of the functions found in the Calculate Geometry tool from within a model or Python script.


1

I do this all the time. In my particular case I maintain a one-off database that needs to be synchronized with the actively maintained data, but it cannot be overwritten by the original database, since I maintain additional fields in my copy that are not in the original. The fastest approach for this scenario requires the use of dictionaries and cursors. ...


1

Locate your shapefile. The error message says it's in: "D:\CLASSES\Debugging_andErrorHandlingLab\Data\TravisCountyAustinTxx.mxd\parks.shp" The .MXD can't be a folder, so it's definitely not there. Perhaps it's in the same folder as the MXD: dataset = r"D:\CLASSES\Debugging_andErrorHandlingLab\Data\parks.shp"


1

LOTS OF ERRORS were fixed --.spatialRefernce (no good) .extent(no good), lyrlist, had too many arguments--FIXED import arcpy mxd = r"D:\CLASSES\Debugging_andErrorHandlingLab\Data\TravisCountyAustinTxx.mxd" mapdoc = arcpy.mapping.MapDocument(mxd) dataset = r"D:\CLASSES\Debugging_andErrorHandlingLab\Data\TravisCountyAustinTxx.mxd" spatialref = arcpy....



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