Thursday, March 18, 2010

Working With GeoJSON Files in Alteryx

Although my preference now is to typically work with yxdb and cydb file formats, I find it liberating from time to time to be able to work free of vendor specific file formats.

That's why I'm excited to hear about the growing acceptance of multiple light-weight data interchange formats. These formats, or more formally Object Representations, allow geographic data structures to be saved out as simple text and then imported into or exported from a variety of GIS applications. That said, I also tend to gravitate towards vendors that allow you to work in multiple formats and not those that force you to work in their own specific, proprietary format(s).

So I was not surprised to find out that SRC added support for one of these data interchange formats in Alteryx 5.0, which is called GeoJSON. GeoJSON is a geospatial data interchange format based on JavaScript Object Notation (JSON). Use of this interchange format provides the ability to express spatial objects as variable length strings, which can then be saved out as a simple csv text file with a .gjsn extension.

If you want to learn more about GeoJSON, here are two good articles on the topic. First, you can read Linda Thompson's post about the GeoJSON addition on the Alteryx Team blog here. Then read a great article by Christopher J. Andrews from Autodesk that was published in Direction Magazine called "Emerging Technology: AJAX and GeoJSON":

Now that we know a bit more about this format, let's look at how to import and export a GeoJSON file into\from Alteryx. I ran across this while working on a project with GeoJSON files, so I queried Ned Harding who provided the following process. To begin, drag an the Input Tool into a blank module and change the Files of Type selection to All Files and browse for your file, as I have in the image below:

Since GeoJSON is not a standard file type, Alteryx will try to resolve the file. To read the file, you'll need to set the Read it as a built in type selector to GeoJSON (gjsn:) as shown in the next image:


After you select the OK button, the Iput Tool properties window will only show one spatial object like the image below displays:


Now the polygon can be browsed and used like any other spatial object, yet it was read in from a text formatted file - a considerably smaller, non-proprietary GeoJSON file I might add! So if your looking to import spatial objects from a GeoJSON file into Alteryx, the process is rather straight forward.

Exporting GeoJSON files out of Alteryx is a bit different, yet just as simple. The main difference is that the spatial objects you are exporting are saved out as a V_String, or variable length string. This conversion is easily accomplished with the Select Tool:
                           

Note: If you are exporting multiple polygons as one gjsn file, use the Summarize Tool to combine the polygons into one, like I did with my Canada example I used for this post (see top image). This must be done in order for the file to be save out correctly. Then output the file out as a csv file (with a .gjsn extension of course) with \0 as the delimiter with no header as shown below:


That's all there is to creating GeoJSON files in Alteryx. I realize that this is somewhat of an obscure topic, yet it might come in handy someday when you are are given GeoJSON files to work with, or need to provide a deliverable in this format.

I'll be heading out next week to the SRC Extend Conference, so look for continuing posts during that time.
Till next time, Enjoy!

Ron


0 comments:

Post a Comment

Add Comments Here: