Wednesday, June 22, 2011

CSV files + ArcGIS.com

ArcGIS.com is getting pretty cool. Presentations, built-in queries for use in mobile apps, creating editable layers, and configurable pop-ups are all awesome. But my new favorite thing is leveraging ArcGIS.com with the samples in the JavaScript API. The neat thing about some of these samples is you can completely configure them using their URL. For example, let’s say you want an interactive map of the tornadoes that just hit the US on 6/20. You could go to NOAA here: http://www.spc.noaa.gov/climo/reports/110620_rpts.html and see a nice list of tornadoes and a map. Unfortunately the map is not interactive so there is no way to tie an item from the list to a point in the map. I could also download a CSV file of the tornadoes by clicking the CSV link on the page. But then I just have a table of coordinates and values with no map. To solve this problem I go to the JavaScript samples, expand the ArcGIS.com samples, and select the CSV Data help topic. If you read this sample it tells you that it takes several arguments in the URL to configure the application. In our case, the NOAA CSV file is publicly accessible, so we can display those points by plugging that URL as an argument to the URL for this sample. We also need to download the CSV to look at the different field names to tell the sample app what column names stores the Latitude, Longitude, and primary Display name. The result is a URL that looks like this:
http://servicesbeta.esri.com/demos/ags/ags_MapwithTable.html?webmap=d5e02a0c1f2b4ec399823fdd3c2fdebd&dataUrl=http://www.spc.noaa.gov/climo/reports/110620_rpts_torn.csv&displayField=Location&title=Tornadoes&subTitle=6-20-2011&latitudeField=Lat&longitudeField=Lon
Notice, the first configuration setting is the webmap that these points are going to overlay. To display the same points on top of the current weather warnings web map you would use a URL like this:
http://servicesbeta.esri.com/demos/ags/ags_MapwithTable.html?webmap=a03a49082c1c4e869c6349d9cdccf2a3&dataUrl=http://www.spc.noaa.gov/climo/reports/110620_rpts_torn.csv&displayField=Location&title=Tornadoes&subTitle=6-20-2011&latitudeField=Lat&longitudeField=Lon
So by simply changing a URL I can mashup and CSV file with Latitude and Longitude data on the web with any web map on ArcGIS.com all for free. Not bad.