Author Topic: TIP: HiRISE Jpeg2000 for ArcMap  (Read 27141 times)

thare

  • GIS Support Team
  • Isis (Extreme Power Member)
  • *****
  • Posts: 1217
    • http://webgis.wr.usgs.gov
    • Email
TIP: HiRISE Jpeg2000 for ArcMap
« on: October 08, 2008, 11:03:34 PM »
update: the March 21, 2010 thread below can be also be used instead of this method which should work for all cases.

We have recently added some projection support to the pds2world.pl and pds2world.exe programs to help generate the ESRI Well-Known Text (WKT) projection definition. The lastest version of pds2world.pl and pds2world.exe can be downloaded from: http://webgis.wr.usgs.gov/pigwad/tutorials/scripts/perl.htm

So first download the HiRISE jp2 and label. Run pds2world.pl or pds2world.exe on the HiRISE label:
>pds2world.pl -J -prj PSP_004145_1455_RED.LBL
-this should output a j2w worldfile and prj projection file

You can now open ArcCatalog, right click on the image, select properties and scroll down to the Spatial Reference and select the "Edit..." button.  In the next dialog use the "Select" button and drive to the location of the *.prj file just created by pds2world.  That's it - it should project on the fly to correct location once the data frame projection in ArcMap is set.

-Trent

For Batch (many images)

batch (unix):
foreach i (*.LBL)
foreach> perl pds2world.pl -J -prj $i
foreach> end

batch (dos):
for %i in (*.LBL) do pds2world -J -prj %i

This will generate the Jpeg2000 worldfile and projection file. Now to assign the projection for each image for use in ArcMap, run the "add projection from PRJ" from the USGS Image Toolbox for all your images:
http://resources.esri.com/geoprocessing/index.cfm?fa=codeGalleryDetails&scriptID=15759
« Last Edit: March 22, 2010, 09:31:52 AM by thare »

thare

  • GIS Support Team
  • Isis (Extreme Power Member)
  • *****
  • Posts: 1217
    • http://webgis.wr.usgs.gov
    • Email
geoJp2 headers
« Reply #1 on: April 29, 2009, 09:16:50 AM »
From HiRISE team:
Quote
All RDR's for data acquired after orbit ~7868 should have the embedded geometry information within the JP2 file.  There is a small handful of products prior to this orbit that have also have it.

This is the first geospatial-ready PDS release in hopefully a long-line of future PDS products!

-Trent

thare

  • GIS Support Team
  • Isis (Extreme Power Member)
  • *****
  • Posts: 1217
    • http://webgis.wr.usgs.gov
    • Email
TIP: HiRISE Jpeg2000 for ArcMap
« Reply #2 on: May 07, 2009, 06:46:04 PM »
Warning for ArcMap 9.3 Users (only for HiIRSE Equirectangular images with an embedded projection). Images without geoheader will accept the projection definition as described above and polar images work fine.

For ArcMap 9.3 and geo-embedded hirise images, this method above will not work. It appears to allow you to overwrite the projection but it doesn't stick. The reason to overwrite the image's embedded projection is because it currently wrongly maps Equirectangular to Plate Carre. And even after setting it manually to Equidistant Cylindrical, the projection will revert back to Plate Carree - arg! The problem -- Plate Carree fails to recognize the standard_par_1 (center lat) parameter which will causes an X scaling and X shift. The Y scaling and location is correct. Fortunately, this mapping issue has been fix in ArcMap 9.4 (now called 10) but we will have to wait for it to be released. The older 9.2 version allows you to overwrite the projection (as described above).

work-around for 9.3 users. See below

1.) convert to different format like ERDAS Img which allows huge files and you can override the projection (I hope). This can be done in ArcMap or using gdal.
2.) Clear the projection from the jpeg2000 image in ArcCatalog. Now set data frame to your HiRISE image projection (Equidistant Cylindrical, clon=180, clat=XX, local radius). This will project all the other files to it.

-still looking for a better workaround. Here is another (last thread) - still not ideal:
https://isis.astrogeology.usgs.gov/IsisSupport/index.php/topic,2057.0.html


Trent
« Last Edit: March 22, 2010, 09:29:09 AM by thare »

thare

  • GIS Support Team
  • Isis (Extreme Power Member)
  • *****
  • Posts: 1217
    • http://webgis.wr.usgs.gov
    • Email
Re: TIP: HiRISE Jpeg2000 for ArcMap
« Reply #3 on: March 21, 2010, 12:17:07 AM »
Well I think I found a solution (at least a work-around) for ArcMap 9.3 - should work for 9.2 also. This actually may work for the forth coming ArcMap 10. But the better way is to actually update the internal JP2 label (using the fix_jp2 app - more on this when needed).

