• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Another GDAL Warp Thread

Messages
53
Country
unitedstates
Have been using Gdal Warp and Translate without issue with the old Geo-Tiffs from NAIP for the most part, compiled most of Utah.

Now with the new JP2 format, in certain areas about half the tiles are giving me coordinate errors when trying to warp them. I downloaded 120 tiles on the S-Idaho / N-Utah border, only half of them went through. I doubled check to make sure they are all in the same EPSG code, and they were.

I've tried with older and newer versions of Gdal Warp...

Error is:
Lattitude or Longitude exceeded limits. Too many points, failed to compute output bounds.

My Statement is:

gdalwarp.exe -s_srs EPSG:26912 -t_srs "+proj=latlong +datum=WGS84" -r cubic -co INTERLEAVE=PIXEL -co TFW=YES -of GTiff -rcs "D:\ToBeWarped\m_4211042_sw_12_1_20120725_20121004.jp2" "D:\PreTransFinals\BearLakeExt_Tile41.tif"


|||||||||||| THE Above fails with the coord errors only on some JP2's |||||||||||

gdal_translate.exe -of Gtiff -b 1 -b 2 -b 3 "D:\PreTransFinals\BearLakeExt_Tile41.tif" "D:\Finals\BearLakeExt_Tile41.tif"

||||||||||| Also for some reason I have to run translate AFTER the warps on these tiles, where with the Geo-Tiffs, I think I did it the other way around (been a while though) ||||||||||


Any ideas anyone?
 
I may have figured it out, I think I need to run the Translate first regardless, and then use the simpler version of the warp line:
gdalwarp.exe -s_srs EPSG:26912 -t_srs "+proj=latlong +datum=WGS84" -r cubic

I think the below method is trying to convert and warp at the same time:
gdalwarp.exe -s_srs EPSG:26912 -t_srs "+proj=latlong +datum=WGS84" -r cubic -co INTERLEAVE=PIXEL -co TFW=YES -of GTiff -rcs "D:\ToBeWarped\m_4211042_sw_12_1_20120725_20121004.jp2" "D:\PreTransFinals\BearLakeExt_Tile41.tif"
 
Nah still got the issue regardless. I'm thinking maybe it's the size of the tile, maybe merging a few together would fix it.
Guess I'll have to try that next.
 
Rather then having everyone guess, why not zip the source up and attach it?

Dick
 
Thanks guys, I really appreciate any input. I will zip it up and provide here as soon as I get the chance.
 
You shouldn't need to define the original projection.

Try

gdalwarp -of GTiff -co "INTERLEAVE=PIXEL" -t_srs "+proj=latlong +datum=WGS84" -r cubic "source.jp2" "geotiff.tif"


With -tr command you can define the output resolution; this is ~ 50 pix/m.

gdalwarp -of GTiff -co "INTERLEAVE=PIXEL" -t_srs "+proj=latlong +datum=WGS84" -r cubic -tr 0.00005 0.00005 "source.jp2" "geotiff.tif"

As long as the the shortcut to OSGeo4w shell is in the same folder, file names will suffice.
 
That didn't work either, and it only works if I remove all the projection info completely, but then the coordinate system is wrong.
See the GDAL-INFO below for each tile (one that works, and one that does NOT work).
The problem is the source coordinate system isn't NAD 83 with the second tile, this is what is causing it to FAIL.

The 2nd tile is PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",...

Why the heck are there inconsistencies in the source coordinate type when downloading direct from The National Map Viewer, what gives here??

gdalinfo workingtile.jp2

