Upload
lykhue
View
219
Download
1
Embed Size (px)
Citation preview
Hosted Feature Service to
Custom Report with Data
Driven PagesJOANNA NISHIMURA | GIS ANALYST
Problem
Client interested in using Survey123 but solution
needed to output survey results to branded report
Basic print functionality in online Survey123 app
Ability to export forms in Survey123, but in beta and
limited functionality
Survey123
Survey123 is an Esri solution to facilitate field data collection
Focuses on collecting data in form format rather than map format
Works well in a disconnected (offline) mode
Compatible on a wide range of devices (Android, iOS, Windows, Linux, Mac OS)
Integrates with other Esri mobile apps like Workforce, Explorer, and Collector
Like other Esri solutions, all data collected goes back to a feature service
Basic Workflow
Use Python tool to download feature service hosted in ArcGIS Online (AGOL) or ArcGIS Server
Export photo attachments, signature attachments
Set up MXD with data driven pages
Use Python script to export pdf from MXD with Data Driven Pages, fill in MXD with
appropriate fields and paths to photo and signature attachments
Benefits of this workflow:
Can be set up as a scheduled process
Easy to set up and make changes to
Can be used with any feature service (hosted in AGOL or through ArcGIS Server)
Exporting from AGOL
Python script to download feature services written by jskinner-esristaff
Download script from: https://geonet.esri.com/docs/DOC-6496
Data Driven Pages (DDP)
DDP allow the export of multiple pages from a single map document
Commonly used to create map books to programmatically export multiple pages
from a single map document
Dynamically updates text, images, locations on a map
Setting Up DDP
Insert data frame for map portion
Use drawing tools to create boxes
Insert text boxes (found that rectangle text worked well) that will dynamically be populated with field information
Add default text to text boxes in event that no information was recorded
Insert picture elements with a path to a default picture
Insert picture element with a path to a default signature
Setting Up DDP continued
Dynamic Text
Insert rectangle text---this enables word wrapping
Change text properties to enable dynamic text replacement
No domain with field called “email”: <dyn type=“page” field=“email” domainlookup=“false”/>
Domain with field called “weather”: <dyn type=“page” field =“weather” domainlookup=“true”/>
No domain with field “notes1” and default text: <dyn type=“page” field =“notes1”
domainlookup=“false” emptyStr=“No notes”/>
Setting up the Python Script
The Python script:
Sets up data driven pages and loops over the globalid field
Gets globalid value of active feature
Creates arrays to store the names of the related photo files and signature file
Goes to attachments folder, finds sub-folder with matching globalid
Stores names of signature and photo files in an array
Accesses picture elements in the MXD and updates the file path
Dyanmic text values are automatically filled in with the correct field information
Exports each page as a pdf
Setting up the Python Script continued
Accessing the correct related images:
Find attachment folder with matching globalID. Within this folder:
If image file name has “signature” in file name, sends the file name to Sig dictionary key
If image file does not have “signature” in file name, appends file name to Photos dictionary
key
So each record ends up with a dictionary that looks something like:
Setting up the Python Script continued
Element
Name:
Photo0
Element
Name:
Photo1
Element
Name:
Photo2
Element Name:
Sig
Find all picture elements in the MXD
Loop through the photo key. Grab the first photo value (file name) and update the first picture
element with file name and file director.
Repeat for the signature key
Limitations and Future Changes
• DDP is limited to 1 page. A possible workaround is to increase the size of the document in the page layout in the MXD
• Requires initial setup of MXD and mapping of dynamic text boxes
• Default update/edit times that are populated in feature services are in UTC time---8 hours ahead of PST
• Future updates:• Only export pages for new features---have to compare against list of globalIDs
• Email pdf as an attachment