0

I added a Google hybrid tiles layer in my QGIS project. I set the project CRS from this layer. I then exported an image of KRZL runways.

$ file KRZL.png
KRZL.png: PNG image data, 245 x 412, 8-bit/color RGBA, non-interlaced

Vertically, the image just captures runway 18/36 which is 4000 feet or 1219 m long. I measured it in QGIS to verify this.

KRZL runways

Knowing the runway length, I calculate (1219/412) that each pixel represents just under 3 meters (vertically, at least).

$ cat KRZL.pgw
3.91571999999637521
0
0
-3.91571999999637521
-9705942.66393999941647053
5005478.73730999883264303

How can I accurately calculate the meters/pixel from this data instead of using a known reference? At first, I naively assumed that yscale (-3.91571999999637521) was what I wanted, but obviously it's substantially different.

(My end goal is to automate importing such images in FreeCAD. For that, I need to know the image's size in meters.)

3
  • If your image is accurately georeferenced, you could just zoom in and measure the x and y dimensions of a single pixel, right?
    – Kartograaf
    Commented Feb 2, 2022 at 17:15
  • what if you run gdalinfo -stats on your image
    – nmtoken
    Commented Feb 2, 2022 at 17:44
  • You are right that the first and third rows of the world file tell the pixel size in the units of the corresponding coordinate system. That is often stored into .prj file or then you just need to know the system. The pixel size on ground can be different due to distortions caused by the projections. QGIS knows how to convert the lengths but you may need to re-project the image into some other coordinate system if you want to use it with a projection unaware software.
    – user30184
    Commented Feb 2, 2022 at 17:59

1 Answer 1

2

World files don't include a projection, so it's better to do the conversion in QGIS. Set the project CRS (Project -> Properties -> CRS) to an appropriate UTM Zone. In this case, it's WGS 84/UTM Zone 16N EPSG:32616.

Export the image (Project -> Import/Export -> Export Map to Image).

$ file KRZL.png
KRZL.png: PNG image data, 311 x 522, 8-bit/color RGBA, non-interlaced

$ cat KRZL.pgw
2.34732279693529389
0
0
-2.34732279693529389
484005.87236647499958053
4533608.77363860141485929

Using the xscale/yscale from the World File, calculate the size of the image.

In [1]: 2.34732279693529389 * 311
Out[1]: 730.0173898468764

In [2]: 2.34732279693529389 * 522
Out[2]: 1225.3025000002235

In FreeCAD, use the Image workbench to Create a planar in the 3D space. After loading the image, select it in the model. Change XSize and YSize to be the sizes calculated above (730.02m, 1225.30m).

Now you should be able to make sketches on the image with (reasonably) correct dimensions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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