This simple PERL script runs on a HiRISE JP2 label and will write out a .jp2.aux.xml projection auxiliary file for ArcMap. Fortunately, when this file exists, it overrides the internal JP2 projection. This fixes the projection mapping bug in ArcMap 9.x and swaps the center lat keyword in the HiRISE label to standard_par_1. The projection mapping issue for 9.x sets the HiRISE Equirectangular to Plate Carree instead of more appropriately to Equidistant Cylindrical.

To run: download, unzip, and place this script next to your HiRISE Jp2 images (and matching PDS labels).
ftp://pdsimage2.wr.usgs.gov/pub/pigpen/Perl/arcmap93_fixjp2_equirectangular.zip

link direct to PERL to check out code: ftp://pdsimage2.wr.usgs.gov/pub/pigpen/Perl/arcmap9_fixjp2.pl

example run:
>perl arcmap9_fixjp2.pl PSP_008913_2255_RED.LBL

for Windows you can run the PERL or .exe:
>arcmap9_fixjp2 PSP_008913_2255_RED.LBL

Please test. To batch over many files, see first thread above.

-Trent
« Last Edit: March 22, 2010, 09:26:14 AM by thare »

bermandc

  • Osiris (Active Member)
  • **
  • Posts: 5
    • Email
Re: TIP: HiRISE Jpeg2000 for ArcMap
« Reply #4 on: April 02, 2010, 10:27:30 AM »
This appears to be working for me without any problems!
Daniel C. Berman
Research Associate
Planetary Science Institute

lorifenton

  • Osiris (Active Member)
  • **
  • Posts: 11
Re: TIP: HiRISE Jpeg2000 for ArcMap
« Reply #5 on: July 09, 2010, 02:43:03 PM »
Hi Trent

This doesn't seem to be working for me and my student. We've tried both pds2world.pl and arcmap9_fixjp2.pl and both of them say "not supported for this fix equirectangular routine" (in the case of arcmap9_fixjp2) and "not yet supported" (in the case of pds2world). We're trying it on image PSP_003474_1735, which should be an older image. Any idea why it's not working? Thanks!

Lori

thare

  • GIS Support Team
  • Isis (Extreme Power Member)
  • *****
  • Posts: 1217
    • http://webgis.wr.usgs.gov
    • Email
Re: TIP: HiRISE Jpeg2000 for ArcMap
« Reply #6 on: July 10, 2010, 02:08:10 PM »
hmm - it seems to have worked for me... See animated gif: ftp://pdsimage2.wr.usgs.gov/pub/pigpen/tutorials/hirise_jp2fix_arcmap.gif

So I ran (windows):
> arcmap9_fixjp2 PSP_003474_1735_RED.LBL
*NIX or Windows:
> arcmap9_fixjp2.pl PSP_003474_1735_RED.LBL

results in the new file - PSP_003474_1735_RED.jp2.aux.xml (which will override the internal projection).
Code: [Select]
<PAMDataset>
<SRS>PROJCS[&quot;EQUIRECTANGULAR MARS clon180&quot;,GEOGCS[&quot;GCS_MARS&quot;,DATUM[&quot;D_MARS&quot;,SPHEROID[&quot;&quot;,3396036.8126024,0]],PRIMEM[&quot;Reference_Meridian&quot;,0],UNIT[&quot;degree&quot;,0.0174532925199433]],PROJECTION[&quot;Equidistant_Cylindrical&quot;],PARAMETER[&quot;latitude_of_origin&quot;,0],PARAMETER[&quot;central_meridian&quot;,180],PARAMETER[&quot;standard_parallel_1&quot;,-5],PARAMETER[&quot;false_easting&quot;,0],PARAMETER[&quot;false_northing&quot;,0]]</SRS>
</PAMDataset>

Now I loaded the *.JP2 into ArcMap with an MDIM21 mosaic. I set the data frame to projection of the HiRISE image (but you can set to another because it will project-on-the-fly).

