2

We create printed maps from a GeoTIFF file projected in LCC, which is a common projection for aviation maps. Part of our process includes customization of the raster image by selecting a region and adding other design elements. The final part of the process allows for the customer to select desired airports on the map via a custom leaflet application showing all the airports via a GeoJSON file.

We would like to have the tiles map image the customer sees in the Leaflet application be similar to the way the printed map will appear to the customer. This means they will stay in LCC and we crop and raster tile the actual artwork for use in leaflet. We have this all worked out just fine with tiling the resulting image and using leaflet and proj4leaflet. The issue we have is sometimes would like to rotate the crop so that the raster image does not end up aligning with the LCC projection.

Shown here is a copy of my main image where you can see the inside image which will make up our final printed artwork. The inlayed image aligns with the original image, but the cropped area is rotated about 13 degrees.

Map

I would like to output inset cropped image, rotated so that it appears as it would appear hanging on the wall. This would involve rotating the image about 13 degrees.

rotated image

If it were not rotated, we easily calculate a new TFW and include the northing and easting components by calculating the pixel size and the amount of the crop. This all works out perfectly.

However, with it being rotated, we need to add the rotation components to the TFW file and I have been unsuccessful in trying to figure that out.

The end results should be a map which appears to be a cropped version of the main map, projected in LCC, but rotated 13 degrees so that it appears online as it would appear hanging on the wall.

Things I've Tried

I've studied the page here: https://en.wikipedia.org/wiki/World_file and worked out that I need to do some trig on the pixel values.

The other completely unknown is if Leaflet and proj4leaflet can even handle these translations? Answer -- YES, I think I can use the Leaflet.Transformation function for this once I figure out the transformation to use for the rotation.

Update

Here is a concrete example of what I am trying to do along with the files.

The projection of these are '+proj=lcc +lat_0=38 +lon_0=-100 +lat_1=45 +lat_2=33 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'

Here is a portion of the the map I'm working with along with the accompanying pgw file.

corner image

Here is that same image rotated 45 degrees (around the center of the image)

corner image rotated

What should the corresponding world file be for the rotated 45 image and how do you calculate each field in that file.

12
  • GIS SE works better if you explain what you have attempted, rather than just stating that you were unsuccessful.
    – Vince
    Jan 15, 2021 at 0:27
  • @Vince I will work on updating the question as to what I have tried, which is mainly just trying to calculate the new values for the TFW file.
    – jr.
    Jan 15, 2021 at 0:29
  • Is your raster map layer image overlay or tiled layer?
    – TomazicM
    Jan 15, 2021 at 14:05
  • It is a tiled layer.
    – jr.
    Jan 15, 2021 at 18:17
  • I think I really just need to work out the affine transformation to turn the pixel coordinates into the coordinates of the underlying coordinate system since when you rotate things it won’t be aligned on the same grid anymore. I don’t quite understand how to calculate those rotation values to be placed in the world file. I’ve read about it but don’t understand if the meters per pixel need to change or not? I know it’ll require some trig.
    – jr.
    Jan 15, 2021 at 18:28

1 Answer 1

0

I suggest leveraging Leaflet.ImageOverlay.Rotated - it's able to display raster images given three control corners, as shown in its demo:

leaflet imageoverlay rotated demo

The control corners are trivially calculated from a worldfile: one of them is the coordinate of the top-left pixel (lines 5 and 6 of a worldfile) - other is the top-left plus (width in pixels) times the width scale-skew (lines 1 and 2) and the third one is top-left plus (height in pixels) times the height scale-skew (lines 3 and 4).

1
  • I don’t think this would work since my map isn’t an overlay, but a tiled layer.
    – jr.
    Jan 15, 2021 at 18:25

Your Answer

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

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