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.

 

Example

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.  

 

eg_import_geojson01_01.png

 

Choose File - Import.  

 

eg_import_geojson01_02.png

 

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

 

eg_import_geojson01_03.png

 

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

 

eg_import_geojson01_04.png

 

The Component panel of the Contents 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.

 

eg_import_geojson01_05.png

 

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.

 

eg_import_geojson01_10.png

 

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

 

eg_import_geojson01_11.png

 

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.

 

eg_import_geojson01_12.png

 

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.

 

eg_import_geojson01_13.png

 

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

 

eg_import_geojson01_14.png

 

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

 

eg_import_geojson01_15.png

 

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.

 

eg_import_geojson01_16.png

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.

 

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

 

eg_import_geojson01_17.png

 

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.

 

eg_import_geojson01_18.png

 

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.   

 

il_mouse_buttons.png

 

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.

 

eg_import_geojson01_19.png

 

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.

 

eg_import_geojson01_20.png

 

We zoom further into the view and then we use the Style panel of the Contents 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 panel provides controls for foreground color, fill color, symbology, and size for areas, lines and points, plus a rotation factor for point icons.

 

eg_import_geojson01_21.png

 

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.

 

eg_import_geojson01_22.png

 

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.

 

eg_import_geojson01_23.png

 

Back in the Style panel 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 by Alt-clicking the Map tab.

 

eg_import_geojson01_24.png

 

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

 

eg_import_geojson01_25.png

 

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.

 

eg_import_geojson01_26.png

 

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.

 

eg_import_geojson01_27.png

 

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.

 

 

eg_import_geojson01_28.png

 

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 panel 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.

 

eg_import_geojson01_29.png

 

In the Style panel 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.

 

eg_import_geojson01_30.png

 

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

 

Notes

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

 

Videos

yt_microsoft_json.png

 

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

 

See Also

Drawings

 

Tables

 

Style

 

Web Servers

 

File - Import

 

File - Create - New Data Source

 

GeoJSON / JSON