consbio / gis-metadata-parser

Parser for GIS metadata standards including ArcGIS, FGDC and ISO-19115
BSD 3-Clause "New" or "Revised" License
20 stars 3 forks source link

Questions about adding FGDC projection information - nested complex? #5

Closed jlaura closed 3 years ago

jlaura commented 3 years ago

I am trying to parse/include projection information in some FGDC metadata. Specifically, the and then projection specific sections.

I have the following working to set the projection name:

class CustomFGDCMetadata(FgdcParser):
      mapproj_definition = frozendict({
            'name': '{name}'
        }) 

    def _init_data_map(self):
        super(CustomFGDCMetadata, self)._init_data_map()

        mapproj_prop = 'projection'
        mapproj_xpath = 'spref/horizsys/planar/mapproj/{mapproj_path}'

        self._data_structures[mapproj_prop] = format_xpaths(
            self.mapproj_definition,
            name=mapproj_xpath.format(mapproj_path='mapprojn'),
        )

        self._data_map['_{prop}_root'.format(prop=mapproj_prop)] = 'projection'
        self._data_map[mapproj_prop] = ParserProperty(self._parse_complex, self._update_complex)
        self._metadata_props.add(mapproj_prop)

I am struggling to set the projection itself inside of the name. Here, I am trying to extend the above in order to get an equirectangular projection defined.

class CustomFGDCMetadata(FgdcParser):
    equi_definition = frozendict({
        'standard_parallel' : '{standard_parallel}',
        'lon_center_meridian':'{lon_center_meridian}',
        'false_easting' : '{false_easting}',
        'false_northing' : '{false_northing}'
    })

    mapproj_definition = frozendict({
            'name': '{name}',
            'crs': '{crs}'
        }) 

    def _init_data_map(self):
        super(CustomFGDCMetadata, self)._init_data_map()

        mapproj_prop = 'projection'
        mapproj_xpath = 'spref/horizsys/planar/mapproj/{mapproj_path}'
        crs_prop = 'crs'
        crs_xpath = 'spref/horizsys/planar/mapproj/{projname}/{mapproj_path}'

        self._data_structures[mapproj_prop] = format_xpaths(
            self.mapproj_definition,
            name=mapproj_xpath.format(mapproj_path='mapprojn'),
            projection=mapproj_xpath.format(mapproj_path='equirect'),
            standard_parallel=crs_xpath.format(projname='equirect', mapproj_path='stdparll')
        )

        self._data_map['_{prop}_root'.format(prop=mapproj_prop)] = 'projection'
        self._data_map[mapproj_prop] = ParserProperty(self._parse_complex, self._update_complex)
        self._metadata_props.add(mapproj_prop)

This is throwing key errors trying to get the crs xpath. I also tried defining the mapprojn separate from the projection information, but this resulted in duplicate wrapping keys (specifically the planar one). Does an example exist for nested objects that I can/should follow?

Thanks!

dharvey-consbio commented 3 years ago

@jlaura, can you provide me an example XML file so I can test your code, and see about fixing the errors or suggesting a change of code?

jlaura commented 3 years ago

@dharvey-consbio Absolutely! Thanks. Here is a truncated (but still valid I believe) example:

