Can features be added by entering coordinates?

3809
9
03-11-2016 09:40 AM
WillMcInnes
New Contributor III

Users in our organization have asked to be able to add point features in Collector by typing in the coordinates of the point (rather than clicking on the map or adding at the device location).


Is there a way to set the coordinates of a feature, or a way to locate a coordinate on the map? I know that if you click on the map it will give the location, but we need a way to locate coordinates.


Any help appreciated.

9 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Will,

Doesn't look like this functionality is available just yet.

One thing you could do is have two fields where the user can enter the coordinates of the feature they would like to collect.  The user can the collect a point in the general vicinity.  You could have a script that runs on the backend to update the geometry of these points.  Below is an example of a script that will update the geometry of a point feature service by reading values from a field called X and another called Y.

import urllib, urllib2, json

#Parameters
username = 'agolUser'
password = '*****'
baseURL = 'http://services.arcgis.com/dlFtlWFB4qUk/arcgis/rest/services/PA_Hydrants/FeatureServer/0'
referer = 'http://countysandbox.maps.arcgis.com'

#generate token for service
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': referer}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']

#query service and return OID, X, & Y fields
url = baseURL
params = {'where': '1=1', 'outFields': "OBJECTID, X, Y", 'token': token, 'f': 'json'}
req = urllib2.Request(url + "/query", urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)

#update geometry with X & Y values
for value in data['features']:
    updateURL = baseURL + '/updateFeatures'
    X = value['attributes']['X']
    Y = value['attributes']['Y']
    OID = value['attributes']['OBJECTID']
    
    updates = [{"geometry" : {"x" : X, "y" : Y}, "attributes" : {"OBJECTID" : OID}}]
    params = {'features': updates, 'token': token, 'f': 'json'}

    req = urllib2.Request(updateURL, urllib.urlencode(params))
    response = urllib2.urlopen(req)
    data = json.load(response)
    print "ObjectID: " + str(data['updateResults'][0]['objectId']) + ", success: " + str(data['updateResults'][0]['success'])
0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi Will,

Doesn't look like this functionality is available just yet.

One thing you could do is have two fields where the user can enter the coordinates of the feature they would like to collect.  The user can the collect a point in the general vicinity.  You could have a script that runs on the backend to update the geometry of these points.  Below is an example of a script that will update the geometry of a point feature service by reading values from a field called X and another called Y.

import urllib, urllib2, json

#Parameters
username = 'agolUser'
password = '*****'
baseURL = 'http://services.arcgis.com/dlFtlWFB4qUk/arcgis/rest/services/PA_Hydrants/FeatureServer/0'
referer = 'http://countysandbox.maps.arcgis.com'

#generate token for service
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': referer}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']

#query service and return OID, X, & Y fields
url = baseURL
params = {'where': '1=1', 'outFields': "OBJECTID, X, Y", 'token': token, 'f': 'json'}
req = urllib2.Request(url + "/query", urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)

#update geometry with X & Y values
for value in data['features']:
    updateURL = baseURL + '/updateFeatures'
    X = value['attributes']['X']
    Y = value['attributes']['Y']
    OID = value['attributes']['OBJECTID']
    
    updates = [{"geometry" : {"x" : X, "y" : Y}, "attributes" : {"OBJECTID" : OID}}]
    params = {'features': updates, 'token': token, 'f': 'json'}

    req = urllib2.Request(updateURL, urllib.urlencode(params))
    response = urllib2.urlopen(req)
    data = json.load(response)
    print "ObjectID: " + str(data['updateResults'][0]['objectId']) + ", success: " + str(data['updateResults'][0]['success'])
WillMcInnes
New Contributor III

This is a good option, thanks Jake.

0 Kudos
KyleBalke__GISP
Occasional Contributor III

Hey Will...I have had success using the search for Place or Address to search for a coordinate pair.

Screenshot_2016-03-11-12-44-25.png

WillMcInnes
New Contributor III

Thanks Kyle, this is useful. I was trying this with no luck, but I see now that long has to go first!

0 Kudos
WillMcInnes
New Contributor III

Unfortunately I just realized that this function will only work with a data connection, so it will not work when our crews are out in the field.

0 Kudos
PeterNasuti
Esri Contributor

Hello Will,

This can be completed with the following workflow:

1) Open the Collector web map

2) Click the magnifying glass for the Search tool

3) Enter the long/lat in the search in that order (not lat / long)

4) This will find the location and show a nice little pin with a popup box. If it does not find it, you might not be using the World Geocode Service as your organization's default utility geocoder for the ArcGIS Online/Portal for ArcGIS organization.

5) You then click the three dots or action button in the top right corner of the popup > a menu appears > Collect here

6) This brings you to the menu to pick which layer or feature type you are trying to collect

7) Enter your attribute values and submit - all done!

1search.png

3search.png

Let me know if there are any questions! This was tested with Collector for Android 10.3.7 but same workflow for iOS except the ellipsis is replaced with the iOS action button.

RenRosin
New Contributor III

I'm also trying to do this, but I can't get a result, I'm not sure why.

0 Kudos
PeterNasuti
Esri Contributor

Hi Ren,

I just tested the workflow I had provided above again this morning and it still works fine on my end (Android). If it is failing on your end, we would likely want to proceed with a support case to investigate things like:

  1. What coordinate system is your web map/basemap in? Are the entered coordinates matching?
  2. Are you entering long/lat or lat/long. Works with long/lat as mentioned above.
  3. Is your collection layer a point layer?
  4. Is the issue still witnessed with just one point layer in a single map or only if there are multiple layers?
  5. Are you using Android, iOS, or Windows?
  6. Does this fail with a sample service, or just one map/dataset?