Latitude and Longitude Values from Polygon in Alteryx

by Ben Wells

During an API refresher session we were looking at pulling data from the Police API using Alteryx. Usually we would pull data using various API calls to extract the data we wanted, however the Police API has an interesting feature which allows data to be pulled from a custom area. This allows a user to pull data of crimes according to a custom area defined by longitude and latitudes.

In Alteryx, these is the map input tool which allows a user create a custom; point, line or polygon. By drawing a custom polygon on the map input it would be possible to call the Police API and extract crime data for the chosen area drawn in the polygon. So how we would we go about drawing our custom polygon and getting the longitude and latitude points?

First add a Map Input tool and draw your custom polygon shape:

Next, use the Polysplit tool and select ‘split to points’. This will create spatial points in Alteryx for every point on the polygon as shown below:

Finally, use the Spatial Info tool and select ‘Centroid as X and Y Fields’ for the ‘Split_SpatialObj’ which you had just created. We can now see the latitude and longitude points in CentroidX and CentroidY.

Next, you would need to clean the data into a format to call for the Police API to get the crimes in the chosen custom shape but I won’t ruin the data prepping fun for you! Here is how the API call for all crimes in our custom drawn polygon for June 2019 looked!

2 mins read

Fri 23 Aug 2019

Thu 22 Aug 2019

Tue 20 Aug 2019

Mon 19 Aug 2019