|
POST
|
Golden, I don't know exactly why it is happening. My first guess would be a bug in version 10.2.1, because I don't seem have the issue with 10.4.1. (I have only tested with these versions of ArcMap.) I have been able to get a listing of point, line and polygon layers with just 'Point' in the list on line 27. Perhaps one of the items in the list is incorrect, but from the documentation all looks ok. I am also wondering if line 37 is correctly filtering the fields as well, but it doesn't seem to be causing a serious problem. In place of commenting out the line, it is also possible to use an empty list such as: in_features.filter.list = [] Since the filter class is built into the Python toolbox, I'm not quite sure how to debug it. There is some documentation here and here.
... View more
10-12-2016
05:13 PM
|
0
|
4
|
2110
|
|
POST
|
I reposted my code above as I also had some indentation errors. Lines 19-27 limit the type of feature layers the tool will use - points, lines and polygons. For some reason the filter on line 27 is limiting the feature type to lines. If you comment the line out, it will then allow points and polygons. # in_features.filter.list = ['Point','Polyline','Polygon'] But this may cause the code to fail later on. In the training seminar video, POINT etc. is in all caps, but it doesn't seem to be a problem with capitalization alone. This will take some further investigation. Regarding Micah's question about line 37: in_features.filter.list = ['Short','Long','Double','Float','Text'] This line is limiting the choice display of the selected layer's fields to the specific types in the list. Fields of type Date, Blob, Raster, Guid, etc. are not displayed.
... View more
10-11-2016
05:49 PM
|
0
|
6
|
4451
|
|
POST
|
I see a couple of things. First, do not use closed parenthesis on line 20. Use indentation for the command. Since the command variables are in parenthesis, there is no need for a backslash. And line 22 syntax is incorrect. arcpy.Select_analysis("Locations_lyr",
r"M:\NRD_Maps\etc",
'"Marker" = "' + sitename + '"')
Lines 23-25 and 28-29 should also use indentation. Edit - Perhaps line 22 should be like this: '\'"Marker" = \\\'' + sitename + '\\\'\'' There is some discussion on this command here regarding the where clause.
... View more
10-05-2016
09:31 AM
|
1
|
0
|
890
|
|
POST
|
Dan has a point about the code's formatting. The indentation level is important. Using the script you supplied, the indentation should look like this. import arcpy
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Calculate Geometry"
self.alias = "geometry"
# List of tool classes associated with this toolbox
self.tools = [CalculateGeometry]
class CalculateGeometry(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "CalculateGeometry"
self.description = ""
self.canRunInBackground = True
def getParameterInfo(self):
# first parameter
"""Define parameter definitions"""
in_features = arcpy.Parameter(
displayName = 'Input Feature',
name = 'in_features',
datatype = 'Feature Layer',
parameterType = 'Required',
direction = 'Input')
in_features.filter.list = ['Point','Polyline','Polygon']
# second parameter
field = arcpy.Parameter(
displayName = 'Field name',
name = 'field_name',
datatype = 'Field',
parameterType = 'Required',
direction = 'Input')
field.parameterDependencies = [in_features.name]
# only show field belongs to the input feature
in_features.filter.list = ['Short','Long','Double','Float','Text']
# third parameter
geomProperty = arcpy.Parameter(
displayName = 'Property',
name = 'geomProperty',
datatype = 'String',
parameterType = 'Required',
direction = 'Input')
# fourth parameter
units = arcpy.Parameter(
displayName = 'Units',
name = 'units',
datatype = 'String',
parameterType = 'optional',
direction = 'Input',
enabled = False)
# fifth parameter
out_features = arcpy.Parameter(
displayName = 'Output Features',
name = 'out_features',
datatype = 'Feature Layer',
parameterType = 'Derived',
direction = 'Output')
field.parameterDependencies = [in_features.name]
out_features.schema.clone = True
params = [in_features, field, geomProperty, units, out_features]
return params
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
# Get Inputs
in_features = parameters[0]
geomProperty = parameters[2]
units = parameters[3]
# Geometry Property Filter Lists
pointPropertyList = ['X Coordinate of Point',
'Y Coordinate of Point']
linePropertyList = ['Length', 'X Coordinate of Line Start',
'Y Coordinate of Line Start',
'X Coordinate of Line End',
'Y Coordinate of Line End']
polygonPropertyList = ['Area','Perimeter',
'X Coordinate of Centroid',
'Y Coordinate of Centroid']
# Get shape type of input to determine
# filter list for geometry property parameter
if in_features.value:
desc = arcpy.Describe(in_features.valueAsText)
if desc.shapeType == 'Point':
geomProperty.filter.list = pointPropertyList
elif desc.shapeType == 'Polyline':
geomProperty.filter.list = linePropertyList
elif desc.shapeType == 'Polygon':
geomProperty.filter.list = polygonPropertyList
# Unit Filter Lists
areaUnitList = ['Acres','Ares','Hectares','Square Centimeters','Square Inches','Square Feet','Square Kilometers','Square Meters','Square Miles','Square Millimeters','Square Yard','Square Decimeters']
lengthUnitList = ['Centimeters','Feet','Inches','Kilometers','Meters','Miles','Millimeters','Nautical Miles','Yards','Decimal Degrees']
# Get geometry property input to determine filter list for unit parameter
if geomProperty.value:
if geomProperty.valueAsText == 'Area':
units.enabled = True
units.filter.list = areaUnitList
elif geomProperty.valueAsText in ['Length','Perimeter']:
units.enabled =True
units.filter.list = lengthUnitList
else:
units.value = ''
units.filter.list = []
units.enabled = False
return
def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
in_features = parameters[0]
geomProperty= parameters[2]
units = parameters[3]
# Check is input is Multipoint or Multipatch and if so set an error
if in_features.value:
desc = arcpy.Describe(in_features.valueAsText)
if desc.shapeType in ['Multipoint','Multipatch']:
in_features.setErrorMessage('{0} features are not supported.'.format(desc.shapeType))
# Check if certain geometry property value is set with no units and add error
if geomProperty.valueAsText in ['Length','Perimeter','Area']:
if not units.value:
units.setErrorMessage('Units required for {0} property'.format(geomProperty.valueAsText))
return
def execute(self, parameters, messages):
"""The source code of the tool."""
# Get Input
in_features = parameters[0].valueAsText
field = parameters[1].valueAsText
geomProperty= parameters[2].valueAsText
units = parameters[3].valueAsText
shapeFieldName = arcpy.Describe(in_features).shapeFieldName
# Create the expression
exp = '!' + shapeFieldName
if geomProperty == 'Area':
exp += '.area@'+ units.replace('','')
elif geomProperty in ['Length','Perimeter']:
exp += '.length@'+ units.replace('','')
else:
propertyList = geomProperty.split('')
coord = propertyList[0]
if propertyList[-1] in ['Point','Start']:
exp += '.firstPoint.' + coord
elif propertyList[-1] == 'End':
exp += '.lastPoint.'+ coord
elif propertyList[-1] == 'Centroid':
exp += '.centroid.'+ coord
exp+= '!'
messages.addMessage(
'\nExpression used for field calculation: {0}\n'.format(exp))
#Calculate Field
arcpy.CalculateField_management(in_features,field,exp,'PYTHON_9.3')
return
I would also suggest using some blank lines to help make the code more readable.
... View more
10-04-2016
10:57 PM
|
1
|
12
|
2344
|
|
POST
|
For map layers to display on Collector, the layer needs to be editable. Since you want to take the map offline, you also need to enable sync for the layer. When you add the reference layers to your map, select the option to disable editing. If you prefer, you can also uncheck the edit option when you are configuring the pop-up for the reference layer.
... View more
09-23-2016
09:39 AM
|
1
|
0
|
1650
|
|
POST
|
Perhaps someone who is more familiar with Portal can help answer this. If I understand your question: How to set permissions in Portal to allow a Collector user delete data that was mistakenly added to a feature? I suggest that you check the feature layer settings and make sure that users can add, update and delete features. Tal vez alguien que está más familiarizado con el Portal puede ayudar a responder a esto. Si entiendo su pregunta: ¿Cómo establecer permisos en el Portal para permitir al usuario borrar los datos del colector que se agregó por error a una característica? Le sugiero que compruebe la configuración de capa de entidades y asegurarse de que los usuarios pueden añadir, actualizar y eliminar funciones.
... View more
09-14-2016
02:07 PM
|
0
|
0
|
947
|
|
POST
|
If I understand your question, you need to set delete permission for your feature layer in the feature settings so that a user can delete unwanted features.
... View more
09-12-2016
02:24 PM
|
2
|
1
|
947
|
|
POST
|
Is this currently limited to iOS and Windows devices? The link for Android is grayed out on the metadata page.
... View more
09-08-2016
12:36 PM
|
0
|
3
|
1984
|
|
POST
|
There is some discussion in this thread: https://community.esri.com/thread/180792. There are some links for obtaining this data when using an external device connected to an iOS or Windows version of Collector. I would also like to be able to capture this data using the device's internal GPS.
... View more
09-08-2016
12:01 PM
|
0
|
0
|
1984
|
|
POST
|
And the feature layers used in the map also have sharing enabled for the group members? With editing/updating enabled as appropriate.
... View more
09-06-2016
08:08 PM
|
0
|
1
|
1050
|
|
POST
|
You would use the REST API query. Here's some sample code which you will need to modify. import arcpy, urllib, urllib2, json, sys, time, datetime, collections
from datetime import datetime, timedelta
# how far back do you want to go? Remember AGO uses GMT / UTC.
H = 220
date_H_hours_ago = datetime.now() - timedelta(hours=H)
# Credentials and feature service information
# URL, referrer and tokenurl may vary based on ArcGIS Online or your server setup
# Credentials and feature service information
username = 'Username' # use your username here
password = 'Password' # use your password here
# This needs to be the path to your featue, edit as needed, note /query at end
URL = "https://services2.arcgis.com/somestring/arcgis/rest/services/FeatureName/FeatureServer/0/query"
referer = "http://www.arcgis.com/"
tokenurl = "https://www.arcgis.com/sharing/rest/generateToken"
# obtain a token
query_dict = { 'username': username, 'password': password, 'referer': referer }
query_string = urllib.urlencode(query_dict)
token = json.loads(urllib.urlopen(tokenurl + "?f=json", query_string).read())
if "token" not in token:
print(token['error'])
sys.exit(1)
# Your fields go in comma delimited list (outFields)
query_dict = {
"where" : "EditDate >= DATE '2016-06-01 00:00:00'",
"outFields" : "OBJECTID, EditDate",
"orderByFields" : "EditDate",
"returnGeometry" : "true",
"f": "json", "token": token['token'] }
# to select all fields use: "outFields" : "*",
# to select individual fields use comma delimited list: "outFields" : "OBJECTID, EditDate",
# a date certain: "where" : "EditDate >= DATE '2016-05-29 18:30:00'",
# this morning at 2 am: "where" : "EditDate >= DATE '"+(datetime.now()).strftime("%Y-%m-%d 02:00:00")+"'",
# some time ago: "where" : "EditDate > DATE '"+date_H_hours_ago.strftime("%Y-%m-%d %H:%M:%S")+"'",
# if you do not want geometry: "returnGeometry" : "false",
# results in json format
jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))
features = json.loads(jsonResponse.read(),
object_pairs_hook=collections.OrderedDict)[u'features']
# print json.dumps(features, indent=4, sort_keys=False) # formatted json
print '\n\nTitle if needed:'
print 'ObjectID\tEditDate\tX-lon\tY-lat' #Field list you want to use
for feature in features:
# AGO normally uses GMT/UTC, you may wish to convert to local time
editTime = time.strftime('%c', time.localtime(feature['attributes']['EditDate']/1000))
# print your fields here, using something like this:
print str(feature['attributes']['OBJECTID']) + '\t' + editTime,
# if you wanted geometry; AGO returns web mercator, reproject if necessary
# print "x: " + str(feature['geometry']['x'])+ "\ty: " + str(feature['geometry']['y'])
# WGS 1984 : (4326) Lat/Lon
# WGS 1984 Web Mercator (auxiliary sphere) : (102100) or (3857)
ptGeometry = arcpy.PointGeometry(arcpy.Point(feature['geometry']['x'],feature['geometry']['y']),
arcpy.SpatialReference(3857)).projectAs(arcpy.SpatialReference(4326))
print "\t" + str(ptGeometry.firstPoint.X) +"\t" + str(ptGeometry.firstPoint.Y)
Some of the places you need to change are lines: 12, 13, 16, 32, 53, 54, 61. There's also some general notes and debugging code, which you can cut out.
... View more
09-06-2016
02:29 PM
|
1
|
0
|
1312
|
|
POST
|
Are the layers and the map shared with the Publisher? If not, you should create a group, invite this person to become a member of the group, and share the map and features with everyone in the group. As an alternative, you could share the layers and map with everyone, which is probably not the best idea.
... View more
09-06-2016
02:00 PM
|
0
|
3
|
1050
|
|
POST
|
If you are running your own server, this information might be in the server logs.
... View more
09-02-2016
09:44 AM
|
0
|
0
|
643
|
|
POST
|
I also suggest using UTC. I will query features using the REST API and Python with a line of code to convert the time zone from UTC, such as: editTime = time.strftime('%c', time.localtime(feature['attributes']['EditDate']/1000)) In addition, there is a Convert Time Zone tool in the Data Management - Fields toolset that can assist in this process if you are downloading the feature in a file geodatabase.
... View more
09-01-2016
02:24 PM
|
0
|
0
|
990
|
|
POST
|
It can also be written: import arcpy
table = r"C:\Temp\Default.gdb\LV"
field = "group_code"
exp = "''.join(i for i in !group_code! if i.isdigit())"
arcpy.CalculateField_management(table,field,exp,"PYTHON_9.3")
... View more
08-31-2016
03:36 PM
|
2
|
0
|
2528
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-15-2025
02:54 PM
|