Example: Detecting and Correcting a Wrong Projection

In this example we explore projection dialogs and a classic coordinate system problem. T  We save a drawing into projected shapefiles and then show on import how a projection can be quickly and easily checked and corrected if it is wrong. The terms projection and coordinate system are used as interchangeable synonyms in Manifold.   The more technical dialogs tend to use the term coordinate system, while in casual use we often say projection

 

This is a long example which combines several different activities.   There are five major parts to this example.

 

 

 

 

 

 

There are many illustrations to cover virtually every small step.  With only a bit of experience Manifold users will not think twice about the small steps but to help beginners all steps are illustrated here.

Create example data

We start with our sample drawing that shows provinces in Mexico as areas.

 

 

eg_check_proj01_01.png

 

To see what coordinate system the drawing uses we click on the Contents pane.

 

 

eg_check_proj01_02.png

 

The Contents pane shows the Mexico drawing use the Latitude / Longitude coordinate system.

 

 

eg_check_proj01_03.png

 

 

We will now export the drawing into ESRI shapefile format.  Choose File - Export to launch the Export  dialog.

 

 

eg_check_proj01_04.png

 

We choose a File name of MexLatLon to remind us that we are exporting Mexico in Latitude / Longitude projection, and we choose SHP Files in the Save as type box.  Press the Save button.

 

eg_check_proj01_05.png

 

If we use Windows Explorer to take a look at the files created we see that five files were created by the export process.   

 

An ESRI "shapefile" is actually a minimum of three files that have .shp, .dbf and .shx extensions.  Although the ESRI shapefile standard mentions no way of saving projection information, an informal standard of using a fourth, .prj, file has arisen over the years.  Use of .prj files has become so widespread that many, but not all, applications will write an accessory .prj files to specify the projection used together with the three shapefiles described by the ESRI standard.  Manifold writes a .prj file as well.

 

In addition,  Manifold creates a fifth file, the .mapmeta file, to save projection information in a highly detailed form for the use of other Manifold applications. See the Accessory Files Created topic and the Shapefiles Strangely Out of Shape topic.

 

If shapefiles are written with a .prj file that follows accepted conventions then those shapefiles will be easy to import into almost any GIS package that reads shapefiles and understands .prj conventions.   Unfortunately, not all applications write .prj files and there are millions of shapefiles floating around in the world's spatial data archives that were created without .prj files.   This topic is all about how to handle such files.   

eg_check_proj01_06.png

 

Since this example is intended to show what happens when working with shapefiles that do not have a .prj attached, we will perform a quick spatial lobotomy by highlighting both the .prj file and the  .mapmeta file and then pressing the Delete key.  

 

eg_check_proj01_07.png

 

Now we have a triplet of shapefiles, exactly as they might be encountered in some random download from the web with not a hint of what projection they may use.   Because we created them by exporting a drawing of Mexico in Latitude / Longitude projection, we know these shapefiles use Latitude / Longitude projection.  But without a .prj file or, for Manifold users, the .mapmeta file, there is no way for an application to know that automatically.

Change the Projection of the Mexico Drawing

We will now change the projection of the Mexico drawing to some other projection.    We will then export it again to a shapefile so that we will have a second shapefile for Mexico, but using a different coordinate system than the MexLatLon shapefiles.

 

btn_coord_sys_picker.pngTo change the projection of the Mexico drawing, in the Contents pane we click on the coordinate system picker button in the main menu. and choose Change Coordinate System.

 

eg_check_proj01_08.png

 

That launches the Change Coordinate System dialog.   

 

 

eg_check_proj01_09.png

 

 

btn_coord_sys_picker.pngWe click that dialog's coordinate picker button and in the resulting menu we choose the Pseudo-Mercator projection from the favorites list the menu offers.  This is the same projection that Manifold, ESRI's ArcGIS Pro, Google, Microsoft and virtually all web servers use as a default projection.

 

Two favorites are built into Manifold and we can easily add more if we like.   See the Example: Adding a Favorite Coordinate System to learn how to add a coordinate system to the Favorites system.  

 

eg_check_proj01_10.png

 

That sets the Pseudo-Mercator coordinate system as the intended New system.   We press Update Component to re-project the drawing into Pseudo-Mercator.

 

 

