A while ago I was asked to find out how to display line geometry on a map using SharePoint lists. After some creative googling, I came across an ESRI thread, and another one, which pointed me in the right direction. This example uses a single line feature to demonstrate the methodology I developed.
- Convert the line feature to JSON using the tool or using Python (my preferred method):
# # @date 29/04/2015 # @author Cindy Williams # # Converts geometry in a feature class to JSON, # and writes it to a CSV file. # # For use in the Python window in ArcCatalog. # import arcpy arcpy.env.workspace = r"C:\Some\Arb\Folder" lyr = arcpy.management.MakeFeatureLayer("work.gdb\ftr_line") outcsv = r"line_json.csv" # Get geometry of first feature as JSON lyr_json = arcpy.da.SearchCursor(lyr, "SHAPE@JSON").next() # Write JSON to CSV with open(outcsv, 'wb') as csvw: csvw.write(lyr_json)
Of course you can save the file immediately as a JSON file, but I am so used to writing it out to CSV that I automatically put that there.
In your SharePoint site:
- Create a custom list (or open your existing one).
- Add a plain text column called Shape of type Multiple Lines (not sure if this is a requirement, but I figured it couldn’t hurt). As mentioned in the thread, the column must be created with the correct title – renaming an existing column will not work.
- Add a ESRI Maps Location column to the list. Under Location Settings > Coordinate Fields, select Shape. The field dropdown should automatically populate the Shapecolumn we added earlier.
- Start editing your list.
- Create a new record in your list, and populate your attributes. Copy the JSON string from the file created earlier and paste it into the Shape column.
Here is the result (click to enlarge):
This is a nice way of storing commonly accessed features such as study area boundaries, in a central list without a dependency on map services hosted on ArcGIS Server or ArcGIS Online.