Tag Info

New answers tagged

0

First, I'm skipping "only even numbers on a side of the street and only odd numbers on the other side" because the code for this might get a bit complicated. And because I'm not sure how to accomplish this task. Anyways, let's break these down. Python is my method of choice. in the same locality I can't have two points with the same number on the same ...


0

My methodology to accomplish this task has always been using ArcGIS's selection tools on feature layers. Something like this: arcpy.MakeFeatureLayer_management (polygon, "lyr") #The check for item in features: arcpy.SelectLayerByLocation_management ("lyr", "CONTAINS", item) #Check for selection, i.e. item is contained within polygon if ...


0

This issue here is that you are iterating through your input feature class with your cursor, and assigning a value to the variable lightBuffDist. This variable is being updated for each row in your cursor. Finally, it reaches the final row, which appears to have the value "SV" in the field "TYPE". This assigns 100 to the variable lightBuffDist. Your ...


0

Your issue is here I believe: graph.addSeriesHistogram(input_table, fieldName, countBin) Specifically, with the variable fieldName. For addSeriesHistogram, fieldNameneeds to be a layer object. Instead, it is a string in your code. To access the layer object, you'll need to use arcpy.ListLayers. Try this code: #Create map object mxd = ...


0

Setting your workspace to in_memory will mean that for any new data file that you create, if a file path is not provided in the code, the data file will be saved in_memory, which is a temporary location. Working with data in_memory is faster than saving it to disk (such as C:\GISStuff), and it means less cleanup is needed on intermediate data files. In your ...


1

Export Data Change Message GP tool could be used which creates a delta file with changes to synchronize (number of records could be obtained from the result).


4

If you have ArcGIS 10.1 or higher then a Data Access Insert cursor is faster than CopyFeatures_management by more than double the speed. I ran your test code and it took over 22 seconds to run. I rewrote it to use a da InsertCursor and it took less than 8.233 seconds to run. The da insert cursor can handle all of the attributes you want as well. After ...


2

