Tag Info

New answers tagged

6

In the field calculator select "update the column" where you have numbers and use this string "COLUMN_NAME" || ' M' If you just want to label them with the 'M' paste the same code in the "expression based label panel".


3

if not availble you can always create your own convertion function: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ and should be good to share it in some place or to propose to insert in the expression library


4

The issue is in the interpretation: %Name% Expands out to the name of the feature class so the field calculation is looking for a field that matches the name of the feature class, is unable to find one, then returns an error as no field called MCD43B3.A2002001.h21v09.005.2007114212806.hdf.tif exists in the feature class. To use the name of the feature ...


5

Try adjusting your code, your /n should be \n: arcpy.CalculateField_management("path/to/my/layer","field","RemoveBad( !field!)","PYTHON_9.3","def RemoveBad(x):\n x = x.replace(\"<=\", \" Less Than or Equal To \" )\n x = x.replace(\">=\", \" Greater Than or Equal To \")\n x = x.replace(\"<\", \" Less Than \")\n x = x.replace(\">\", \" ...


3

first you need a double == for your test, simple = is for assignment, not testing second you forgot the indentation and a semi-colon def MyCalc(Kultur,DG): if (Kultur == DG): return 1 else: return 2 third, DG must be identified as a string MyCalc(!Kultur!,'DG') it would go the same way with numeric values (you don't need quotes ...


4

Assuming you are using ArcGIS, and not QGIS, this is a simple operation. It definitely can be performed in the Field Calculator. I created a field, "test_num", type of Double as an example. This is in ArcGIS 10.2 on Windows 7, 64bit. Source Table - Data set to 0 Field Calculator: Simply enter NULL as the value to be calculated. Result Table - ...


5

You can do this directly in the field calculator.


3

Create a new integer field. Then calculate your existing field with the newly created one.


2

This is a pretty late answer but you can do this in the Model Builder, a simple example is shown below: With your vector point layer already added, you can access the Field Calculator: In the Formula textbox, you can add your little equation to calculate the percentage. Depending on the column names of the attributes, you can use something like this: ...


2

The date field stores the full date. It is your system (combined with the type of database) that defines how a date will be displayed. if you want to store a string with the time using your own format, you can use a text field, then something like str(datetime.datetime.now( )).split()[1] will work, or, better, directly use the date formatting from ...


2

This expression1 = '"' + str(FACIL_ID) + "-" + str(SPACENAME) + "-001" + '"' is trying to build a string out of two variables, FACIL_ID and SPACENAME. However, neither one has been defined (hence, the "not defined" error). If they are supposed to be variables, they need to be defined before building a string, such as: FACIL_ID = '88888F10' SPACENAME = ...


0

You cannot use the field calculator to find the maximum value within all of the rows in a field. However, the field calculator can perform operations horizontally, among rows using functions like max([!field1!, !field2!, !field3!]). The only way to accomplish this is by using cursors outside of the field calculator. Try the following workflow: Use a ...


1

This answer is not meant to steal from @ian, but it shows a little bit easier way to write the code that he provided... instead of using a code block (which can be a pain in the butt sometimes when trying to write it in a standalone script...) you can rewrite his code in a single line as: "Verified" if None not in (!B!, !C!, !D!, !E!) and "" not in (!B!, ...


8

Run the field calc on the Summary field. Use Python as the parser and check the Show Codeblock box. For the Pre-Logic Script Code put: def Reclass(B, C, D, E): if None not in (B, C, D, E) and "" not in (B, C, D, E): return "Verified" else: return "In Progess" Then put this in the bottom box: Reclass(!B!, !C!, !D!, !E!) The ...


7

Cursors are the way to go for this type of problem. First, create a list of values using a Search Cursor and a generator expression: b = sum(row[0] for row in arcpy.da.SearchCursor(fc, 'QUANTITY_SOLID')) Then run an Update Cursor to populate the QUANTITY_SOLID_SUM field: with arcpy.da.UpdateCursor(fc, ['QUANTITY_SOLID_SUM']) as cursor: for row ...


0

Here's the solution that worked for me (using the Python Console in ArcGIS, not the Field Calculator): rows = arcpy.UpdateCursor("Assets\Welds") for row in rows: hexString = str(row.REMARKS).encode("hex") if "0a" in hexString: hexString = hexString.replace("0a","") row.REMARKS = hexString.decode("hex") ...


2

Here's the approach I would suggest: Use the Union tool with your buffer feature class as the only input. This will effectively split each polygon at the boundaries of any others. Run the Find Identical tool on the output from the Union tool, using only SHAPE as the categorization field. Join the output table from Find Identical back to the Union output's ...


2

As stated in the function help, the correct syntax is replace('QGIS SHOULD ROCK','SHOULD','DOES') → 'QGIS DOES ROCK' Note that the function is case senstive so Calle != calle


0

What about looping through, throwing the names in a dictionary as keys? Use a counter to add the value if the key doesn't exist, otherwise use the value from the key. So 'Chris' doesn't exist when first encountered; 'Chris' becomes the key and 1 the value. Then 'Dave is next, doesn't exist, so becomes a new key with 2 as the value. Then 'Chris' is ...


1

The Status values "Placed" and "Unplaced" are coded values in a Domain, representing actual values of 0 and 1 respectively. Try your calculation with 1 instead.


2

If you know all of the possible input values in advance, it is possible to do this with Field Calculator by turning on the "Codeblock" and creating a function like the following: def classify(name): if name == 'chris': return 1 elif name == 'dave': return 2 elif name == 'tom': return 3 else: return 0 And then the expression you ...


10

In layout view, open the legend properties and browse to the Items tab (see above picture) where you can specify which items show the count. If you were asking specifically about showing the count in the Table of Contents, I'm not sure how this can be done. I looked around but only found this helpfile from ArcMAP that states For example, you can use ...


0

To determine why you are receiving that error I would recommend replacing: arcpy.CalculateField_management(out_table, pharmF, expression) with: print out_table print pharmF print expression arcpy.CalculateField_management(out_table, pharmF, expression) I suspect that you are not supplying CalculateField_management with the parameter values that you ...


2

You seem to be misusing the cursor. arcpy.CalculateField_management() will operate on the entire table or table view it is given, regardless of any cursor object's existence. It's probably failing because you're passing a field object rather than a field name to it. Try using an update cursor instead, replacing this: #select records from table with ...


1

Is the field an integer type, you might try expression = int(0). Calculate field will work on selected records only or all records if none are selected. Will Calculate field 0 work from the attribute table for that field? Only other option I can suggest is to comment out the CalcField function and maybe do something else that proves the cursor is working as ...



Top 50 recent answers are included