``` Equirectangular 0 0 0 0 7346.0 7346.0 none84.94594418192924360.0-84.771088834352080.0Research Space Scientistmbland@usgs.govSouthwest Region: ASTROGEOLOGY SCIENCE CENTERMichael T BlandNASA's Galileo Mission Solid State Imaging Team 2021Bland, Michael{{}}{{}}Photogrammetrically Controlled, Equirectangular Galileo Image Mosaics of Europaraster digital data Flagstaff, AZ U. S. Geological Survey The Solid State Imager (SSI) on NASA's Galileo spacecraft provided the only moderate- to high-resolution images of Jupiter's moon, Europa. Unfortunately, uncertainty in the position and pointing of the spacecraft, as well as the position and orientation of Europa, when the images were acquired resulted in significant errors in image locations on the surface. The result of these errors is that images acquired during different Galileo orbits, or even at different times during the same orbit, are significantly misaligned (errors of up to 100 km on the surface). Previous work has generated global mosaics of Galileo and Voyager images that photogrammetrically control a subset of the available images to correct their relative locations. However, these efforts result in a "static" mosaic that is projected to a consistent pixel scale, and only use a fraction of the dataset (e.g., high resolution images are not included). The purpose of this current dataset is to increase the usability of the entire Galileo image set by photogrammetrically improving the locations of nearly every Europa image acquired by Galileo, and making them available to the community at their native resolution and in easy-to-use regional mosaics based on their acquisition time. The dataset therefore provides a set of image mosaics that can be used for scientific analysis and mission planning activities.The Solid State Imager (SSI) on NASA's Galileo spacecraft acquired more than 500 images of Jupiter's moon, Europa, providing the only moderate- to high-resolution images of the moon's surface. Images were acquired as observation sequences during each orbit that targeted the moon. Each of these observation sequences consists of between 1 and 19 images acquired close in time, that typically overlap, have consistent illumination and similar pixel scale. The observations vary from relatively low-resolution hemispherical imaging, to high-resolution targeted "postage stamps". Here we provide average mosaics of each of the individual observation sequences acquired by the Galileo spacecraft. These observation mosaics were constructed from a set of 481 Galileo images that were photogrammetrically controlled globally (along with 221 Voyager 1 and 2 images) to improve their relative locations on Europa's surface. The 92 observation mosaics provide users with nearly the entire Galileo Europa imaging dataset at it's native resolution and with improved relative image locations. 2021publication date Complete Irregular Planetary ScienceRemote sensing imagesPhotogrammetryEuropaJupiterGalileoSolid State ImagermosaicUSGS Thesaurus EuropaIAU Gazzeteer of Planetary Nomenclature Galileo SpacecraftSolid State Imager none The dataset includes 481 Galileo images with pixel scale between 5.7 m/pixel and 19532.4 m/pixel. 33 Galileo images of Europa (i.e., with Target=Europa in the label) were not included because 1) they contained no visible target (usually navigation or eclipse images), or 2) there was significant ghosting of the target, or 3) they were too noisy to identify features, or 4) they had very high emission angles and saturation levels (E19 eclipse images). These images were combined into 92 different observation mosaics that cover most of Europa's surface, with the exception of the polar regions. No formal attribute accuracy tests were conducted See Processing The root mean square (RMS) uncertainties in latitude, longitude, and radius are 246.6, 307.0, and 70.5 m, respectively. The total RMS uncertainty is 0.32 pixels. 2020In order to improve the locations of Galileo and Voyager images we developed a global network of image tie points (a control network) using the USGS' Integrated Software for Imagers and Spectrometers (ISIS). The control network is the input to the photogrammetric control process, in which a least-square bundle adjustment is performed to triangulate the ground coordinates (latitude, longitude, and radius) of each tie point and minimize location residuals globally. We used ISIS’ jigsaw application to perform all of the bundle adjustments. In order to create a global control network for Europa images, we first generated three independent networks: a Voyager-only network, a Galileo-only network, and a “bridge” network that included key Voyager and Galileo images. Each of these networks was bundle adjusted separately to ensure a “clean” network (i.e., free from image mis-registrations). The three clean networks were then merged into a single network and bundled together to update images locations. The final bundle solution used constraints of 500 m in radius and 1 degree on camera angles. We adjusted the orientation of Europa (parameterized as the prime meridian offset Wo) to ensure the data are aligned with the IAU-defined coordinate system for Europa (i.e., the longitude of the crater Cilix must be at 182 degrees west, or 178 degrees east). We then used ISIS to trim each image to remove regions with high emission and incidence angles. In general, we set the maximum emission and incidence angle to 90 degrees; however, 25 images used maximum angles between 80 and 90 degrees to remove distorted data. ISIS was then used to project all images within a single observation to a common pixel scale (equivalent to the smallest pixel scale in the observation sequence, pixel scales typically only varied by 10s of meters between images) and equirectangular projection. Average mosaics were created using ISIS' automos application. Additional details are provided in Bland et al. 2021. Galileo SSI Imaging Team 2009 Galileo SSI Europa Images remote-sensing image Space Science reviews Kluwer Academis Publishers Belton et al. 1992 https://pds-imaging.jpl.nasa.gov/volumes/galileo.html#gllSSIREDR Digital and/or Hardcopy 1996 2009 observed Galileo SSI Europa Images Raw Images 13286511328PixelRaster Unless otherwise stated, all data, metadata and related materials are considered to satisfy the quality standards relative to the purpose for which the data were collected. Although these data and associated metadata have been reviewed for accuracy and completeness and approved for release by the U.S. Geological Survey (USGS), no warranty expressed or implied is made regarding the display or utility of the data for other purposes, nor on all computer systems, nor shall the act of distribution constitute any such warranty. Any use of trade, firm, or product names is for descriptive purposes only and does not imply endorsement by the U.S. Government. mbland@usgs.gov928-556-7080 Michael T BlandSouthwest Region: ASTROGEOLOGY SCIENCE CENTER Research Space Scientist US86001AZFlagstaff
2255 North Gemini Drive
mailing and physical
Digital DataNone
20210226 Michael T Bland Southwest Region: ASTROGEOLOGY SCIENCE CENTER Research Space Scientist mailing and physical
2255 North Gemini Drive
Flagstaff AZ 86001 US
928-556-7080 mbland@usgs.gov
Content Standard for Digital Geospatial Metadata FGDC-STD-001-1998
```

The section equirect:

              <equirect>
                <stdparll>0</stdparll>
                <longcm>0</longcm>
                <feast>0</feast>
                <fnorth>0</fnorth>
              </equirect>

can be any one of a number of projections with a varied number of required fields. I am happy to implement equirectangular, and polar stereographic for my current use case. I mention this because I will try to have as generic a solution as possible because we have a number of different projections to support.

Thanks and very happy to continue the conversation and submit a PR back with changes to support projections. Much appreciate the library!

dharvey-consbio commented 3 years ago

@jlaura, I'm working on this now. I'm also adding this specific example to the tests. I hope to have something working for you soon. So glad you appreciate the library!

dharvey-consbio commented 3 years ago

Hi @jlaura,

I was able to get a complex projection data structure to work. I added it to the tests. Here is the commit: https://github.com/consbio/gis-metadata-parser/commit/929e79dd937e427bd1242e901e035b2a8be87c9a

I'm not sure exactly what was amiss in your original code, but you can copy the CustomFgdcParser class directly from tests.py for a working example. Please let me know if you encounter any issues.

I'm closing this issue for now, but feel free to reopen if I missed something.

Thanks for taking the time to submit an issue!