Tag Info

Hot answers tagged

5

My understanding is that Background Geoprocessing runs as a separate process and, unlike Foreground Geoprocessing, is unaware of your current ArcMap environment. Consequently, I don't think you'll have success with your current approach. AutoSaving maps is not the same as AutoSaving edits but you could look at Incremental "auto save" in ArcMap ...


4

Since the field datatypes are static, you can pre-cast pylist to whatever you need it to be. For example: pylist= [(1.0, u'10',''), (2.0, 1.0, 2.0), (u'9', '', 2.0)] cast = [(float(x), str(y), str(z)) for x,y,z in pylist] #[(1.0, '10', ''), (2.0, '1.0', '2.0'), (9.0, '', '2.0')] fields =["A", "B", "C"] #fields of arcgis table #using with means closure in ...


4

As Vince mentioned in the comments, 'The "with" syntax is a Data Access cursor construct'. You have a couple options: Using the old version of update cursor: cursor = arcpy.UpdateCursor(i) for row in cursor: if row.getValue("Type") == "Intermediate" and row.getValue("Depression") == "Yes": row.setValue("Contour_Type", "Intermediate_Depression") ...


3

When you are running a script in the background, a python process is spawned that is separate from ArcMap. So essentially, arcpy.mapping.MapDocument("CURRENT") is attempting to open a map document that it cannot see. This makes sense as imagine the issues if you had multiple .mxd open: Python would not know which one you mean by "CURRENT". You can see this ...


3

I was curious as to this as well so I asked around a little and did some research. what I found was SHAPE@XY —A tuple of the feature's centroid x,y coordinates. SHAPE@TRUECENTROID —A tuple of the feature's true centroid x,y coordinates. This article describes how they are identical around 95% of the time but will result in a slight difference the ...


2

Riffing on @mkennedy's comment above, here's a small script to parse and create a spatial reference if the datum is NAD83. import arcpy inputString = r'PROJCS["GCS North American 1983 UTM Zone 10S (Calculated)",GEOGCS[ETCETCETC]' editString = inputString.replace(" ", "_").upper() if "NORTH_AMERICAN_1983" in editString and "UTM_ZONE" in editString: ...


2

If your scripts are failing at lines where you're using the arcpy package, you can use try & except statements. In the try statement you should put your arcpy methods, and in the except you can write out arcpy.GetMessages() to a log file. arcpy.getMessages() writes out the messages from the last geoprocessing event attempted. It may help you identify ...


2

At one time I was running particularly large models 500+ elements with lots of iteration that frequently bailed, and like you I found that starting ArcCatalog immediately prior to running them gave them a much better chance of succeeding. I also tried to re-start my PC before starting ArcCatalog and to not do any other lower priority jobs while running ...


2

The problem is that you were adding all fields as "TEXT". The first one should have been a date. Here is an example where you can map the field types with the headers: import arcpy import os import csv import time import locale from arcpy import env start_time = time.time() ##incsv = arcpy.GetParameterAsText(0) ##outfc = arcpy.GetParameterAsText(1) ...


2

Copy Features handles the conversion of file formats (shp into sde-fc like in your example) simply by what workspace has been defined in the output path.


1

You'll want to use a search cursor that iterates through your feature layer and reads values in the PageNumber field. Something like this: with arcpy.da.SearchCursor (IndexPoly, "PageNumber") as cursor: for pageNumber, in cursor: Expression = "PageNumber = {}".format (pageNumber) arcpy.SelectLayerByAttribute_management(IndexPoly, ...


1

The AddMessage will add a message to the geoprocessing job message queue: jobs/ja861064b634648f1be2371e2307c6112?f=json For general logging, I use python logging: import logging and make sure the formatter has a process id: formatter = logging.Formatter('%(asctime)s p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s |-| %(message)s') # Set up logging ...


1

An option would be to export your models to python scripts and run them from the command line, completely avoiding the need for ArcCatalog/ArcMap to be open.


1

To do this you'll need to update the Description within the metadata. Unfortunately, there doesn't seem to be a real simple way to do this with arcpy. However, @Ashatz11 over on Stackoverflow documented a pretty straightforward workflow: Updating metadata for feature classes programatically using arcpy Also, here's a similar post on GIS SE, that's worth ...


1

I searched for "arcpy publish map service" and found Publishing a map service with Python: You can automate map service publishing in a Python script. To do this, you need to call the following sequence of functions from the arcpy.mapping module and tools from the Server toolbox.


1

For the sake of explanation let's call your original geotiff source.tif and the manipulated version target.tif. If you use the tool arcpy.management.ExportRasterWorldFile in conjunction with source.tif it will create a world file called source.tfw that contains the tiff's georeferencing information. Assuming that target.tif has the same pixel size, extent ...


1

You're using gridcode as text in a string, instead of a variable. Try: arcpy.SelectLayerByAttribute_management("LC_test","NEW_SELECTION", '"' gridcode + '" < 17 or "' + gridcode + '" = 21') The exact syntax you're after depends on data sources and field types. See the ArcGIS SQL reference for query expressions used in ArcGIS help.


1

In ArcGIS... Let's say you have polygons and lines such as in the example below: Perform a feature to line, with the polygons and the lines as your input. This slices the polygons by the lines. Select all the features on one side of the line. Export selected features. Turn off all layers except the new layer. Select the 'slivers'. Perform ...


1

You could try using XTools Pro, which has an autosave MXD function built in


1

There are few very basic steps to follow: Get value from shape field Get it's part Iterate through elements (points) in this part, where you can access all of the point's properties, i.e. X, Y, Z and M. See if field calculator solution helps Also note that behaviour of Python in calculator and script is slightly different


1

Esri support got in touch with me and said to simply save a copy rather than save the .MXD itself. Further: "...when Bing layers are added to a MXD a global property is created and referenced. Even when those layers are removed the MXD maintains the reference. When saving the MXD as a copy (when Bing layers are not present) the reference is not copied. Which ...



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