eg_check_proj01_11.png

 

The result is not exactly what we expected, as Mexico disappears. That happens sometimes when switching between significantly different coordinate systems, as the viewport for the drawing window may need to be reset for the new projection.  We press Zoom to Fit  to get it back.  [And yes.. that's on the wishlist to improve in an update soon.  For now, just hit Zoom to Fit after doing a re-projection.]

 

 

eg_check_proj01_12.png

 

That's better.   Some projections will show a visibly different display when a drawing is re-projected, but at the latitude of Mexico there is not much visual difference between a Latitude / Longitude projection of Mexico and the Pseudo-Mercator projection.

Export to a Shapefile

Once again we will export the Mexico drawing to a shapefile.  This time, what we are exporting is in a different projection, the Pseudo-Mercator projection.

 

 

eg_check_proj01_13.png

 

 

As before, we choose File - Export in the main menu.

 

eg_check_proj01_14.png

 

In the Export dialog we choose a FileName of MexPsMerc, intending that to remind us later on this file contains Mexico in Pseudo-Mercator projection.   We choose SHP Files as the type and press Save.

 

eg_check_proj01_15.png

 

In Windows Explorer we see that five additional files have been created.   As before, we delete the .prj and the .mapmeta files to remove all projection intelligence from the shapefiles.

 

eg_check_proj01_16.png

We now have two different sets of shapefiles that contain the Mexico drawing.  One of them has Mexico in Latitude / Longitude projection and the other set has Mexico in Pseudo-Mercator projection.   Neither of the shapefiles has any information stating what projection is used, other than, of course, the names we chose to use to remind ourselves which is which.

Create a Google Data Source

We will now create a map with a reference layer that has a "known good" projection.   We will use a Google imageserver following the same procedure covered in the Example: An Imageserver Tutorial topic.

 

In the main menu we choose File - Create...

 

 

eg_check_proj01_17.png

 

We click New Data Source to launch the New Data Source dialog.

 

eg_check_proj01_18.png

 

From the seemingly endless list of data sources in the Type box's pull down list, we choose Web Server: imageserver and then in the box just below that we choose Google Maps Satellite from the long list of imageservers built into Manifold.  Press Create Data Source.

 

 

eg_check_proj01_19.png

 

That creates a new data source in the project pane, which we can expand to see within it the Google Maps Satellite Image the data source provides.

 

Create a Map

We right-click into the Project pane and in the context menu choose New Map.

 

eg_check_proj01_20.png

 

 

We use defaults to create the new map, clicking OK in the dialog (not shown).  That creates a new map in the project pane.

 

We double-click the map open and then drag and drop the Google Maps Satellite Image component into the map.

 

 

eg_check_proj01_21.png

 

 

We press Zoom to Fit to see the entire world in Google.  That's Pseudo-Mercator projection, by the way, that Google uses.

 

 

eg_check_proj01_22.png

 

We zoom into a region that shows the Southern portion of the North American continent, about where we reckon Mexico is located.  

Import Shapefiles

We now will make use of the example shapefiles we created earlier.

 

eg_check_proj01_23.png

 

Choose File - Import to launch the Import dialog.

 

eg_check_proj01_24.png

 

To reduce visual clutter in the Import dialog  we choose the SHP Files (*.shp) setting to show only the .shp files.   We click on the MexPsMerc.shp file and then we click Open.

 

 

eg_check_proj01_25.png

 

A new MexPsMerc drawing and its table appear in the Project pane.   

 

We will now choose Edit - Import again and import the other shapefile.

 

eg_check_proj01_26.png

 

In the Import dialog we click on the MexLatLon.shp file and then we click Open.

 

 

eg_check_proj01_27.png

 

A new MexLatLon drawing and its table appear in the Project pane.

A Lucky Import

We will now display the new MexPsMerc drawing by double-clicking on it to open it in a drawing window.

 

 

eg_check_proj01_28.png

 

 

It appears to look OK.   There is nothing about the display which immediately would tell us whether the initial coordinate system for this drawing was correctly assigned.  To see what coordinate system was assigned we click on the Contents pane tab.

 

 

eg_check_proj01_29.png

 

 

The Contents pane reports that this drawing is in Pseudo Mercator coordinate system, using red text to advise us that Pseudo Mercator has been assigned only as a placeholder, since the originating data source did not specify what coordinate system to use.  

 

Experienced GIS operators at this point will know the above is a matter of dumb luck, because they know very well that shapefiles by themselves provide no coordinate system information at all.  There is nothing whatsoever about the MexPsMerc.shp file that tells any software what coordinate system the data within utilizes, let alone that the data is computed for the Pseudo Mercator coordinate system.   How did Manifold know that the contents of the MexPsMerc.shp file were in Pseudo Mercator coordinate system?  

 

Manifold did not know what coordinate system was in the file.   When Manifold imports a file that comes with no coordinate system information Manifold simply assigns the default coordinate system, which happens to be Pseudo Mercator coordinate system.    When importing the MexPsMerc.shp file Manifold received no coordinate system info from the shapefile so Manifold assigned the default Pseudo Mercator coordinate system.   In this case by pure coincidence that happens to be the right coordinate system.

 

eg_check_proj01_29a.png

We created the shapefile that was imported, so we know in this rare case coincidence has worked out.  We may as well take this opportunity to verify this import as OK.   In the Contents pane we click the coordinate system picker button, choose Assign Initial Coordinate System, the only choice for a coordinate system that is a provisional placeholder, and then we choose the Pseudo-Mercator coordinate system from the list of favorites.

 

 

eg_check_proj01_29b.png

 

 

The coordinate system read-out in the Contents pane switches to using black text to show the coordinate system has been assigned and is no longer just a provisional placeholder.   

 

 

eg_check_proj01_30.png

 

We can confirm the initial coordinate system has been correctly assigned by dragging and dropping the MexPsMerc drawing into the map.    In the illustration above we have closed the other open drawings to reduce clutter.

 

 

eg_check_proj01_31.png

 

Like magic, the MexPsMerc drawing appears exactly where Mexico should be.

An Unlucky Import

So now that we know that dumb luck is good to have on our side when importing shapefiles we will see if our luck holds with the other shapefile, which contains Mexico in Latitude / Longitude coordinate system.  

 

We begin by right clicking on the MexPsMerc layer tab in the map and choosing Delete from map.  This will remove the layer from the map so that we can clearly see what happens when we drag and drop the MexLatLon layer into the map.

 

 

eg_check_proj01_32.png

 

 

First, we double-click on the MexLatLon drawing to open it in a drawing window.

 

 

eg_check_proj01_33.png

 

It appears OK as well.  tech_angus_sm.png

 

Tech Tip:  This is how toxic data gets imported into workflow.  The drawing seen above has the wrong coordinate system assigned, but when opened in its own drawing window it looks perfectly OK.  Only when it appears as a layer together with correct data will it be seen to be in error.    If we do not catch the error now we risk using this drawing to create other drawings, proliferating the error into our workflow and into our archives.  Ultimately, if we publish the data we might even end up contributing to the world's growing inventory of junk data.    This topic will show us how to avoid doing that.

 

We will see what coordinate system has been assigned to this drawing by seeing what the Contents pane reports.

 

 

eg_check_proj01_34.png

 

As before, the Contents pane reports that this drawing is in Pseudo Mercator coordinate system, using red text to advise us that Pseudo Mercator has been assigned only as a placeholder, since the originating data source did not specify what coordinate system to use.  

 

We know that the initial coordinate system assigned as a provisional placeholder is wrong, because the drawing we exported into that shapefile used Latitude / Longitude coordinate system.  But because we removed the .prj and the .mapmeta files that reported the coordinate system used by the shapefile there is no way for any GIS software to know what that shapefile contains.

 

We know what the drawing is supposed to use as a coordinate system because we created the drawing.   But suppose we did not create it?   Suppose we downloaded the drawing from some random web site or suppose we created it a long time ago and forgot what coordinate system we used?    In that case we might look at what seems to be a perfectly good display in the drawing window, check the current coordinate system in the dialog and decide that the drawing was correctly imported using Pseudo Mercator, ignoring the red text that warns us the provisional initial assignment of coordinate system may be incorrect.

 

An easy way to see if the initial coordinate system has been correctly assigned is to compare the drawing to a known good layer.  We will do that by adding it to our map with the Google layer.

 

 

eg_check_proj01_35.png

 

We drag and drop the MexLatLon drawing into the map.   

 

 

eg_check_proj01_36.png

 

Nothing happens.   Nothing appears because the drawing has the wrong initial coordinate system, so when Manifold interprets the data within the drawing based on the provisional, placeholder initial coordinate system the drawing is said to use, Pseudo Mercator, the data does not appear in the right place.

 

 

eg_check_proj01_37.png

 

 

In fact, the drawing appears as a nearly microscopic dot off the coast of Africa at the (0,0) intersection of the Prime Meridian (zero longitude) with the Equator (zero latitude).  If we zoomed far, far in we would see a tiny rendition of Mexico a few meters wide by a few meters tall.    Pseudo Mercator coordinate system uses meters as degrees of measure so the coordinate numbers in a Latitude / Longitude coordinate system, which are geographic degrees result a drawing only a few meters in dimension, with all of the meter numbers within a few meters of the (0,0) intersection.

 

Lucky for us, it is trivially easy to assign the correct initial coordinate system if we know what it is supposed to be.    We will assign the Latitude / Longitude coordinate system as the initial coordinate system.

 

eg_check_proj01_38.png

 

In the Contents pane we click the coordinate system picker button, choose Assign Initial Coordinate System, the only choice for a coordinate system that is a provisional placeholder, and then we choose the Latitude / Longitude coordinate system from the list of favorites.

 

eg_check_proj01_39.png

We know that this particular drawing uses the Latitude / Longitude coordinate system, which just happens to be one of the two default Favorites built into Manifold.    If the drawing used some other coordinate system we could choose Edit Coordinate System to launch the full Coordinate System dialog that would allow choosing any of thousands of different coordinate systems or specifying a custom coordinate system.

 

 

eg_check_proj01_40.png

 

Like magic, Mexico appears where it is supposed to be now that the correct initial coordinate system has been assigned to the drawing.  The Contents pane now reports Latitude / Longitude in black text as the assigned coordinate system.  We have also taken a moment to Style the drawing with colors, to create a more visually appealing display.

 

Notes

Synonyms -  The terms projection and coordinate system are used as synonyms by Manifold.  Cartographers favor the term projection while programmers seem to prefer coordinate system.  This documentation uses the two terms interchangeably, with the term projection tending to be used more in GIS or display contexts and the term coordinate system tending to be used more when discussing programming, SQL or standards.

 

Detective work - In this case because we created the shapefiles we knew that MexLatLon used Latitude / Longitude  coordinate system, so we could immediately and confidently assign that as the correct initial coordinate system.   But suppose we got the shapefile from some random web site and we didn't know what coordinate system it is supposed to use?  In that case we would usually first try Latitude / Longitude anyway as a guess.   If that did not work we would hunt through whatever website provided the shapefile to see if somewhere on the site we could find an explanatory note or some sort of metadata document that says what coordinate system is used.  

See Also

Contents Pane

 

Coordinates

 

Assign Initial Coordinate System

 

Change Coordinate System

 

Map Projection

 

Coordinate System

 

Base Coordinate System

 

Favorite Coordinate Systems

 

Favorite Base Coordinate Systems

 

Style

 

Example: An Imageserver Tutorial - An extensive tutorial showing step by step how to add new data sources that are imageservers, how to show them as layers in a map, how to create a new drawing that matches the projection of the map and how to trace over what is seen in an imageserver layer to create an area object in the drawing.

 

Example: Assign Initial Coordinate System - Use the Contents pane to manually assign an initial coordinate system when importing from a format that does not specify the coordinate system.

 

Example: Change Projection of an Image - Use the Change Coordinate System command to change the projection of an image, raster data showing terrain elevations in a region of Florida, from Latitude / Longitude to Orthographic centered on Florida.

 

Example: Adding a Favorite Coordinate System - Step by step example showing how to add a frequently used coordinate system to the Favorites system.

 

Re-Projection Creates a New Image - Why changing the projection of an image creates a new image.

 

About Coordinate Systems

 

Projections Tutorial

 

Shapefiles Strangely Out of Shape

 

Accessory Files Created