-
Notifications
You must be signed in to change notification settings - Fork 2
Raster Introduction for PDS4 Conversion Using GDAL
First, to get a quick GDAL environment on any OS install miniconda (64bit if available) https://docs.conda.io/en/latest/miniconda.html
Windows: I install for "everyone" and under advanced install options, I like to uncheck the environment options. So it doesn't change anything. Not bad, but it might play oddly with other applications (like ArcMap). Uninstall will fix it also.
Windows: from the start button, type in "anaconda" and open the command prompt.
- Now install GDAL, on the command-line:
conda install -c conda-forge gdal
currently to get gdal 3.1 (needed for vector support), you may need run:
conda install -c conda-forge gdal=3.1
--type "y", wait a while to install
Once GDAL is installed, you should be ready for testing, but let's also get a minimum PDS4 XML template (with some inline variables) that comes with GDAL. You can manually edit this minimum example (pds4_template.xml) or use your own PDS4 Template as created by other tools like Generate, OLAF, PLAID, etc. Note: templates can be used from http/https addresses too.
to download in your window type:
curl https://raw.githubusercontent.com/OSGeo/gdal/master/data/pds4_template.xml --output pds4_template.xml
to download an example image to convert, let's try the 4pdd LOLA DEM (the IMG is the raw pixel file and the LBL is the PDS3 ASCII label).
curl https://pds-geosciences.wustl.edu/lro/lro-l-lola-3-rdr-v1/lrolol_1xxx/data/lola_gdr/cylindrical/img/ldem_4.img --output ldem_4.img
curl https://pds-geosciences.wustl.edu/lro/lro-l-lola-3-rdr-v1/lrolol_1xxx/data/lola_gdr/cylindrical/img/ldem_4.lbl --output ldem_4.lbl
So - finally, an example run might look like:
gdal_translate -of PDS4 -co IMAGE_FORMAT=GEOTIFF -co TEMPLATE=pds4_template.xml ldem_4.lbl ldem_4_PDS4_geo.xml
where:
- -of = output format
- -co = conversion option and without variables specified in template, you will get several warnings. To show one variable you can add:
gdal_translate -of PDS4 -co IMAGE_FORMAT=GEOTIFF -co TEMPLATE=pds4_template.xml -co VAR_Target=Moon ldem_4.lbl ldem_4_PDS4_geo.xml
see more variables used in links below.
To test the Tiff and the PDS4 label you can run (note gdal writes only a *.tif (one "f" for the extension))
gdalinfo ldem_4_PDS4_geo.xml
gdalinfo ldem_4_PDS4_geo.tif
to run a *.img raw image, instead of Tiff, just default:
gdal_translate -of PDS4 ldem_4.lbl ldem_4_PDS4_raw.xml
More examples: isis3 helper script (gathers label info for gdal conversion) but should also work for for PDS3 (using PVL):
final label using version PDS4_CART_1D00_1933:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1D00.sch" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-model href="https://pds.nasa.gov/pds4/disp/v1/PDS4_DISP_1B00.sch" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-model href="https://pds.nasa.gov/pds4/cart/v1/PDS4_CART_1D00_1933.sch" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<Product_Observational xmlns="http://pds.nasa.gov/pds4/pds/v1" xmlns:pds="http://pds.nasa.gov/pds4/pds/v1" xmlns:disp="http://pds.nasa.gov/pds4/disp/v1" xmlns:cart="http://pds.nasa.gov/pds4/cart/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://pds.nasa.gov/pds4/pds/v1 https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1D00.xsd
http://pds.nasa.gov/pds4/disp/v1 https://pds.nasa.gov/pds4/disp/v1/PDS4_DISP_1B00.xsd
http://pds.nasa.gov/pds4/cart/v1 https://pds.nasa.gov/pds4/cart/v1/PDS4_CART_1D00_1933.xsd">
<Identification_Area>
<logical_identifier>urn:nasa:pds:lro:lola:ldem_global_64ppd</logical_identifier>
<version_id>1.0</version_id>
<title>LRO LOLA Digital Elevation Model (DEM) 64ppd</title>
<information_model_version>1.13.0.0</information_model_version>
<product_class>Product_Observational</product_class>
</Identification_Area>
<Observation_Area>
<Time_Coordinates>
<start_date_time nilReason="inapplicable" xsi:nil="true"/>
<stop_date_time nilReason="inapplicable" xsi:nil="true"/>
</Time_Coordinates>
<Investigation_Area>
<name>Lunar Reconnaissance Orbiter</name>
<type>Mission</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:instrument_host:spacecraft.lro</lid_reference>
<reference_type>data_to_investigation</reference_type>
</Internal_Reference>
</Investigation_Area>
<Observing_System>
<Observing_System_Component>
<name>LOLA</name>
<type>Spacecraft</type>
</Observing_System_Component>
</Observing_System>
<Target_Identification>
<name>${TARGET}</name>
<type>Satellite</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:target:satellite.moon</lid_reference>
<reference_type>data_to_target</reference_type>
</Internal_Reference>
</Target_Identification>
<Discipline_Area>
<disp:Display_Settings>
<Local_Internal_Reference>
<local_identifier_reference>image</local_identifier_reference>
<local_reference_type>display_settings_to_array</local_reference_type>
</Local_Internal_Reference>
<disp:Display_Direction>
<disp:horizontal_display_axis>Sample</disp:horizontal_display_axis>
<disp:horizontal_display_direction>Left to Right</disp:horizontal_display_direction>
<disp:vertical_display_axis>Line</disp:vertical_display_axis>
<disp:vertical_display_direction>Top to Bottom</disp:vertical_display_direction>
</disp:Display_Direction>
</disp:Display_Settings>
<cart:Cartography>
<Local_Internal_Reference>
<local_identifier_reference>image</local_identifier_reference>
<local_reference_type>cartography_parameters_to_image_object</local_reference_type>
</Local_Internal_Reference>
<cart:Spatial_Domain>
<cart:Bounding_Coordinates>
<cart:west_bounding_coordinate unit="deg">0.0</cart:west_bounding_coordinate>
<cart:east_bounding_coordinate unit="deg">360.0</cart:east_bounding_coordinate>
<cart:north_bounding_coordinate unit="deg">90.0</cart:north_bounding_coordinate>
<cart:south_bounding_coordinate unit="deg">-90.0</cart:south_bounding_coordinate>
</cart:Bounding_Coordinates>
</cart:Spatial_Domain>
<cart:Spatial_Reference_Information>
<cart:Horizontal_Coordinate_System_Definition>
<cart:Planar>
<cart:Map_Projection>
<cart:map_projection_name>Equirectangular</cart:map_projection_name>
<cart:Equirectangular>
<cart:latitude_of_projection_origin unit="deg">0</cart:latitude_of_projection_origin>
<cart:standard_parallel_1 unit="deg">0</cart:standard_parallel_1>
<cart:longitude_of_central_meridian unit="deg">180</cart:longitude_of_central_meridian>
</cart:Equirectangular>
</cart:Map_Projection>
<cart:Planar_Coordinate_Information>
<cart:planar_coordinate_encoding_method>Coordinate Pair</cart:planar_coordinate_encoding_method>
<cart:Coordinate_Representation>
<cart:pixel_resolution_x unit="m/pixel">7580.84000000000015</cart:pixel_resolution_x>
<cart:pixel_resolution_y unit="m/pixel">7580.84000000000015</cart:pixel_resolution_y>
<cart:pixel_scale_x unit="pixel/deg">3.99999873683516327</cart:pixel_scale_x>
<cart:pixel_scale_y unit="pixel/deg">3.99999873683516327</cart:pixel_scale_y>
</cart:Coordinate_Representation>
</cart:Planar_Coordinate_Information>
<cart:Geo_Transformation>
<cart:upperleft_corner_x unit="m">-5458204.79999999981</cart:upperleft_corner_x>
<cart:upperleft_corner_y unit="m">2729102.39999999991</cart:upperleft_corner_y>
</cart:Geo_Transformation>
</cart:Planar>
<cart:Geodetic_Model>
<cart:latitude_type>Planetocentric</cart:latitude_type>
<cart:spheroid_name>MOON</cart:spheroid_name>
<cart:a_axis_radius unit="m">1737400</cart:a_axis_radius>
<cart:b_axis_radius unit="m">1737400</cart:b_axis_radius>
<cart:c_axis_radius unit="m">1737400</cart:c_axis_radius>
<cart:longitude_direction>Positive East</cart:longitude_direction>
</cart:Geodetic_Model>
</cart:Horizontal_Coordinate_System_Definition>
</cart:Spatial_Reference_Information>
</cart:Cartography>
</Discipline_Area>
</Observation_Area>
<File_Area_Observational>
<File>
<file_name>out_ldem4.img</file_name>
</File>
<Array_3D_Image>
<local_identifier>image</local_identifier>
<offset unit="byte">0</offset>
<axes>3</axes>
<axis_index_order>Last Index Fastest</axis_index_order>
<Element_Array>
<data_type>SignedLSB2</data_type>
<scaling_factor>0.5</scaling_factor>
<value_offset>1737400</value_offset>
</Element_Array>
<Axis_Array>
<axis_name>Band</axis_name>
<elements>1</elements>
<sequence_number>1</sequence_number>
</Axis_Array>
<Axis_Array>
<axis_name>Line</axis_name>
<elements>720</elements>
<sequence_number>2</sequence_number>
</Axis_Array>
<Axis_Array>
<axis_name>Sample</axis_name>
<elements>1440</elements>
<sequence_number>3</sequence_number>
</Axis_Array>
<Special_Constants>
<missing_constant>-32768</missing_constant>
</Special_Constants>
</Array_3D_Image>
</File_Area_Observational>
</Product_Observational>