I've searched already everywhere but couldn't find anything. I have a "polar stereographic projection" map that is true at 60 degrees latitude north as an image (e.g. https://flightplanning.navcanada.ca/Latest/gfa/anglais/produits/uprair/gfa/gfacn31/Latest-gfacn31_cldwx_000.png). I know on that image the X/Y pixel coordinates as well as the corresponding Lat/Lon coordinates for a couple of points (but not the actual edges).
Now I am trying to figure out how I can map a couple of Lat/Lon coordinates onto that map. So I need to convert Lat/Lon to X/Y pixel.
Currently trying todo that in JavaScript inside the browser to visualize a path on a chart like that.
Best Answer
The dataset is documented in "MANAIR Manual of Standards and Procedures for Aviation Forecasts: appendix C" -- Appendix C: Graphic Area Forecast (GFA)—Supplement to Chapter 4. A coordinate system is not mentioned here but it seem to be a polar stereo-graphic projection.
Lets give it a try:
1. Find ground gontrol points (GCP's) and create a pass point table
The border polygon can be used to set ground control points (GCP's) in the graphic (at least four) (from GADM for example),
Create a pass point table (QGIS has a geo-referencing tool for example.)
(Corner points are used ..purple marked circles)
Initial longitude/latitude based pass point table:
2. Calculate corresponding pass points at the spherical coordinate system:
Apply the proj.4 definition string of to get the GCP corresponding to the projection.
The proj.4 string is:
The final table looks like that (..see Perl script at the end):
3. Geo-referencing with
gdal_translate
:Try to geo-reference your picture by these points using the tool gdal_translate
with:
-gcp
-- ground control point:img.col img.row world.x world.y
,-a_srs
-- define the coordinate system (proj.4 string),-expand
-- expand from a palette define color image to RGB 24 bit image,-of
--output format (refer to gdal formats for further info's),data/Latest-gfacn31_cldwx_000.png
-- incoming dataset anddata/Latest-gfacn31_cldwx_000_trans.png
-- outgoing dataset.4. Resampling to have a good image quality with
gdalwarp
:Resample the image to an defined resolution and coordinate system here Canadian Polar Stereographic (EPSG:5937) with gdalwarp
with:
-t_srs
-- tagret coordinate system (proj.4 string again),-tr 2000 2000
-- target resolution [m], here 2x2 km,-r lancoz
-- Interpolation method here sinc(x) based,data/Latest-gfacn31_cldwx_000.tif_trans.tif
-- incoming dataset anddata/Latest-gfacn31_cldwx_000.tif-warp.tif
.4. GIS Application
qgis
:Now you can use your "Aviation Weather Map" in an Geo-Information-System like QGIS, overlay spatial data and create augmented maps.
5. Perl Sketch
I've written a small Perl script to get a more compact workflow and used the tools directly by a shell call (..same like bash
$(...)
).There are similar tools for JavaScript proj4js or [npm gdal(https://www.npmjs.com/package/gdal)] or in QGIS more functional available.
The script and the related datasets can be found under https://github.com/bigopensky/gis-se-snippet.
EDIT: Comment Browser based JavaScript Approach of the Original
If the original image should be used as a "Map Canvas" for a browser based application, the product with source CRS and affine transform data produced by
gdal_translate
(data/Latest-gfacn31_cldwx_000.tif_trans.tif
in the scripts above) can be applied in conjuction with libraries/applications like Leaflet to draw the Lon/Lat based vector content.Examples: https://github.com/stuartmatthews/leaflet-geotiff