You have the path wrong for the line that reads: arcpy.mapping.MapDocument(r"C:\Project\\" + mxd) you have made the path a raw string, so the double backslash is wrong and making it fail, it should either be: arcpy.mapping.MapDocument(r"C:\Project\" + mxd) or: arcpy.mapping.MapDocument("C:\\Project\\" + mxd)


2

This code worked for me. I modified a near point distance tool I wrote last year. To find max distance, just change the dist_type parameter from min to max: import arcpy, os, sys, traceback, math from os import path as p from datetime import datetime as d arcpy.env.overwriteOutput = True def Message(msg): print str(msg) arcpy.AddMessage(msg) def ...


1

The only way i know to remove symbology definitions whilst keeping all the required ones AND keeping the current symbology is manually in ArcMap. In case this is of help here are the instructions: Right click on layer in ArcMap and go to properties Select the symbology tab Right click the unwanted definition ('Extreme' in this case) and delete. This ...


3

If you have access to an ArcInfo license, you could use the Point Distance tool, which: Determines the distances from input point features to all points in the near features.... The tool creates a table with distances between two sets of points. if the default search radius is used, distances from all input points to all near points are calculated. ...


1

You just don't quite have the quotes right in your expression.You need double quotes around your datetime. Also, you shouldn't have !DateTime! = as part of it. Try: arcpy.CalculateField_management(out_path_shp, "DateTime", '"' + date_time + '"', "PYTHON_9.3")


0

You need to walk nested group layers then use arcpy.CreateArcSDEConnectionFile_management to create new sde using parameters from lyr.serviceProperties, and pass parameters as servProp.get or arcpy.GetParameterAsText(0). Don't forget to use os.remove(temp_sde) if os.path.exsists(temp_sde) else None. for maplayer in lyr_list: walknestedgroups(maplayer) ...


0

sounds like your looking for CheckInExtension? looks as simple as arcpy.CheckInExtension("3D") (oops, answered too quickly) at least for extensions - the desktop license condition appears to be read only - more info here


2

is creating a standalone .xml file for the feature class an option? ... for instance a temporary XML, which you delete extracting the information you need? If yes, you might want to look into the arcpy command "XSLTransform_conversion". To get acquainted with it, look into ArcToolbox: Conversion Tools > Metadata toolset. The arcpy command only calls this ...


0

Working with layers can indeed be tricky, with the multiple steps of adding one to your map. Also confusion can arise with the in memory layer created by arcpy.MakeFeatureLayer_management and the mapping layer you add to your map via arcpy.mapping.AddLayer usually having the same name. These two 'layers' are similar objects but are not, in fact, the same, ...


0

thank you all, I have solved this problem and there is an little error here. The range of the interpolation is 27000 meters but the extent of the arcpy environment is in degree unit. So the only thing need to do is to unify the unit.


1

Your arcpy.mapping.UpdateLayer is referencing the same layer (updateLayer) in the same data frame for each iteration of your for loop. Thus it is most likely throwing an error because you are trying to update a layer from one map data frame but indicating it is located in a different data frame. Replace with this: arcpy.mapping.UpdateLayer(df, lyr, ...


3

Use the spatial_reference parameter to reproject on-the-fly. with arcpy.da.SearchCursor("prim_catch_dissolved", ["TR", "SHAPE@XY"], spatial_reference=arcpy.SpatialReference("WGS 1984")) as cursor: # Do interesting things here


2

This worked for me: import arcpy contours = r'C:\TEMP\Contours.shp' con2 = r'C:\TEMP\Contours2.shp' d = {'a': 1, 'b': 2} _list = [1,2,3] string = 'test' lyr1 = arcpy.MakeFeatureLayer_management(contours, 'contours1').getOutput(0) lyr2 = arcpy.MakeFeatureLayer_management(con2, 'contours2').getOutput(0) layers = [globals()[v] for v in dir() if ...


0

Have you tried ListLayers()? I don't see where in-memory is specifically addressed in the Help File, but worth a shot.


1

Okay, posting for posterity's sake now. My team and I did find a way to successfully implement data driven pages with domain values (for the ultimate purpose of a printing service) using a combination of python and spatial views that were created in the database. Basically, every field I wanted on the print layout was included in the spatial view. The ...


0

An alternative would be to deploy your script in a toolbox, which you could access from ArcCatalog. The script, which you expose as a tool in a custom-made toolbox will allow your users to select a datatset and run the script on it. Should you need to run the script on several datatset , you users can use the built-in batch mode (present by default in all ...


0

I would guess there's something wrong with your geometry. Try using RepairGeometry_management prior to your field calculation. If this doesn't do the trick, a workaround is probably needed. I would use FeatureToPoint_management, followed by AddXY_management, followed by SpatialJoin_analysis. Edit: The best method might be via an UpdateCursor. Then you ...


0

Caitlin, here's a tool I created that does what you want, at least as far as your question goes. I haven't added validation, except to set default values, so you may want to do that. In particular, check that filePath exists in case the user manually types in a non-existent path. Note that they can browse to an existing folder, and create a new one. Setting ...


0

I agree with @phloem's comment...this parameter is set when the feature service is published and can be modified (with appropriate permissions) in the Server Manager, in Desktop/Catalog, and the Server Admin directory. You are looking for the Maximum number of records returned by the server parameter. More detail on this page under the "Parameters" ...


0

Here's a revised version of the first part of your script. Notice you don't even need projectGDB, at least to this stage. Untested, and written as a script, not a tool (except for the GetParameter calls). You should probably check if the path exists as well. # Import arcpy module & other helpful import arcpy, os, xlwt # Name Project ext = ".gdb" ...


2

Following on Phloem's comment about using arguments in the printPages() method, and echoing Emil's answer as well: My gut reaction says we need to select the desired active page by setting the currentPageID property in the mxd.dataDrivenPages object, and then run the mxd.dataDrivenPages.printPages() method to send the active page to the printer. I'm ...


2

Here's a snippet of code that might work for you. the variable 'pageName' is the name of the page to be printed. pageName = "page1" mxd = arcpy.mapping.MapDocument (r"M:\CCAO_GIS_Projects\Library_Districts\MXD\Lib_Test_new.mxd") pageIndex = mxd.DataDrivenPages.getPageIDFromName (pageName) mxd.DataDrivenPages.printPages ("HP Color LaserJet 2600n (Copy 1)", ...


1

The reason is probably in ArcMap unable to recognize a NoData value set by the IDW tool as either 3.40282e+038 or -3.40282e+038. I'd recommend using SetNull tool for these two values on the result and see if that gets rid of any senseless values (should set them correctly to NoData). If not, a flaw in the input data might be present (I'm unsure if IDW ...


2

You've forgotten to add cur.updateRow(row) in the end of the loop, to save changes.


0

It sounds like what you want to do is delete your old feature class and then rename the result of your erase to the name of your old feature class. Here's the code: if fiabia > fiabib: out_poly = os.path.join(outFolder, nameb + "_er_" + namea + str(count) + "_" + str(cnt)) arcpy.Erase_analysis("fcb","fca", out_poly) arcpy.Delete_management ...


2

As Michael suggested, first creating a layer file of populated rows should do the trick. Before your code, create a variable with the proper SQL query, and then create your layer file. Execute your time conversion on your layer file. code: sql = '"START_DATE" IS NOT NULL' arcpy.MakeFeatureLayer_management (SA_TEN_GOV_els, "lyr", sql) ...


4

I think your question is pure Python rather than GIS but I put together a simple Python script called test.py below to prove that it can be easily done. import arcpy arcpy.CreateFeatureclass_management("C:/temp","test.shp") I placed test.py in C:\temp and used Windows Explorer to double-click it. A DOS window appeared for about 10-15 seconds, and then ...


1

This code will do the trick I think. It looks for any line with $PHOTO_NUM, and when it finds one it checks three lines below with the use of the linecache module. If $TERRAIN_HEIGHT : is found three lines down, the script performs a cursor to find the replacement value, and calculates the index of the line to do the replacement in. Once this index is ...


3

Don't manually concatenate paths. It leads to errors and makes your code non-portable to other OS's. Use os.path.join instead. For example, replace any instance of projectGDB = path + projectName + ".gdb" with : projectGDB = os.path.join(path, projectName + ".gdb") I believe this will solve your problem, since "F:\GIS\TEST" doesn't end in a path ...


3

The problem may be in how you concatenate the variables to create projectGDB. What you're endiing up with for projectGDB is "F:\GIS\TESTTEST.gdb" Notice there's no slash between the path and the gdb name. I'd suggest using os.path.join(path, projectName + '.gdb') to set projectGDB. Alternately, you could add a slash in front of projectName manually. Also, ...


0

I needed to save my Table View to disk in order for it to be usable by a join. CopyRows_management was the missing link. arcpy.MakeTableView_management(outGdb + "\myTable", viewName, sqlFilterForView ,outGdb) arcpy.CopyRows_management(viewName, saveViewPath) arcpy.AddJoin_management( shapeLayer , joinField, savedViewName , joinField,"KEEP_COMMON") ...


0

Thanks Amarinel, that works. import arcpy import os from arcpy import env # Set local variables inWorkspace = "Q:\\NHD project\\Connection to Oracle.sde" inFeatures = "Q:\\NHD project\\Connection to Oracle.sde\\ARCFM.Landbase\\ARCFM.Towns" outFeatures = "Q:\\NHD project\\Towns\\towns.shp" tempLayer = "townsLayer"


2

Your basic code is very good. As per my comments: arcpy.da.UpdateCursor(inFeatures, ('x','y',"shape@")) should be arcpy.da.UpdateCursor(inFeatures,['x','y','shape@']) The square brackets make it a list which is what the tool is expecting. Schema locks occur when you have the same data open in multiple sources or have left a cursor unclosed - using ...


0

I don't totally understand the output of your analysis, but it seems like that for each feature being evaluated you're doing a lot fiddling - copying datatsets, joining them, adding fields, deleting them. If you don't need to do them every time do them once outside your loop. Some benchmarking might help you figure out where the bottleneck is. You can do ...


2

Years and Months behave differently in several ways that make your expression work for years, but break for months. Any set of year ranges that are positive will work with the original years expression. No set of ranges across multiple years alone can select just dates from a given month. For months you have to set an overall range of all dates regardless ...


3

float("Inf") is not a true float. You can't do normal math with it. Feature class fields can only store actual numeric values, within specific ranges. From the help: Data type | Storable range --------------------------------------------------- Short integer | -32,768 to 32,767 Long integer | -2,147,483,648 to 2,147,483,647 Float | ...


1

I can think of a few ways to accomplish this, if you want to automate the process you would use a similar approach to this example in the ArcGIS help LegendElement example 4: The following script updates all layers in the legend to use a custom legend item style item called MyNewStyle. import arcpy mxd = ...


0

If the legend is dynamic, you may use the Layer (arcpy.mapping) class, using a combination of the isRasterLayer property and VISIBLE parameter to turn on or off raster layers, which should hide or show that item in the legend.


2

Have you looked at the arcpy.mapping LegendElement? Not sure that will do what you want, but is one way of manipulating legend elements.


1

Try this: for month in range (01,12): arcpy.MakeFeatureLayer_management("Sightings1995-2014", "test%s" %month,"DATE >= date'01.%s.1995' AND DATE < date'01.%s.2014'" % (month, month+1) When you did it for year you ended your for statement with a colon (:), but when you did it for month that was omitted.


3

there is no such thing as the "sum" operator for difference (which is not permutable), so you should test the validity of each item to decide how you run the substraction. def stack(item1,item2): if item1 != None and item2 != None: return item1-item2 elif item1 != None: return item1 elif item2 != None: return -item2 ...


1

You have this problem because the field names to be used when you have a join are not the original field names. If you don't need the join anymore, you can use the "remove join" tool. If you do need the values from the joined table, you must include the table name in the field name, like this : !table_name.field_name! If you want to make sure of the ...


1

Similar to what the other posters have said. Use arcpy.da.searchcursor and use the where clause. You can then set the where clause to be "where accuarcy > 80" or whatever you want. check out this resource http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001r000000



Top 50 recent answers are included