I use a Web Mercator tileset as a convenient base map for my sites. I've fixed measurements in the viewer by using a measurement projection, but when I print a map the scale bar and map scale are incorrect. How can I fix this?
We can take advantage of the fact that in a local area the difference between a correct measurement of distance in a locally conformal projection and an incorrect measurement in Web Mercator is close to a constant ratio. This ratio will of course vary continuously around the world, but as long as you do not leave the valid boundaries of your local conformal projection, it will be close enough for quick measurements and back-of-napkin calculations using a printed map.
There are two steps to this solution. First, you must determine the correct ratio to use for your local area, then you must use calculated fields in your print templates to fix the scale numbers in the printed maps.
Step 1: Find the correct ratio to use
- For any particular latitude the scale of the Web Mercator projection and the actual measurement is proportional to the secant of the latitude. Since the secant is equal to 1/cos, you can multiply any measurement by the cosine of the latitude and get a fairly accurate value back. How accurate this value is will depend on how much the latitude changes along the length being measured. If it does not change much at all, this measurement will be quite accurate (source: https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor)
- For example, for a latitude of 49ºN the ratio between actual and correct measurements will be equal to cos(49º) or 0.65605902899. Put another way, all measurements in Web Mercator made at this latitude are approximately 152.42% bigger than they should be.
Note: Google can help you do the math here, but make sure you search for 'cos(49 degrees)' or it will calculate the answer in radians.
Step 2: Modify your Print Template(s) to correct the values it is sent by Essentials
- Open the print template in Report Designer. On the scale bar, look for the field that will contain the scale bar distance value. It will have a DataField value of _ScaleBarDistance. This is a special field sent by Essentials to the print template, and we will use it to calculate the correct values:
- A quirk of Active Reports is that, in order to use a field to make another calculated field, the original field _must_ be included somewhere in the report. Since we don't actually want to see original value we are going to have to hide it. Right click the field, copy it, and drag the copy onto the main map area. Right click the copy and choose 'Send To Back'. It will no longer be visible when the map is printed.
- In the top right of Report Designer you should see a 'Fields' element. Expand this, and right click on 'Calculated'. Add a new calculated field.
- Fill out the parameters that appear in the bottom right as follows:
- (Name): _CorrectedDistance
- FieldType: Double
- Formula: _ScaleBarDistance * 0.656 <-- use your actual calculated value here from above, not this one.
- Now modify the configuration of the 'HalfDistanceCalc' field to use your new calculated field:
- (Name): HalfDistanceCalc
- FieldType: Double
- Formula: _CorrectedDistance / 2
- Map scale has a similar issue to the scale bar, as the scales reported by WebMercator are only correct along the Equator. You'll find this field on the right of the template below the legend, and if you click on it you'll see that it is using the special DataField _MapScale. Fix this value with another calculated field, first copying and hiding the original _MapScale textbox as above.
- (Name): _CorrectedMapScale
- FieldType: Double
- Formula: _MapScale * 0.656
- Finally, alter the 'DataField' values from the original textboxes to reflect the new calculated field values: _CorrectedDistance and _CorrectedMapScale. Note that there are two 'Distance' text boxes that need fixing on the scale bar, one on the left and one on the right.
Your printed map will now have a scale bar and scale, that while only roughly correct, will be good enough to make quick calculations and estimates that are not wildly off. If working at the scale of a neighborhood or small municipality you can expect that the values will be good to at least one or two decimal places.
Be sure to remember though that this print template is now 'hardcoded' to only work in a certain area. If it needs to be used in the area of a different local coordinate system the above calculations will need to be redone.
Article is closed for comments.