Tag Info

Hot answers tagged

11

Part count will not yield the correct answer. You could have a multi-part polygon with no holes. See image below for scenario. This would have been a simple query pre-ArcGIS 10 as you could have called ArcObjects to ask if the polygon had a hole but ESRI have removed much of this support in the VBScripting environment to the point its pretty useless now, ...


5

There are better ways to adjust label placement in the placement properties. However, you can pad text using the python parser and .ljust(). "Twp1".ljust(10)


4

def Reclass(A): Low = 0.208113 Moderate = 0.261517 High = 0.36756 if Low <= A <= Moderate: val = "Low" elif Moderate < A <= High: val = "Moderate" elif A > High: val = "High" return val   Reclass(!grid_code!) This will do what your code seems to be trying to do. My concern is that I think you need to think more ...


4

Your code is fine but you are missing a right parenthesis for each line of code in the nested if part: if(biltype.startswith('Commercial, Education')): return 'Education' elif(biltype.startswith('Commercial, Emergency and Rescue Service')): return 'Emergency Services' elif(biltype.startswith('Commercial, Retail')): ...


3

You can take care of this before ever trying to load the data into ArcGIS by creating a schema.ini file. Simply use a text editor to save a file called schema.ini (no other extension) in the same folder as your CSV. Then, explicitly specify the data types for columns that you don't want ArcGIS to infer. For example, if your CSV were called mydata.csv and ...


3

You need to pass the returned value in a variable, not reference the column itself. Expression: result Codeblock: if [ColumnB] > 0 then result = [ColumnA] / [ColumnB] else result = 0 end if Here's how the two parts fit together in the field calculator - my data doesn't have the same field names, but you get the idea.


3

The problem was that both the current working copy and the shadow copy tables were named the same. The join went fine but the field calculator and geometry were greyed out. To fix this, I simply renamed the backup table name to something different. I was able to field calculate and essentially restore the data. I did not find this resolution documented ...


3

You are defining the function on the first statement, which needs to end in a ":", e.g. def makestr(test): Here is a simple solution: def makestr(test): try: return ''.join(i for i in test if i.isdigit()) except ValueError: pass


2

What about "size" * 16 in the field calculator expression?


2

Try this (edited per @alpha-beta-soup comment): def myFunction (inter, prop, patch, shp, nat, edge): myList = [inter, prop, patch, shp, nat, edge] myList.sort() myDict = {'Interconnectivity' : inter, 'PropCover' : prop, 'PatchSize' : patch, 'ShapeIndex': shp, 'Naturalness' : nat, ...


2

From an article below, I answered the question. The final code was: http://stackoverflow.com/questions/8990864/calculating-subtypes-and-coded-values-in-arcgis-attribute-table Pre-Logic Script Code: Dim ValueToConvert Dim ConvertedValue ValueToConvert = [ZONING] Select Case ValueToConvert Case "RS" ConvertedValue = "Single Family Residential" Case ...


2

You're mixing returning values from a function and assignment. You have to return the modified value, not assign it to the old variable. The correct format for the pre-logic script code would be: def mycalc(ADM2_NAME, Projects): if ADM2_NAME == "Bo": return (Projects + 1) else return Projects Although there is an even better (shorter) way of ...


1

Perhaps the calculator is your answer. From "Raster-Raster Calculator" you can create new layers from others. For the the intersection you can use the "AND".


1

I can see that multiple comments aren't being understood. This is what I meant: import os,arcpy from arcpy import env mxd = arcpy.mapping.MapDocument("CURRENT") #arcpy.env.overwriteOutput = True fieldName = "RasterID" RowsField = "unknown" # the field (numeric) for the number of rows ColsField = "unknown" # the field (numeric) for the number of columns ...


1

As @Michael Miles-Stimson has commented your calculate field method will overwrite all row values each loop through the raster list method. So, the table will only have one raster name for each record. In addition, it is unclear from your question if the update table has an equal number of rows for rasters that exist within the directory. If you are ...


1

It is hard to be sure without seeing your error message but I suspect this will work: def Reclass(A): if ( A>= 0.208113 and A <= 0.261517): return "Low" elif (A > 0.261517 and A < 0.301951): return "Moderate" elif (A > 0.301951 and A < 0.335518): return "Moderate" elif (A > 0.335518 and A < 0.36756): return ...


1

You can use this code in field calculator to increment by 1. Parser: Python Expression: autoIncrement() Code Block: rec=0 def autoIncrement(): global rec pStart = 1 #adjust start value, if req'd pInterval = 1 #adjust interval value, if req'd if (rec == 0): rec = pStart else: rec = rec + pInterval return rec


1

Using the python parser, look at ljust() (added as answer, not comment, to include link).


1

Are you referring to the difference between the two expressions? If yes, it looks like the bottom one is using Python as the parser where as the one on top is using VB. To change this in the Field Calculator window in ArcGIS, just select VB instead of Python and the top expression should work.


1

Try this: def makestr(test): # Add colon numlist = [] # Don't use name "list" for s in test: if s.isdigit(): numlist.append(s) return ''.join(numlist) # Return a value


1

I found also another error. You have to join the a values at the last loop: def makestr(test): l1=[] for val in test: if val.isdigit(): l1.append(val) return " ".join(l1) or def makestr(test): l1 =[val for val in test if val.isdigit()] return " ".join(l1) You can join list items without iterating over them. Just ...


1

Sorry for that stupid question! I did find an very easy way to do what I aked in this thread. Just use the QGis processing tool and the SAGA "merge vector layers" tool. The merged shape file has a column (called "Layer") filled with the shape file names.


1

I found a solution using arcpy.da.TableToNumPyArray in the Field calculator using Python. It first creates an Array (list) of all the 'X' values. Afterwards the max value is calculated and given a seperate variable. Last step is to divide this maxium value from each 'Y' value ('Scores', in my example below). def my_rank(score_value): my_list = ...



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