Example: Import from GPKG and Modify Geometry

This topic shows a simple, but typical, task involving spatial data.  We will take a country-sized data set in GeoPackage format, change all areas in the data to the boundary lines for those areas, and then place those boundary lines into a new drawing and table.  The topic seeks to illustrate every small step, including those an experienced user would find completely automatic and not worth mentioning.  

 

We will:

 

 

The data we would like to use comes in a GeoPackage (GPKG) format file.   

 

GPKG is the OGC GeoPackage format for storing vector and raster spatial data within an SQLite database container within a single .gpkg file.  As an interchange format, GPKG is a well-implemented, capable format that is clearly superior to older formats such as shapefiles.    See also the GPKG topic.

 

To fit into this documentation, illustrations show a small Manifold desktop, with only a few panes, docked to the right side.  In real life we use a much larger Manifold desktop, and more panes would be turned on, with panes docked to the left or to the right, or undocked, as we prefer.   Right-click a pane's tab to change where it is docked.  Manifold will remember that new arrangement for our next session.

Import spatial data from a GPKG file

Choose File - Import and then navigate to the folder where the GeoPackage file is, with an extension of .gpkg.   Note that the file we will use in this example is over one gigabyte in size.

 

 

Press Open.  The import may take a few tens of seconds on slower machines, since GPKG is a relatively slow format.  See the discussion on GPKG performance in the GPKG topic.

 

The file is imported as many tables, including a drawing and its table, seen in the Project pane below.   

 

 

 

 

The file was downloaded from the lris.scinfo.org.nz site in New Zealand. It shows what covers the land area of New Zealand by covering New Zealand with over 400,000 areas, each of which is classed into one of 43 different types of cover, such as pine forest, deciduous hardwoods, saltmarsh, urban parkland, built up area and other classifications.   

Simplify Project

In this topic we mostly will illustrate windows and panes as undocked. Undocked windows can be moved about on our Windows desktop and can be resized as we like, for example, to make them smaller to make smaller illustrations.   Shift-click the title tab or caption bar for a window or pane to undock or dock.

 

The project has many tables we do not need and will not use, so we will delete them to reduce clutter in the project.

 

 

 We highlight all components except the two we wish to leave, and then we press the Delete tool bar button.

 

 

Manifold raises a confirmation dialog, advising that many components will be deleted at once.   We can remove this confirmation dialog either in the Tools - Options dialog or by checking the Never show this again box.

Shorten Names

Our next step is to change the inconveniently long names used into something shorter.   If we are happy with the long name we can skip the following steps to rename the table and drawing.   But in the real world such a long name is likely to get on our nerves over time so we would probably change it to something shorter, as we will now do.

 

 

We right-click onto the long drawing name and choose Rename Related.

 

 

We double-click into the drawing name and enter landcover as the new name for the drawing, and then we press Enter.

 

 

We then double-click into the table name, which the dialog has already partially changed for us, and enter landcover Table as the new name for the table, and then we press Enter.

 

 

Press Rename.  The dialog will automatically update all properties within the drawing that reference the table to correctly use the new name of the table.  If the drawing had been used in any map or in a window, all such references would also be updated.

 

 

The new names appear in the Project pane.

 

 

We can now double-click the drawing to open it.

 

 

Seen zoomed out there are so many areas the display is mostly black.  

 

 

If we zoom in we can see there are very many highly detailed areas covering all of New Zealand.

 

 

In the Style dialog we choose a palette for the area background color, using Class_2012 as the field for thematic formatting (which gives a unique value for each area based on the land cover type in that area), and a method of unique values with 100 intervals.  We think there are only 43 different classifications in this table, but using 100 will make sure to get them all in case there are more than we think.  Pressing Tally will find all the unique values.  

 

We press the palette button to assign a palette we like, and then we press Update Style.

 

The actual palette used in the illustration above is the Land Cover palette in the Classic collection, used in reverse order.

 

 

The drawing updates to show thematic formatting based on the palette we used.   The palette provides reasonably green colors in areas that are intended to show forest and similar land cover.   We could tinker with the colors used, perhaps picking colors that are standard within New Zealand government cartography, if we liked.

Convert Areas to Lines

It is easy to convert the geometry of objects, for example, from areas to lines, by using the Transform pane.   The Transform pane provides a list of geoprocessing tools, called transform templates, or simply just transforms, that encapsulate SQL functionality in a point-and-click dialog.

 