Size is 5780, 7580
Coordinate System is:
PROJCS["NAD83 / UTM zone 12N",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.2572221010002,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6269"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4269"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-111],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AUTHORITY["EPSG","26912"]]
Origin = (504830.000000000000000,4698680.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 504830.000, 4698680.000) (110d56'28.58"W, 42d26'25.54"N)
Lower Left ( 504830.000, 4691100.000) (110d56'28.81"W, 42d22'19.78"N)
Upper Right ( 510610.000, 4698680.000) (110d52'15.58"W, 42d26'25.33"N)
Lower Right ( 510610.000, 4691100.000) (110d52'16.08"W, 42d22'19.58"N)
Center ( 507720.000, 4694890.000) (110d54'22.26"W, 42d24'22.58"N)
Band 1 Block=4096x4096 Type=Byte, ColorInterp=Red
Overviews: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Overviews: arbitrary
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Band 2 Block=4096x4096 Type=Byte, ColorInterp=Green
Overviews: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Overviews: arbitrary
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Band 3 Block=4096x4096 Type=Byte, ColorInterp=Blue
Overviews: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Overviews: arbitrary
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Band 4 Block=4096x4096 Type=Byte, ColorInterp=Alpha
Overviews: 2890x3790, 1445x1895, 722x947, 361x473, 180x236
Overviews: arbitrary

gdalinfo Notworkingtile.jp2
Driver: JP2OpenJPEG/JPEG-2000 driver based on OpenJPEG library
Files: Notworkingtile.jp2
Size is 13925, 18855
Coordinate System is:
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",
GEOGCS["GCS_WGS_1984",
DATUM["D_WGS_1984",
SPHEROID["WGS_1984",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Mercator_Auxiliary_Sphere"],
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",0.0],
PARAMETER["Standard_Parallel_1",0.0],
PARAMETER["Auxiliary_Sphere_Type",0.0],
UNIT["Meter",1.0]]
Origin = (-12432998.393608849000000,5226744.198668295500000)
Pixel Size = (0.500000000000000,-0.500000000000000)
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left (-12432998.394, 5226744.199)
Lower Left (-12432998.394, 5217316.699)
Upper Right (-12426035.894, 5226744.199)
Lower Right (-12426035.894, 5217316.699)
Center (-12429517.144, 5222030.449)
Band 1 Block=4096x4096 Type=Byte, ColorInterp=Red
Overviews: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589, 217x294, 1087
Overviews: arbitrary
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589,
7x294, 108x147
Band 2 Block=4096x4096 Type=Byte, ColorInterp=Green
Overviews: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589, 217x294, 1087
Overviews: arbitrary
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589,
7x294, 108x147
Band 3 Block=4096x4096 Type=Byte, ColorInterp=Blue
Overviews: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589, 217x294, 1087
Overviews: arbitrary
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589,
7x294, 108x147
Band 4 Block=4096x4096 Type=Byte, ColorInterp=Alpha
Overviews: 6962x9427, 3481x4713, 1740x2356, 870x1178, 435x589, 217x294, 1087
Overviews: arbitrary
 
Tile Download:
http://www.mediafire.com/download/7p9avgrqfjo8r29/WorkingTile_AndNotWorkingTile.zip

I've attached both tiles ABOVE as a ZIP, the first file is WorkingTile.JP2, which works with Gdalwarp, and the second tile is NotWorking.jp2. Let me know if someone wants to check it out, but seems that the obvious issue is the coords in the metadata is stored differently. Also the not working tile is about 10x bigger in file size.

NOTE:
Hmm...
It appears the TNM Downloader is throwing in these MUCH larger tiles in the download, they are 10x the size and in a different source coordinate system. It did it even when I chose download by bounding box and selected only certain tiles (weird).
 
Last edited:
Potential Resolution:
My next step is to just forget GDAL_WARP, I had ZERO problems with it in the old GEO-Tiff format, it seems to be a nightmare with SOME of these JP2 files. I'm just going to use the KMZ files to extract the coordinates directly, convert the image to single layer, and then copy the KMZ coords directly to the INF file. Hopefully the coords are in the correct format in the KMZ (they appear to be from a glance).

Even on working tiles, I was getting coordinate errors anyways of a few pixels off on some of the tiles (might be my fault from accidental rounding), but anyways hopefully the KMZ file will take care of this. Some simple string parsing from the KMZ file and I should be good to go.
 
Back
Top