I’m new to ArcMap and was wondering if anybody could help me out. I have a shapefile with counties and wells in that county. In the table I’m trying edit it so that for each county calculate the total numbers of wells that fall into that county, and update the county table with the total count. I also want to calculate how many wells there are per area unit, and update the table with that value as well.  import arcpy featureClass = "C:/Lesson5_Data/Colorado_cities.shp" fieldList = "*"  with arcpy.da.SearchCursor(featureClass, fieldList) as cursor: for row in cursor: print row[4  population = 10000  whereClause = '"POP2007" &gt;= ' + str(population
121504
I am trying to calculate:   total numbers of wells that fall into each county in a shapefile, and update the county table with the total count. calculate the well density (how many wells there are per area unit, and update the table with the values obtained)   This is what I have so far but I have to set up the where_clause (the where clause should be set up to select the county that the cursor is on).   How should I sep up the where_clause to select the county and similarly select the wells that intersect on that county where the cursor is on?     import arcpy   WellsPath = "C:/Lesson5_Data/Wells.shp" COpath = "C:/Lesson5_Data/COUNTIES.shp"  # Create a feature class for the wells  arcpy.MakeFeatureLayer_management (wellspath, "wells_lyr") arcpy.MakeFeatureLayer_management (COpath, "county_lyr")  # Set up the field list to be used by the update cursor fieldlist = "COUNTY"  countyname = "'ADAMS'" where_clause = "COUNTY = " +  countyname print where_clause  with arcpy.da.UpdateCursor(COpath, fieldlist) as countycursor:     for row in countycursor:         print row[0]         countyCount =   int(arcpy.GetCount_management("county_lyr").getOutput(0))         print "Counties selected: " + str(countyCount)         arcpy.SelectLayerByLocation_management("wells_lyr", "INTERSECT", "county_lyr", "", "NEW_SELECTION")   I'm new to Python and I have no clue how to do this.
63840
Is it posssible to perform any math on ESRI ArcMap dynamic text?  For example I have the area of a SDE park layer's SHAPE.AREA, but it is in m2 because the layer is in NAD_1983_UTM_Zone_17N.  I want to show the area in hectares (m2 / 10000).  How do I do this?  Is it possible to add two fields together and display it in dynamic text?
63011
I have a few shapefiles where some of the attributes contain the non-English characters ÅÄÖ. Since some queries doesn't work with these characters (specifically ), I tried to change them in advance with a simple script and add the new strings to another field.  However, change in characters works fine but not updating the field with arcpy.UpdateCursor.   What is an appropriate way of solving this?  I have also tried to do this via the Field Calculator while posting "code" to the codeblock, with the same error.  Error message: Runtime error  Traceback (most recent call last):   File "", line 1, in    File "c:/gis/python/teststring.py", line 28, in      val = code(str(prow.Typkod)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 3: ordinal not in range(128)  Code:  # -*- coding: cp1252 -*- def code(infield):     data = ''     for i in infield: ##        print i         if i == 'Ä':             data = data + 'AE'         elif i == 'ä':             data = data + 'ae'         elif i == 'Å':             data = data + 'AA'         elif i == 'å':             data = data + 'aa'         elif i == 'Ö':             data = data + 'OE'         elif i == 'ö':             data = data + 'oe'         else:             data = data + i     return data   shp = r'O:\XXX\250000\DB\ArcView\shape.shp'  prows = arcpy.UpdateCursor(shp)  for prow in prows:     val = code(unicode(str(prow.Typkod), "utf-8"))     prow.Typkod_U = val     print val     prows.updateRow(prow)   The values of Typkod are of the type: [D, D, S, DDRÄ, TRÄ] etc.  I use ArcMap Basic (10.1) on Windows 7.    New Error message:  Runtime error  Traceback (most recent call last):   File "", line 1, in    File "c:/gis/python/teststring.py", line 29, in      val = code(unicode(str(row.Typkod), "utf-8")) UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 3: ordinal not in range(128)  &gt;&gt;&gt; val 'DDRÄ' &gt;&gt;&gt; type(val) type 'str'      It appears as if the output from the function is wrong somehow. When there's ÅÄÖ involved it returns data = u'DDR\xc4' and not (as was my intention) data = 'DDRAE'. Any suggestions on what might cause this?
44536
Is there a way to export a table with selected records to an Excel spreadsheet?  I was trying to export just to .txt file but ArcGIS gives me an error message.     An error occurred exporting the table   The other problem I have is with coordinates. I want them only with one locus after the comma, I mean like the format: xx xx xx,x not like I have now xx xx xx,xxx.     The version of my software is 9.3.
73375
Using ArcMap 10.1, I edited the coordinates within a shapefile.   They are long/lat but the point will not move to that new coordinate on the map.   I've tried clicking on the Longitude column in the attribute table and 'calculating geometry' but still nothing occurs.
113771
I am using ArcGIS 10.2 and have assumed until now that it is possible to select a specific row in an attribute table. However, I can't seem to find a way to do this. The only available methods seem to be to return a search or update cursor, and to iterate through each row in the table.   Is there really no way to select only the desired row?  What I am trying to do is to select a target row - e.g. 50423 - and then to update a field for that row. I'd hate to iterate through the entire table of millions of records.
86494
I have an ArcMap 10 project with multiple layer groups. One layer is a raster DEM, another layer group is a bunch of vector shapefiles (including points, lines and polygons). The client wants all vector data to contain Z values.  Populating the attribute tables for the vector data with X and Y values is easy enough but how do I populate the Z values?   Is there a way that I can use Field Calculator to "grab" the height values from the DEM layer for each vector feature?   I should add that we don't have a licence for the 3D Analyst or Spatial Analyst extensions.
17297
I would like to use a Python script that is not based on arcpy to do things like  query a shapefile by attributes, create new layer from selection, and calculate areas of a polygon and convert polygons to points.  Anyone have any code examples of using other Python modules or libraries? I am able to do this easily using arcpy but i wanted to explore other options.
112923
Can someone help me understand what the last 2 lines of this code does:  import arcpy arcpy.env.workspace = "c:/esripress/python/data/exercise07" arcpy.env.overwriteOutput = True  copy = arcpy.CopyFeatures_management("airports.shp","Results/airports.shp") fc = "Results/airports.shp"  cursor = arcpy.da.UpdateCursor(fc, ["STATE"], ' "STATE" &lt;&gt; \'AK\'') for row in cursor:     row[0] = "AK"     cursor.updateRow(row) del row del cursor   I understand that the loop function goes through each record that does not have a value of 'AK'  and gives that record a value of "AK".  But what I don't understand is what the del row and del cursor are meant to do.
43815
So I found this python script on another post here and was trying to adjust it for my needs.  I'm a very novice python user so I'm struggling with how to modify the script.  I have a Feature Class stored in a feature Dataset that I want to search a field for duplicate values and populate a new field with Y for duplicate or N for none.  The below script is what I found that looks like it will work once I find a way to drill down into my file geodatabase.          from arcpy import *          inShapefile = pointsShapefile          checkField = "xyCombine"         updateField = "dplicate"         #List of values found once         occursOnce = []        #list of values found twice         occursTwice = []       cursor = da.SearchCursor (inShapefile, [checkField])           for row in cursor:           #Check value is not null        if row[0]:     #If not already found to occur twice, proceed     if not row[0] in occursTwice:         #If hasn't occured once yet         if not row[0] in occursOnce:             #Add to occurs once list             occursOnce.append (row[0])         #If value has already been found once         else:             #Add to occurs twice list (duplicates)             occursTwice.append (row[0])     del cursor       cursor = da.UpdateCursor (inShapefile, [checkField, updateField])      for row in cursor:       #Check value is not null         if row[0]:            #check if value in occursTwice list (i.e. is duplicate)     if row[0] in occursTwice:         row[1] = "Y"     else:         row[1] = "N"     cursor.updateRow(row)    del cursor
30924
I am using ArcMap 10.2 and I'm looking for a way to add  a table containing certain fields from select elements from a featureclass to my map. Ive tried the add table option from the attribute table, but it doesn't quite give what I want (the table must be editable to look a certain way).   Are there any options out there for 10.2 like arcpy.mapping.tableview or will upgrading to 10.3 so I can get access to the "graphic table element" function be best?
36018
I have added a new field (Category) in an attribute table of a shapefile and I would like to fill it with numbers, 0 or 1, based on the numbers of another field (Calorific value) of the same attribute table.   That means that if the Calorific value is higher than 15, then I would like to fill in the corresponding cells of the (new) Category field with 1. If the Calorific value is less than 15, then the rest cells of the (new) Category field to be filled in with the number 0.   Is there a way to do this automatically rather than manually?
82190
I am using ArcGIS 10.1 and I have a non-spatial table and some layers in a Data Frame.   When I switch to Layout View I want to be able to show the map in a data frame element and the table in another element (something that one could do with "Add Table To Layout" from Table Options, but I want to do this in one step without having to go to Table Options).   Is there a way to do this using ArcPy?   I couldn't find any function in the ArcPy library that would create a new Layout Element ... and then I also don't know how to add the contents of the table to the Layout Element.
79937
I am using ArcGIS 10.2 for Desktop, and I've been looking through this site, and can't seem to figure out my answer yet. Very new to VBA and Python, but lots of years with ArcGIS.  I know I can do this the slow way with Select By Attributes, but It's time consuming.  I am attempting a spatial join between cases of a disease (points layer) and US Census Tracts (polygon layer). This requires count data. For each point/case, I have a field called YEAR with date ranges 2001 to 2012 depending on what year the case happened. I need a count column for each year. For example, the first one I'm calling COUNT01. If the case date in YEAR is 2001, then COUNT01 will have a 1 in it. If it is any other year (2002-2012), then there will need to be a 0. I will have COUNT02, COUNT03...COUNT12 columns. Can't have a "Null" value.   Here's what I've tried so far    And here is what the data looks like in Arc.
100474
I am using ArcGIS Desktop 10x. I have a shapefile of 300 points which I need to make groups, each of which will contain exactly 9 points which are closest neighbors.  I tried the '' tool, which have added NEAR_FID and NEAR_DIST to the attribute table but couldn't use it to group 9 neighbors. I also tried '' tool but this only makes 2 groups overall with variable number of members each time.  Anyone have any better idea?
94147
I am a new user doing simple tasks with ArcMap 10.1  I have a shapefile and an excel file, and I want the join to be a permanent part of the shapefile. The way I've been going about this is to export the shapefile into a feature class within a database. Is this the most efficient way to go about saving the joined attributes?
45334
I need to combine two fields in an attribute table.  I want to do this using the field calculator.  What is the proper script to write to combine a field called "name" and "type", so that it produces one field with "name type"?  I'm using ArcGIS Desktop 10.0.