Example: Import GeoJSON / JSON File

In this example we use Manifold's GeoJSON / JSON dataport to import vector footprints for all buildings in the District of Columbia, using a GeoJSON file published as open data by Microsoft.


Microsoft has recently published vector footprints of over 125 million buildings in the US in GeoJSON format under the Open Data Commons Open Database License (ODbL). However, Microsoft's files all use the .json file name extension instead of .geojson.   Manifold's GeoJSON dataport automatically reads GeoJSON format files that utilize either the  .json file name extension or the .geojson file name extension.  This makes it easy to use Microsoft's new data set without the need to manually rename files. tech_angus_sm.png


Important: The GeoJSON dataport's limitation to 2 GB of text currently disallows use of Microsoft's Texas and California files, both of which are larger than 2 GB as GeoJSON text.    This limitation will be removed in upcoming builds, allowing use of these and other GeoJSON files that exceed 2 GB.


We will import a .json file that provides vector footprints of buildings in the District of Columbia.  This is part of the collection of all US building footprints recently published as open data by Microsoft on their US Building Footprints page on Github.    Microsoft publishes files as .zip files.  Unzip the file to get the .json file.  




Choose File - Import.  




Navigate to the desired .json or .geojson file and double-click it.




The file imports as a drawing and the drawing's table.   Double-click the drawing to open it.  




The Component pane shows the drawing has been correctly imported with the specified Latitude / Longitude coordinate system correctly assigned.   We can see from the Status Bar's Scale and Position readouts the drawing is correctly positioned and scaled.




Back in the Project pane we can double-click open the drawing's table. We can see that this particular data set from Microsoft has only one field, the geometric shape for each vector object, all of which are areas.

Create a Map with a Bing Background

In principle, this example is done in that we have imported a .json file provided by Microsoft.   But more interesting is using the drawings to create more useful displays.   We will next create a map and we will create two web server layers that can provide cool backgrounds from Microsoft's Bing satellite and street map servers.




We create a new map by choosing File - Create - New Map.




Accept defaults and press Create Map.

Create Web Server Layers

Next, we will create two data sources that provide layers from Microsoft's Bing servers.




Manifold provides access to an endless range of web servers.  Several are hosted by default as favorites, with the ability to add whatever additional favorites we want.  For convenience, we will use two of the default favorites.   We add a Bing street map layer to the project by choosing File - Create - New Favorite Data Source - Bing Maps Street Map.




Next, we add a Bing satellite image layer to the project by choosing File - Create - New Favorite Data Source - Bing Maps Satellite.




We open the Map by double-clicking the Map component in the Project pane.  




The Map component opens as a blank window since it does not yet have any layers.   We expand the Bing Maps Street Map data source hierarchy and then we drag and drop the Bing Maps Street Map Image into the map.



It immediately appears in the map, zoomed to fit and showing the entire world.   


ico_nb_arrow_blue.png  Maps take their projection from whatever is the first layer added to the map.   We wanted our map to be in Pseudo-Mercator projection, as used by Bing, so we dragged and dropped the Bing streets layer into the map first.

Add the Imported Drawing to the Map

Next, we drag and drop into the map the DistrictofColumbia Drawing that we imported from the .json file.




Since the map is zoomed to the entire Earth, the District of Columbia appears as a dot on the East coast of the US.  To zoom to the extents of the District of Columbia drawing, we can Ctrl-click on the layer's tab, a convenient short cut.  We could also have right-clicked on the tab and have chosen Zoom from the context menu to zoom to fit that layer.




Right away, the map zooms to fit the District of Columbia drawing.  The Bing streets layer automatically fills in with more detailed tiles served by Microsoft's Bing server.   We right-click and drag to draw a zoom box, to zoom to that box.   




ico_nb_arrow_blue.png  Basic navigation:  the default mouse mode in Manifold is navigation.  Using the left mouse button we can click and drag to pan the display.  Using the right mouse button we right-click and drag to draw a zoom box to zoom to that box.   The wheel on a wheel mouse zooms in and out.




Zoomed further into the view we see that the drawing imported from the .json shows building footprints as areas, displayed in default, gray formatting.

Style the Drawing

We can create a more appealing and more legible display by coloring areas in the District of Columbia drawing.




We zoom further into the view and then we use the Style pane to choose a blue color for fill color for areas.   Some GIS packages allow only a single object type, such as only areas, in a layer.  Manifold allows a mix of areas, lines and points in drawings, so the Style pane provides controls for foreground color, fill color, symbology, and size for areas, lines and points, plus a rotation factor for point icons.




We can add the satellite layer to the map as well.   We first click the Bing streets layer tab to make that the active layer,  When next we drag and drop the Bing satellite image into the map it will appear as a layer above the active layer.




Manifold automatically pulls tiles from the Bing satellite server to fill the view.    To better see how building footprints align to buildings that are visible in the satellite photo view, we can change the style used to show areas.




Back in the Style pane we change area foreground color, used for area borders, to bright green.  We change area fill color to transparent color, indicated by a hatch pattern.    The result is that areas appear only as bright green outlines with no fill color.


To get a larger display, to make better use of the small screenshot sizes used in this documentation, we can undock the map window.  Shift-click the title tab for a window or a pane to undock it.




 Much better!   We can now move and resize the undocked map window, to get a bigger view of what is in the map.




Zooming in we can see alignment is not bad but is not perfect.  The image above applies a hash pattern to the areas.   Microsoft created the vector data set of building footprints by grinding the entire US database of Bing images through a neural network, using AI techniques to find buildings and to then clean up the resultant polygons.




A few minutes of looking about in the District of Columbia indicate numerous errors.   For example, the scene above shows the region near the Washington Monument.




Zooming into the WWII memorial we see the automated process identified part of the reflecting pool between the monument and the Lincoln Memorial (out of view to the left) as a building.  The process also identified parts of the plaza as buildings.





The process also identified buildings in open grassy areas in the park to the South, although it correctly located one building in the view above.

More Colorful Style

If we like, we can use the Style pane to do a thematic format to apply many colors to the drawing.   The following technique depends on having an mfd_id key field and index in the drawing.  Current builds that import GeoJSON do not automatically add an mfd_id index.  This will be added soon, given that GeoJSON might become popular as an interchange format.  In the interim, it takes but a moment to add an mfd_id key field and index to the drawing's table as described in the Add an Index to a Table topic.




In the Style pane we add a thematic format using the mfd_id field as seen above.  We use a method of equal intervals, tallied to 16 breaks.  We have applied the CB Paired palette, one of the fine Color Brewer palettes available by default with a point and click.




The result is a more colorful display of building footprints in the District of Columbia.  



Download Microsoft's Data - We can download Microsoft's data from their US Building Footprints page on Github.   Thank you, Microsoft!





See the video version of this topic in the Manifold 9 - Microsoft JSON Building Footprints video.


See Also







Web Servers


File - Import


File - Create - New Data Source