Tag Info

Hot answers tagged

5

Try unchecking the 'Add results of geoprocessing operations to the display' in the Geoprocessing Options in ArcMap. You can also access this option via the addOutputsToMap property of the env class: just add arcpy.env.addOutputsToMap = 0 in the beginning of your script.


5

You could try something like this: for the scenario shown above, the script below import arcpy roads1 = #path to roads layer 1 roads2 = #path to roads layer 2 r1 = [row for row in arcpy.da.SearchCursor(roads1,["SHAPE@","NAME"])] #add field to hold required string arcpy.AddField_management(roads2,"COMMENTS","TEXT") with ...


3

I can't explain why Clip is failing when you pass in the geometry. It happens for me as well. I can offer this workaround, though. Persist that geometry out to in_memory (or to disk), then clip with it. with arcpy.da.SearchCursor(splitFC, [splitField,"SHAPE@"]) as cursor: for row in cursor: name = row[0] geom = row[1] ...


3

Calculating a couple of new fields and using the Summary Statistics tool should be one method able to get you what you want. Add a new field to hold the area * thickness for each aquifer and field calculate that value for all the aquifers. Add a second new field to hold the water body id portion of your internal code and populate it as suggested in the ...


3

Try using the Calculate Adjacent Fields, it will do this for 8 directions (NW, NE, SW, SE in addition to N, S, E and W). 8 fields are added with the neighbouring polyon in each direction. But there will be only one adjacent polygon for each direction, there is no grouping of the neighbours. If you want one single field concatenating the neighbouring ...


2

I think you can use the addOutputsToMap (=False) property from the env class in arcpy. Further details here: http://resources.arcgis.com/en/help/main/10.2/index.html#//018z0000004s000000


2

I'm getting the same error in my Arc 10.2 installation. I've encountered issues in the past when using geometry objects with geoprocessing tools, as you're doing with the geom object from your cursor and the Clip tool. It's just ironic since this is almost exactly the example in the Esri help page. One solution is to avoid using geometry objects by exporting ...


2

First you will need an iterator to go through your shape files, there are two methods I employ: Method One: a folder full of shape files: import arcpy, sys InF = sys.argv[1] arcpy.env.workspace=InF for fc in arcpy.ListFeatureClasses(): Method Two: a whole tree full of shape files: import sys, os, arcpy InFolder = sys.argv[1] for (path, dirs, files) ...


2

So you want to convert all values to the same constant value and NoData should remain NoData. Instead of Reclassify, use the Con tool with your input raster as 'Input conditional raster', and the constant value as 'Input true raster or constant value'. E.g.: import arcpy cst = 5 # your constant value outCon = Con(r"C:\data\intput.tif", ...


2

There's a few minor hiccups in your code, I've re-written it (hopefully) better: import arcpy arcpy.env.workspace = "c:\DEM Files" # not requred mxd = arcpy.mapping.MapDocument("Current") # This MXD df = arcpy.mapping.ListDataFrames(mxd,"Georgia")[0] # the first data frame called Georgia rasters = arcpy.mapping.ListLayers(mxd,"*",df) # all the layers # ...


1

On the first pass through the loop, the extent environment variable is set to the extent of the projected version of the first shapefile. On the second pass through the loop, the extent environment variable is still associated with the first shapefile. When Project is called, only the features within that extent are processed (presumably no features in the ...


1

Without seeing the model or the exported Python script it is hard to say this definitively but ... If you have the line below in your Python script: arcpy.env.overwriteOutput = True then it should take care of ensuring that what you try to write can be written. Alternatively, you could use two lines like the following to ensure that the outputFC does ...


1

Try this: CadastreOut = "C:\\" arcpy.MakeFeatureLayer_management(Cadastre, "cadastre_lyr") arcpy.MakeFeatureLayer_management(Buffer_5km, "buflayer") field = "SiteName" cursor = arcpy.SearchCursor("buflayer") for row in cursor: geometry = row.getValue("Shape") out = str(row.getValue(field)) ...


1

The where clause is currently evaluating stepos literally as the value stepos, not the variable value 22. Move the stepos variable outside the where clause string, casting the numeric value to a string, like: arcpy.UpdateCursor(stefile, ' "POSITION" = ' + str(stepos))


1

Once you get the year you should be able to just assign it to parameters[0].value. Also there is an example that may be useful to you here. Look at the first example from the top of the page where it writes param1.value = 'sinuosity'.


1

The line mxd = arcpy.mapping.MapDocument(r"C:\Amruta\clustereddata.mxd") won't alter the map document in the application, but the document of disk. Use mxd = arcpy.mapping.MapDocument(r"CURRENT") and then your script should work.


1

If you want your tool to interact with the map, you need to write a python add-in. To retrieve the X and Y coords of the point you click, use the x and y values of the onMouseUpMap() or onMouseDownMap() function of the Tool add-in class. You have a nice example of code that corresponds to this in this article: HowTo: Capture map coordinates with a mouse ...


1

You can set the scale on the fly using ArcPy's mapping module: from arcpy import mapping mxd = mapping.MapDocument(r"Some Path") df = mxd.activeDataFrame # you can also get access to all data frames through listdataframes() scales = [1500,3000,...,50000] for scale in scales: df.scale = scale # do stuff with map Hope this helps. Andrew


1

If you are using Data Driven Pages from ArcMap there is an option to round the best fit scale to nearest value of your choice (see below) To use this in ArcPy I would have a look at this question and answer: How to automatically generate useful scales for data driven pages in ArcGIS desktop


1

I've just tested the code below and it works fine. You need to be careful in your code that you don't try and apply symbology to the template raster itself otherwise you'll receive an error so I've added an if statement. import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] rasters = arcpy.mapping.ListLayers(mxd, ...


1

I don't have access to ArcPy at the moment, but if you are happy working in that environment, then I reckon you'll be able to code it up pretty easy. Now, my assumption is that you can use road line endpoints, and you don't need to do any network traversal in order to build a reasonable model. Doing a network traversal would be a little harder. Here's some ...



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