Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

PolyBuild around a Building perimeter

Reggie1995
8 - Asteroid

All - Here is the use case.  I have an address, along with the latitude and longitude for that building location.  What I want to do is to be able to construct a polygon around the building in alteryx.  The maps in alteryx have the building outlines, so surely have the building coordinates, but was unsure if anyone has experience with doing this or if anyone has any recommendations/guidance.

10 REPLIES 10
CharlieS
17 - Castor
17 - Castor

Hi @Reggie1995 

 

When you view base maps in Alteryx (and most applications), you're actually viewing a saved image of that particular area and zoom level. This means that Alteryx is just returning the image of what the area looks like from a hosted web service (like Mapbox/Catro) or an installed dataset (like TomTom). Images are much faster to load that spatial objects, so that's why they're used, Spatial object may have been used to create those images, but those are kept by the data provider. TLDR: There's no spatial objects to PolyBuild into polygons for the buildings you see in map layers.

 

The process of geofencing has been increasingly popular with the rise of GPS analytics. Most businesses find it much cheaper and easier to just buy the building polygons from a 3rd party data provider. One example of a provider is SafeGraph

 

What's your application? Maybe a small radius polygon around your centroids might work to get you started while you look into options for more detailed polygons. 

TravisR
Alteryx Alumni (Retired)

@CharlieS hit the nail on the head with this.

 

One minor correction - the TomTom Maps do actually include spatial data for every layer on the map itself - but these maps don't include building footprints. If you want to extract any data from the TomTom maps included with the Location Insights then you can use the TomTom Layer Extraction App that we ship with the Location Insights bundle. Or you can go to the install location of your Location Insights data and grab the raw yxdbs.

 

The bottom of this article covers how to extract spatial data from the TomTom maps: https://community.alteryx.com/t5/Location-Data-Knowledge-Base/Data-Products-101-Maps/ta-p/398016

 

While we are on the topic of building footprints - a few years ago Microsoft open sourced all their building footprint data that they use in Bing Maps. I can't speak for the quality or how up to date it is but you can find their github for it here: https://github.com/Microsoft/USBuildingFootprints

Reggie1995
8 - Asteroid

Would there be a way to use the Microsoft data and then run that in alteryx? So if the centroid of the building is contained in one of these building footprints, then the polygon coordinates of the building gets returned?  

TravisR
Alteryx Alumni (Retired)

Hi @Reggie1995 

 

Yep! You can load the building footprints into Alteryx and go from there with your spatial analysis. The building footprints from Microsoft conveniently come in the .geojson file format.

 

The good news is that a SpatialObj datatype in Alteryx is just GeoJSON.

 

The bad news is - unfortunately there's not really a way to natively read in .geojson file into Alteryx. However there are some really easy work arounds and I've outlined a solution for it on pages 1 and 2 of this post: https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Handling-polygon-GeoJSON-files-in-Alte...

 

Also I went ahead and took a shot at this with the District of Columbia file to get you started.

CharlieS
17 - Castor
17 - Castor

@TravisR Awesome link! I didn't realize that was available!

 

@Reggie1995 Ok, here's what we do. At the github link above, if you scroll down, there's 50 states (plus D.C:) worth of .zip files you can download. If you download one and extract it, you'll get a .geojson file. Guess what? Alteryx's native text format for spatial objects is geojson, so this just takes one tool!

 

Steps 1: Download

Download the 51 files from the gitbub linked above. Extract the 51 .geojson files from each. This could be done with Alteryx, but let's stick to the spatial problem at hand. 

 

Step 2: Save as spatial objects

In the attached example, I input Colorado.geojson (that I already downloaded and unzipped), and use a select tool to change it to a spatial format so I can save a Colorado.yxdb (Alteryx file that saves the polygon).

 

Step 3: Spatial Match

Now that we have a spatial object, we can use it to match from centroids that you already have. Use a Spatial Match tool to find where the centroid you have falls within a building polygon.

 

Once you get the process above running, here's a few further tips:

- Combine all 51 .yxdb files into one, massive file. Then, In your spatial match tool, use the "Use Records from File or Database" in the tool configuration to input the master file path there. This will mean you don't have to load the entire file every time and the spatial indexing in the .yxdb file can be used, which makes it WAY faster.

- The spatial matching should probably be a multi-step process. 1) use a spatial match tool for when the point falls within a building polygon, then take the unmatched records and input those to a Distance to Nearest tool, for when the centroid is a door that lies just outside the building polygon, you'll match to the nearby polygon.

 

Let me know if you have any questions!

 

Reggie1995
8 - Asteroid

@TravisR @CharlieS 

 

This is awesome.  Thank you both.  Let me process what you sent through and take a look and apply to my case and then I will circle back tomorrow if I have any questions. 

Reggie1995
8 - Asteroid

Maybe I am missing something here, but can't seem to find the file download to get the 50 states for testing this method.  Can someone assist?

CharlieS
17 - Castor
17 - Castor

Sure thing.

 

Go to this link that was posted above: https://github.com/Microsoft/USBuildingFootprints

 

Scroll down until you see the list of states + D.C. click on each one, and a download for that file should begin:

20200526-GeoJSON.png

Reggie1995
8 - Asteroid

All - I think we got it.  So I used @CharlieS 's steps.  I then used a select tool and converted the identified polygon back to text to retrieve all of the points for that polygon and wrote those to the output file.  Really appreciate your help on this @TravisR @CharlieS .  Exactly what I was looking for.

 

Reggie1995_0-1590519628593.png

 

Labels