3

Using OGR in Python, I am attempting to modify the driver settings for S57. I am able to read the meta data from the driver as follows:

import ogr

driver = ogr.GetDriverByName("S57")
driver.GetMetadata()

Which returns all the meta-data for the driver, I have removed some of it for the sake of the post length.

{'DCAP_CREATE': 'YES',
 'DCAP_OPEN': 'YES',
 'DCAP_VECTOR': 'YES',
 'DCAP_VIRTUALIO': 'YES',
 'DMD_CREATIONOPTIONLIST': "<CreationOptionList>   <Option name='S57_EXPP' "
                           "type='int' description='Exchange purpose' "
                           "default='1'/>   <Option name='S57_INTU' type='int' "
                           "description='Intended usage' default='4'/>   "
                           "<Option name='S57_EDTN' type='string' "
                           "description='Edition number' default='2'/>   "
                           "<Option name='S57_UPDN' type='string' "
                           "description='Update number' default='0'/>   "
                           "<Option name='S57_UADT' type='string' "
                           "description='Update application date' "
                           "default='20030801'/>   <Option name='S57_ISDT' "
                           "type='string' description='Issue date' "
                           "default='20030801'/>   <Option name='S57_STED' "
                           "type='string' description='Edition number of S-57' "
                           "default='03.1'/>   <Option name='S57_AGEN' "
                           "type='int' description='Producing agency' "
                           "default='540'/>   <Option name='S57_COMT' "
                           "type='string' description='Comment' default=''/>   "
.........
'DMD_EXTENSION': '000',
 'DMD_EXTENSIONS': '000',
 'DMD_HELPTOPIC': 'drv_s57.html',
 'DMD_LONGNAME': 'IHO S-57 (ENC)',
 'DMD_OPENOPTIONLIST': "<OpenOptionList>  <Option name='UPDATES' "
                       "type='string-select' description='Should update files "
                       "be incorporated into the base data on the fly' "
                       "default='APPLY'>    <Value>APPLY</Value>    "
                       '<Value>IGNORE</Value>  </Option>  <Option '
                       "name='SPLIT_MULTIPOINT' type='boolean' "
                       "description='Should multipoint soundings be split into "
                       "many single point sounding features' default='NO'/>  "
                       "<Option name='ADD_SOUNDG_DEPTH' type='boolean' "
                       "description='Should a DEPTH attribute be added on "
                       "SOUNDG features and assign the depth of the sounding' "
                       "default='NO'/>  <Option name='RETURN_PRIMITIVES' "
                       "type='boolean' description='Should all the low level "
                       'geometry primitives be returned as special '
                       "IsolatedNode, ConnectedNode, Edge and Face layers' "
                       "default='NO'/>  <Option name='PRESERVE_EMPTY_NUMBERS' "
                       "type='boolean' description='If enabled, numeric "
                       'attributes assigned an empty string as a value will be '
                       "preserved as a special numeric value' default='NO'/>  "
                       "<Option name='LNAM_REFS' type='boolean' "
.......

Using the following functions

driver.GetMetadataItem("DCAP_OPEN")
driver.SetMetadata({"DCAP_OPEN" : "NO"})

I am able to obtain the "higher"-level options and set them accordingly. However, I'm interested in modifying options within the DMD_CREATIONOPTIONLIST and DMD_OPENOPTIONLIST, such as setting the UPDATES option in the latter. How do I check the status of said option and setting it afterwards?

Edit: Specifically the options on page 301 "S57 Control Options" link

  • An easier reference to read might be: gdal.org/drivers/vector/s57.html – nmtoken Aug 30 at 15:57
  • @nmtoken Whilst searching for possible solutions, I also stumbled upon this. However, I am unsure how to do this using Python? I'm fairly inexperienced. – Thomas Sep 2 at 7:16
0

After investigating further what was suggested by @nmtoken, I finally managed to obtain some desirable results.

from osgeo import ogr
import os

os.environ["OGR_S57_OPTIONS"] = "SPLIT_MULTIPOINT=ON,ADD_SOUNDG_DEPTH=ON"

driver = ogr.GetDriverByName("S57")
data = driver.Open("mapname")

The above snippet is able to set the options available in https://gdal.org/drivers/vector/s57.html. However, I am unable to verify that the settings are correctly loaded, besides looking at concrete map-based examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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