Skip to content

Vector GIS introduction for PDS4 conversion using GDAL

Trent Hare edited this page Feb 22, 2022 · 1 revision

Quick introduction for PDS4 vector conversion using GDAL

(requires GDAL 3.x)

First, for installing GDAL and download the PDS4_template.xml, see the raster tutorial.

Also we need a definition for The Moon.

curl https://raw.githubusercontent.com/USGS-Astrogeology/GDAL_scripts/master/OGC_IAU2000_WKT_v2/IAU2000_prjs/Moon%202000.prj --output Moon_2000.prj


For an example, let's create this simple CSV table. file: ApolloSiteLocation_circa2014.csv

SITE,LONGITUDE,LATITUDE
Apollo_11,23.472,0.671
Apollo_12,-23.418,-3.036
Apollo_14,-17.48,-3.66
Apollo_15,3.65,26.083
Apollo_16,15.5184,-8.991
Apollo_17,30.767,20.167

Now, make a very simple *.csvt (to define the CSV column types). A .csvt file contains only one line and the types for each column have to be quoted and comma separated, e.g.

"Integer","Real","String" You can even specify width and precision of each column, e.g. "Integer(6)","Real(5.5)","String(22)" Finally, the use of CoordX and CoordY is optional but helps to define what are Lon and Lat fields.

file: ApolloSiteLocation_circa2014.csvt

"String(8)", CoordX, CoordY


Now let's run a conversion (Note: first file is output and second is input!)

ogr2ogr -f PDS4 -a_srs "Moon_2000.prj" -dsco TEMPLATE=PDS4_template.xml -lco LAT=LATITUDE -lco LONG=LONGITUDE ApolloSiteLocation_circa2014_PDS4.xml ApolloSiteLocation_circa2014.csv

where:

  • -f PDS4 === output format PDS4
  • -a_srs "Moon_2000.prj" ==== Moon definition or map projection. "-a_srs" input spatial reference system. This can point directly to a web address too like: https://raw.githubusercontent.com/USGS-Astrogeology/GDAL_scripts/master/OGC_IAU2000_WKT_v2/IAU2000_prjs/Moon%202000.prj
  • -dsco TEMPLATE= file.xml ==== Input PDS4 XML template (all the mission info, start/stop time stuff, ect. And "-dsco" means Dataset creation option
  • -lco LAT=LATITUDE -lco LONG=LONGITUDE ==== (defines the lat/lon field -- somewhat redundant since we defined them in CSVT file). "-lco" means Layer Creation Option
  • -dsco BOUNDING_DEGREES=0,-90,360,90 (optional).
  • ApolloSiteLocation_circa2014_PDS4.xml ==== output file (note this is FIRST)
  • ApolloSiteLocation_circa2014.csv ==== input file (this is listed LAST. Note This is different than gdal_translate.)

Other options can always be found for each format using:

ogrinfo --format PDS4 or ogrinfo --format "Esri Shapefile" or ...

for more: https://www.gdal.org/frmt_pds4.html