I'm working on processing some geo-spatial raster data, JOG-A raster to be exact, and know the imagery is supposed to be to a scale of 1:250000. However I would like to calculate this in code but am not coming up with the correct values.
Here are the bounds of a single image and other values needed for calculations. (coordinates are in degrees, EPSG:4326)
Meters Per Degree: 111319 Image Size: x: 1536 y: 1536 DPI: 90 Upper Left: Longitude: -89.5431 Latitude: 33.6529 Upper Right: Longitude: -88.8578 Latitude: 33.6529 Bottom Right: Longitude: -88.8578 Latitude: 33.1351 Bottom Left: Longitude: -89.5431 Latitude: 33.1351
I thought I could say
(degLatA - degLatB) * meterPerDeg / imageSizeY * dpi / 0.0254 33.6529deg - 33.1351deg = 0.5177deg $1 deg * 111319m/deg = 57634m $2 m / 1536px = 37.52m/px $3 m/px * (90px/in * 1in/0.0254m) = 132953
which gives a scale of 1:132953 ... not even close! The units all cancel great, but as you can see from the calculation, the value is not even close to 250k.
Can anyone explain where I'm wrong?
EDIT: The math for calculation is all correct, I just needed the correct DPI which for CADRG imagery is 169 according to the SPEC documents. (buried on page 10 if you want to verify or read for yourself).