Tip: By setting the data frame to the projection of the HiRISE image you can now further nudge the HiRISE registration to the MDIM21 base since the initial location should be close but probably not perfect (using ArcMap's Georeferencing toolbar, add one or more control point(s) and "update georeferencing" - one control point should do). To register many HiRISE images that have different projections, set the data frame's projection to each HiRISE image, register that image using the Georef toolbar (make sure to hit update georeferencing), and repeat for each image. Once all images are nudged (re-registered) they will all be able to project-on-the-fly to a different common projection while maintaining their new location. The animation above shows the initial (pretty good) location of this HiRISE image.:

Does that help?

-Trent
« Last Edit: August 12, 2010, 06:07:52 PM by thare »

lorifenton

  • Osiris (Active Member)
  • **
  • Posts: 11
Re: TIP: HiRISE Jpeg2000 for ArcMap
« Reply #7 on: July 13, 2010, 01:30:22 PM »
On the projection issue:

I'll check the xml file tomorrow (working from home today) to see if it matches yours. We're using ArcGIS 9.3.

When we try to load in the JP2 image it shows up at 0,0 rather than the lat and lon it should be at (and yes, the image and the xml file are in the same directory). We're using the startup ArcGIS project you posted in a different thread last summer.


On the Linux issue:

In Linux we do have to run the command as you have typed it, and it produces a world file but no prj or xml file. Not sure why. Here's an example of what it says:

lfenton@tyre ~/test $ perl arcmap9_fixjp2.pl ESP_018011_2565_RED.LBL
 World file generated: ESP_018011_2565_RED.j2w
, not supported for this fix equirectangular routine - try pds2world.pl or pds2world.exe
lfenton@tyre ~/test $ ls ESP*
ESP_018011_2565_RED.JP2  ESP_018011_2565_RED.LBL  ESP_018011_2565_RED.j2w

thare

  • GIS Support Team
  • Isis (Extreme Power Member)
  • *****
  • Posts: 1217
    • http://webgis.wr.usgs.gov
    • Email
Re: TIP: HiRISE Jpeg2000 for ArcMap
« Reply #8 on: July 13, 2010, 02:15:09 PM »
Now for the image ESP_018011_2565_RED2.JP2 I do get a similar warning (although mine, maybe slightly newer version, lists the projection in the current image):
>arcmap9_fixjp2 ESP_018011_2565_RED.LBL
World file generated: ESP_018011_2565_RED.j2w
This type of projection, POLARSTEREOGRAPHIC, not supported for this fix equirectangular routine - try pds2world.pl or pds2world.exe


So this is listing that the image is not using the "equirectangular" projection which is the only reason to use this script to help fix the label. Fortunately, polar-projected HiRISE jpeg2000 images should work without doing anything. Just open the image in ArcMap.

I know this is confusing and this stems from several issues. I will try to summarize here. I will split up each topic into the two projections (1) polar and (2) equirectangular.

1.) Polar

1.a) HiRISE images pre-orbit 7868 do not contain geoheaders yet. Thus you will need to create a worldfile and a projection file if needed. For polar only pds2world.pl will be able to create the *.j2w and *.prj. You will then need to add the *.prj to the image using ArcCatalog.
>pds2world -J -prj image.lbl      (that is a capital J).

1.b) HiRISE images from orbit 7868 and beyond should be ready to go. The Jp2 image has an included geoheader and should work without doing anything else in ArcMap.

2.) Equirectangular

All images (including pre-orbit 7868) should be run through arcmap9_fixjp2.pl. For image without geospatial headers this should add enough information for ArcMap to locate and understand the projection. For images with geospatial headers, this should update the defined projection to correct for the projection parameter issue.


Let me know if you still have issues. There might be something I have not thought of.

-Trent


This "gdalinfo" run shows that the image ESP_018011_2565_RED2.JP2 has an internal geospatial header in a polar projection. That means it is ready to go in ArcMap 9.3 and 10. I know the keywords are not listed perfectly but it is enough for ArcMap.

Code: [Select]
>gdalinfo ESP_018011_2565_RED2.JP2
Driver: JP2ECW/ERMapper JPEG2000
Files: ESP_018011_2565_RED2.JP2
Size is 56951, 40453
Coordinate System is:
PROJCS["Polar_Stereographic MARS",
    GEOGCS[,
        DATUM["unknown",
            SPHEROID["unnamed",3376200,0]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Polar_Stereographic"],
    PARAMETER["latitude_of_origin",90],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (807395.125000000000000,82116.625000000000000)
Pixel Size = (0.250000000000000,-0.250000000000000)
Corner Coordinates:
Upper Left  (  807395.125,   82116.625) ( 95d48'26.40"E, 76d17'35.41"N)
Lower Left  (  807395.125,   72003.375) ( 95d 5'46.13"E, 76d18'33.28"N)
Upper Right (  821632.875,   82116.625) ( 95d42'26.54"E, 76d 3'22.50"N)
Lower Right (  821632.875,   72003.375) ( 95d 0'29.85"E, 76d 4'19.34"N)
Center      (  814514.000,   77060.000) ( 95d24'16.50"E, 76d10'58.53"N)
Band 1 Block=56951x1 Type=UInt16, ColorInterp=Gray
  Overviews: arbitrary
« Last Edit: July 13, 2010, 02:16:50 PM by thare »