POST
|
A new version of the API was released today (v. 1.3). I guess that has something to do with the problem (that I experienced myself too today). I upgraded to the latest version and tried a lower version, but could not display the map in both instances.
... View more
12-19-2017
01:29 PM
|
0
|
1
|
2212
|
POST
|
I installed the latest version of ArcGIS API for Python (v 1.3.) today on Windows 10 through conda in a separate virtualenv. The map widget is not displaying, although I can run commands such as map.center and get coordinate data returned. I get no error messages or whatsoever, everything seems be installed correctly. What could be the problem here? #arcgis api for python python 3.6
... View more
12-19-2017
12:33 PM
|
0
|
3
|
1011
|
POST
|
Thanks for your help. Would the problem be solved if I use cityName = row[0] instead of: cityName = row[43] ?
... View more
10-18-2016
08:53 AM
|
0
|
1
|
704
|
POST
|
This is the example code of tutorial 2-7 of GIS Tutorial for Python Scripting by David Allen. I followed the example code from the book, but the cursor in line 83 wasn't there so I added it myself and it's not working properly. I´m not even sure I used the right cursor. Any help would be very much appreciated on getting it to work. I'm using ArcMap 10.2.2 and I noticed env.overwriteOutput = True isn´t working properly, which could also be a problem here. try:
# import the modules
import arcpy
from arcpy import env
# set up the environment
env.workspace = "C:/EsriPress/GISTPython/MyExercises"
env.overwriteOutput = True
# prompt the user for the input table
inTable = arcpy.GetParameterAsText(0)
# when this is set up as a cursor tool, set the input to tables only
# Get the fields from the input
fields = arcpy.ListFields(inTable)
# Create a fieldinfo object
fieldinfo = arcpy.FieldInfo()
# Define a fieldinfo object to bring only certain fields into the view
# inci_no, alm_date, arv_date, inci_type
# descript, station, shift, city
# number, st_prefix, street, st_type, st_suffix
# (you can´t add new fields to a table view, so reuse a discarded one)
# Change the name of addr_2 to GeoAddress in the output table
# Code was copied and modified from Help screen
# interate through the fields and set them to fieldinfo
for field in fields:
if field.name == "inci_no":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "alm_date":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "alm_time":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "arv_date":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "arv.time":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "inci_type":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "descript":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "station":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "shift":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "city":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "number":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "st_prefix":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "street":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "st_type":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "st_suffix":
fieldinfo.addField(field.name, field.name , "VISIBLE", "")
elif field.name == "addr_2":
fieldinfo.addField(field.name, "GeoAddress" , "VISIBLE", "")
else:
fieldinfo.addField(field.name, field.name , "HIDDEN", "")
# Create a table view of the input table
# The created fire_view table will have fields as set in fieldinfo object
arcpy.MakeTableView_management(inTable, "fire_view", "", "", fieldinfo)
# Do the address formatting into GeoAddress for the whole table
# Concatenate number + st_prefix + street + st_type + st_suffix and remove spaces
arcpy.CalculateField_management("fire_view","GeoAddress","str(!number!) + ' ' + !st_prefix!.strip() + ' ' + !street!.strip() + ' ' + !st_type!.strip() + ' ' + !st_suffix!.srip()", "PYTHON")
# Create new geodatabase to store results for year
# ("Fire Files for " + last 4 digits of file name)
gdbName = "Fire_Files_For_" + inTable[-8:]
arcpy.CreateFileGDB_management("C:\\EsriPress\\GISTPython\\MyExercises",gdbName)
# Use cursor to find each unique city name and add it to a list.append
# City names included may differ from file to file.
# Set up a list to hold unique ity names.
# Start cursor iteration
with arcpy.da.SearchCursor(inTable, ["city"]) as fireCursor:
for row in fireCursor:
cityList = []
cityName = row[23]
if cityName not in cityList:
cityList.append(cityName)
# Result is a list object with all the unique values of the CITY field
del row
arcpy.AddWarning("Made the list of city names")
# Use the names in the list object to select records
for name in cityList:
cityQuery = '"city" = \'' + name + '\''
arcpy.SelectLayerByAttribute_management("fire_view", "NEW_SELECTION",cityQuery)
newTable = "C:\\EsriPress\\GISTPython\\MyExercises\\" + gdbName + ".gdb\\" + name.replace(" ","_")
itemCount = int(arcpy.GetCount_management("fire_view").getOutput(0))
arcpy.AddWarning("A tale called " + newTable + " was created with " + str(itemCount) + " rows.")
except arcpy.ExecuteError:
print arcpy.GetMessages(2)
except:
print "Process did not complete."
... View more
10-18-2016
05:31 AM
|
0
|
3
|
1550
|
POST
|
Hello Xander, thanks for your clear explanation, this is very helpful. Eric
... View more
02-24-2015
01:58 PM
|
0
|
0
|
437
|
POST
|
Hello, I´m trying to work my way through the ´GIS Tutorial for Python Scripting´ by David Allen. Working with cursors (Tutorial 2.3) is giving me a hard time as there seem to be a number of ways to approach this subject, but I can´t make any sense of them. What confuses me most is the numbering in the syntax. Can anybody helmp me with Exercise 2.3? The problem seems to be a non-defined cursor name, but I´m lost here. This is the code I´ve come up with so far: import arcpy from arcpy import env env.workspace = r"C:\EsriPress\GISTPython\Data\City of Oleander.gdb" env.overwriteOutput = True updateFC = "StreetLights" with arcpy.da.UpdateCursor("StreetLights",["TYPE", "Buffer"]) as cursor: for row in cursor: TYPE = row[0] Buffer = row[1] if TYPE == "MV": Buffer = 125 else: Buffer = 200 cursor.updateRow(row) print "All done updating" del cursor del row
... View more
02-24-2015
01:35 PM
|
0
|
2
|
2962
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|