With the focus on the opened landcover drawing window, we choose the Transform pane.

 

 

We choose the geom field as the subject, and then we double-click on the Convert template.  

 

We chose line as the Convert to option.   For the Result, from the pull down list we choose (new table), which will save the result into a new table and drawing.  We give the New drawing and New table names.  As we enter the name for the drawing, the pane will automatically fill in an analogous name for the table.   We can change that if we like.

 

Press the Preview button to get a preview of what will happen:

 

 

The drawing window shows a preview of what the transform will do, using blue preview color.   This is just a preview - no changes have been made to the drawing.

 

 

If we like what we see, we press the Transform button.   That applies the transform, changing all objects from areas to lines, as shown in the preview and saving the results into a new drawing and table.

 

 

The new drawing and its table appear in the project pane.

 

We can drag and drop the new landcover lines drawing into the same window as the landcover layer.

 

 

Using default formatting, the landcover lines layer does not standout, since the lines are the same as the boundary lines of the layer underneath.

 

 

We can double-click the landcover layer tab to turn off that layer.   That shows the landcover lines layer by itself.   In the illustration above, we have used the Style pane to set the width of lines in the landcover lines layer to 0.6 points, for a lighter look.

 

If we like, we can open the landcover lines drawing in its own window, to compare that to the landcover layer in its own window.

 

 

We double-click open the landcover lines drawing.  It opens up with the contents zoomed to fit.  

 

 

We can match the view in the landcover lines window to the view in the landcover window by using the Locations button, choosing the Windows option and then the landcover window as the window to match.

 

 

That instantly pans and zooms the view in the landcover lines window to be the same as the view in the landcover window.

 

 

The illustration above shows the landcover drawing for comparison.  We have turned off the landcover lines layer and turned on the landcover layer.

 

Another way to compare the landcover lines layer with the landcover layer is to show them together in the same window, but to style the landcover lines layer in a contrasting color and width so it stands out.

 

 

For example, in the illustration above we have colored the lines in the landcover lines layer a bright blue, making them thicker than the boundary lines of areas in the landcover layer below.  We have also used the Layers pane to set 50% opacity for the landcover lines layer, so the area boundary lines in the layer below can be seen through the upper layer.

 

 

Zooming in, we can see that the lines created in the landcover lines layer are exactly the same as the area boundary lines in the landcover layer.

 

The lines in the landcover lines layer have also inherited all the attributes of the areas from which they were created.

 

 

For example, we can thematically format the color of the lines in the landcover lines layer using the same field and style options that were used for the landcover layer.

 

In the illustration above, we have used the Layers pane to set a black background for the landcover lines window.  That allows the colored lines to appear more brightly and distinctly than they would against a default white background.

 

 

The Style pane settings used for the thematic format are seen above.  They use the same Class_2012 field with the same palette as were used for the thematic formatting of area fill color in the landcover layer.

 

See Also

Queries

 

File - Create - New Data Source

 

Command Window

 

GPKG

 

Example: Create a New Data Source from a MAP File - Create a new data source from an existing Manifold .map project file.   This is the classic way to nest projects, one calling another, to create libraries of data and projects.   Access to nested projects has effectively zero performance loss and the links within projects take up effectively zero space so we can create huge constellations of data at our fingertips.

 

Example: Create and Use New Data Source using an MDB Database - This example Illustrates the step-by-step creation of a new data source using an .mdb file database, followed by use of SQL.  Although now deprecated in favor of the more current Access Database Engine formats, .mdb files are ubiquitous in the Microsoft world, one of the more popular file formats in which file databases are encountered.  

 

Example: Create and Run a Query - See how the different parts of a command window operate when creating and running SQL queries.   Includes use of the Log tab as well as the ?expression and !fullfetch commands.

 

Example: Automatically Generating CREATE Queries - How to use the Command window to automatically generate SQL in the form of CREATE queries that create a desired component.

 

Example: Clip Areas with a Transform Expression - Use the Expression tab of the Transform pane to clip areas in a drawing to fit within horizontal bounds.   Includes examples of using the Add Component button and also the Edit Query button.

 

Example: Link GPKG and Save Style - A companion topic to the GPKG topic.   How to link a GPKG, open a drawing, Style it and then save so the styling is retained within the GPKG file.