Select to view content in your preferred language

Displaying images associated with features in ArcGIS online

1696
8
03-17-2018 06:14 PM
JeffreySamson
Emerging Contributor

I am trying to display graphs generated in matplotlib within an ArcGIS online app. I am taking this approach because the chart widget will fall short of the graphing capabilities I need. Therefore I want to generate a chart in matplotlib (via python) and somehow display in the ArcGIS online application. I have tried working with configuring pop-ups and adding an image but I cant seem to access an image associated with a particular feature. Instead there is an option to show image from an URL. I need to show an image which is assigned for each feature in a table. I can store these images in the attribute table as a field with a raster data type, but how do I access and display these raster images in an arcgis online app? ...or is there a much easier and/or better way to bring up python generated graphs within the app?

0 Kudos
8 Replies
XanderBakker
Esri Esteemed Contributor

Can you post a graph that you want to generate (or already have generated)?

If you have the images and you have access to a web server (even dropbox or google drive should work), you can allocate your images there with a name that is related to the features (for instance a unique name or the Object ID) and with that you can create the URL to the images for each feature.

0 Kudos
JeffreySamson
Emerging Contributor

Xander, Thanks so much for replying. I really appreciate it.

The graphs are just  .jpeg images of graphs made in matplotlib. Although not generated in matplotlib, I quickly made a rough graph in arcmap and saved as a jpeg for the purpose of showing what I want to attach to my features.

For each point (location) selected within the online application, we need to generate a new graph based on some variables which are provided by the user via a multi-variable string parameter in the python script  (geoprocessing tool in the web app). We can do this via python script but getting this image stored on our server once it is created is where we are at a standstill. We have a server but our knowledge of posting and accessing content on the server is limited. 

You mentioned that you can allocated images on the server. This is probably the breakthrough thing we need here. Therefore this is my main question: 

Once we create the graph from the python script (which will be a geoprocessing service in the web app), how do we allocate it to the server once the image is created from the script? For the moment we have been posting our content (web map, feature layers, geoprocessing tools) through "share as service" via ArcMap in the desktop environment. I think this would all work out if we could save or post these images to the server from a statement within the script. Then, as you said, we can assign a feature ID and URL to each image once on the server.

Hope this made some sense. Its a little difficult explaining a problem that we have limited knowledge on, so you detective work here is much appreciated.

Regards,

Jefff

0 Kudos
XanderBakker
Esri Esteemed Contributor

HiJeffrey Samson , sorry for the delay in my response. 

As far as I understand you will have a geoprocessing service that will be able to generate the graphs and store them at the server. Each user is able to specify different parameters. Will the GP service generate graphs for all the features? Naming should include an ID of the feature and a user ID. For the GP service that is not a problem, but for the pop-up it will be, since the pop-up would need to access the user id somehow. At this moment Arcade does not have that possibility and would not be able to generate a URL including the user ID.

Creating a name that does not include the user ID would mean that at each run the graphs will be overwritten and each user will have access to the latest generate graphs, which is not what you want.

0 Kudos
JeffreySamson
Emerging Contributor

Hi Xander ,

Absolutely no worries. I just appreciate your time and efforts in heartng this out.

In response to your answer, I may have take a few step backs as my problem probably begins at an earlier level - just get the geoprocessing tool to work.

We have water station locations which are a layer in a map service. We have script which produces a chart from matplotlib. Each produced chart will need to be linked somehow with each station (or each feature) in the water station layer. These images are created in matplotlib and saved as an .png image. Within the desktop environment, the script works great: it plots data which is retrieved from a stand alone table and stores the generated image in a separate folder. Now this is where I am probably missing something entirely...probably something basic:

After running this script and publishing it as a geoprocessing service, where do these pictures get saved? The pictures were saved in a separate folder on my local machine when the tool was ran in ArcMap Desktop, but how does this change when the tool is published? Once publishing, is a REST destination automatically created on the server to store the image outputs? I ask because when I run the published tool within ArcGIS Online App, the tool executes and then "fails". At the moment, these images aren't being generated or stored and on the server - this is the first step I have to solve.

After I am able to get this tool to make images on the server, then I can start dealing with the issue of accessing there location from the Web App. In other words, set an URL for the images in the Web App..I guess I would somehow have to retrieved the URL for each image. But again, I must get the tool working in the first place.

Sorry to back pedel a few steps, but thought I should point out that I am not even able to get the script or geoprocessing tool to work in the Web App yet. I guess that would be step one..

Thanks again for any insight.

Jeff

0 Kudos
XanderBakker
Esri Esteemed Contributor
After running this script and publishing it as a geoprocessing service, where do these pictures get saved?

Your script will need to have the logic and define the output location. When working with a GP Service, this will have to be a folder that is accessible by ArcGIS Server and it need to be a folder that is accessible by you app. Results from GP services are normally produced in the output folder of the service (part if the Server install). You can also write them to a folder inside IIS (if you are using IIS/Windows). 

To understand the logic of your script, can you post it here? In matplotlib, when you save a graph as png you can specify the location. 

I think it is important to start thinking about how to access the graphs from your web app, to avoid doing things that might not work in that context.

0 Kudos
JeffreySamson
Emerging Contributor

The code below is the section of my scrip which saves the picture to a local folder on my computer (path to directory is stored in the variable "picFolder".

I was hoping when publishing, these pictures would be stored on a folder somewhere on the Server automatically. I am guessing I must specify a path to a directory on the server..I am not sure what this path would be...

Also, you can see that I save the image path as a string in an attribute field called "ImagePath" (via Update cursor) and I use this field to attach these images to each feature. These images don't actually get attached to the feature (like they do if manually attach images in an edit session with ArcMap desktop). Instead just an attachment table is made (second picture).

Thanks again.

0 Kudos
JeffreySamson
Emerging Contributor

Here is the  actual location of the pictures on my machine: D:\Tool_Demo\Pictures

0 Kudos
XanderBakker
Esri Esteemed Contributor

When you execute this script on the server (as GP service) you will have to point the savePath to the location on the server machine that is accessible by the GP service and also accessible by the web application.

What I notice is that you generate the png of the graph and you use those as attachments. If you are going to have multiple users generating their own graphs and all these graphs will be added as attachments, you will potentially have a long list of attachments and every user is able to access each user specific attachment. 

0 Kudos