Select to view content in your preferred language

Generate/populate lat/lon fields in Collector

3788
2
Jump to solution
07-27-2015 09:03 AM
MichaelMiller2
Frequent Contributor

Can you think of a way that we can have the latitude and longitude that are collected in Collector show up automatically in lat/long fields?

As it is right now, the workflow goes like this:

  1. 1.      Person collects data in field and syncs it up to AGOL.
  2. 2.      I pull the service down and calculate geometry in the Lat/Long fields that I created.
  3. 3.      I republish.

My drill crew wants to be able to pull lats and longs automatically from the table in AGOL, but I have to generate these through the calculate geometry tool each time they collect. Any ideas?

0 Kudos
1 Solution

Accepted Solutions
RandyBurton
MVP Alum

You should be able to do this with a Python script using REST services.  This blog explains "Using Python to push updates to a hosted feature service from an external source.  Instead of the external source, you would query your own data.  The process would go something like this:

  1. Log into your feature services rest URL and get a token.
  2. Query your feature for points containing null latitude/longitude fields (or where the edit date meets selection criteria) to get the points' geometry and ObjectID attribute.
  3. If the feature uses a projection other than WGS 84, you can use arcpy's PointGeometry().projectAs to get a latitude and longitude.
  4. Update the points by sending the ObjectID with related lat/lon data.

You can set the script to run a preset times, or it can be run manually.

View solution in original post

0 Kudos
2 Replies
RandyBurton
MVP Alum

You should be able to do this with a Python script using REST services.  This blog explains "Using Python to push updates to a hosted feature service from an external source.  Instead of the external source, you would query your own data.  The process would go something like this:

  1. Log into your feature services rest URL and get a token.
  2. Query your feature for points containing null latitude/longitude fields (or where the edit date meets selection criteria) to get the points' geometry and ObjectID attribute.
  3. If the feature uses a projection other than WGS 84, you can use arcpy's PointGeometry().projectAs to get a latitude and longitude.
  4. Update the points by sending the ObjectID with related lat/lon data.

You can set the script to run a preset times, or it can be run manually.

0 Kudos
MichaelMiller2
Frequent Contributor

Thanks Randy. I'll explore employing your method.

Thanks again.

0 Kudos