Tag Info

Hot answers tagged

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 ...


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 ...


7

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".


5

You can do this directly in the field calculator.


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(\">\", \" ...


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 - ...


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 ...


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


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 ...


3

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


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 ...


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

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 ...


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


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

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 = ...


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!, ...


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.


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 ...



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