Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Let's suppose you have a raster dataset (in a folder or in a personal database). How can you detect what map scale it represents (assuming of course that all rasters have same dimensions/resolution)?

Mind you, I want to have this info WITHOUT having to show the rasters on the map before.

EDIT:

Based on Matthew Snape's post, I have come to the following code that works satisfactory. The only thing that I have still hard time to get is the raster's dpi. Is there any hope to find this information embedded somewhere in the db?

public void GetDatasetMapScale(string datasetPath, out double scale)
{
     var _gp = new Geoprocessor();
    _gp.SetEnvironmentValue("workspace", datasetPath);
     var rasters = _gp.ListRasters("", "");
     var raster = rasters.Next(); // get first raster from dataset

     object dt = "";
     var rasterElement = (IDERasterBand) _gp.GetDataElement(raster, ref dt);
     var meanCellHeight = rasterElement.MeanCellHeight;
     var meanCellWidth = rasterElement.MeanCellWidth;

     var myCellSize = (meanCellHeight + meanCellWidth) / 2;
     var dpi = 300; **// HOW CAN DETECT THIS?????**
     var METERS_PER_INCH = 0.0254;

     scale = (dpi * myCellSize) / METERS_PER_INCH;
}

Thanks in advance

share|improve this question

2 Answers 2

up vote 5 down vote accepted

A lot of rasters are designed with a particular scale in mind, which you can't detect without metadata describing that fact. However, it is possible to estimate scales that a raster could be printed/displayed at based on a minimum density of cells in the output medium.

If the DPI of the raster when displayed is to small the raster may be inappropriate for that scale as it lacks sufficient detail. This can be calculated with the following equation:

scale = (dpi * resolution)/0.0254

This assumes that the resolution is measured in metres and gives a scale as the ratio of distance in the world to distance on the map. The value 0.0254 is the number of metres in 1 inch and allows us to specify the density in dots per inch while giving unitless output.

In ESRI you can calculate this using the following (setting a min DPI of 150):

import arcpy
from arcpy.sa import *
elevRaster = Raster(r'raster.tif')

myExtent = elevRaster.extent
myCellsize = (elevRaster.meanCellHeight + elevRaster.meanCellWidth) / 2
mindpi = 150

scale = (mindpi * myCellsize) / 0.0254
share|improve this answer
2  
What does 0.0254 represent? –  Kirk Kuykendall Nov 1 '11 at 13:52
3  
This has the ingredients of a great answer, but it needs to disclose its assumptions (the key one is that grid cellsize is measured in meters); it needs to perform a units analysis (to show where 0.0254 comes from); and it needs to be clear about what "scale" means. The formula as given is actually the reciprocal of the scale in its usual sense (as the ratio of distance on the map to distance in the world, such as 1:25000). –  whuber Nov 1 '11 at 14:16
    
Updated to include Whuber's comments. –  Matthew Snape Nov 1 '11 at 15:23
2  
+1 I took the liberty of polishing your updates: you still compute the inverse scale and your answer is unitless (as it should be), not in meters. Check: inch^(-1) * meters / (.0254 meters/inch) = no units. Another check using realistic values: 150 dpi * 10 meters / (.0254 meters/inch) = 59,055 = 59055:1 is clearly a ratio of world distance to map distance, not the other way around. –  whuber Nov 1 '11 at 15:50
    
This is a good approach, the only parameter I have hard time to get is the dpi. Is there any chance I get the dpi from a geodatabase raster dataset? Is this information somewhere available? –  Exile79 Nov 2 '11 at 12:21

Deepening on the mapping Cartographic Representations design, you may be able to use the presence of a colour or shape that is only used on a given scale. (E.g. for UK OS Maps, 1:50K does not have some of the symbols that 1:25K maps have)

share|improve this answer
    
Interesting and creative idea (+1). Note, though, that images have colors, but raster datasets usually do not. –  whuber Nov 1 '11 at 15:52
    
For cartographic mapping you could also measure the amount of variability in color to determine the quantity of information in a given area. So very dense information is more appropriate at large scale, and harder for the viewer to understand at small scale. Another good marker would be text size using OCR. –  Matthew Snape Nov 1 '11 at 16:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.