DOI-USGS / fort-pymdwizard

The MetadataWizard is a useful tool designed to facilitate FGDC metadata creation for spatial and non-spatial data sets. It is a cross-platform desktop application built using an open-source Python architecture.
https://usgs.github.io/fort-pymdwizard/
Other
62 stars 21 forks source link

remove EPSG 4326 to allow for planetary bounds (untested) #175

Open thareUSGS opened 1 year ago

thareUSGS commented 1 year ago

To fix the calculation for planetary codes in the latest version, this code can likely be updated from:

    srs = get_ref(layer)
    srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
    target = osr.SpatialReference()
    target.ImportFromEPSG(4326)
    target.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)

https://github.com/DOI-USGS/fort-pymdwizard/blob/225193692f9399b20d44905d7cf8e58441e428bd/pymdwizard/core/spatial_utils.py#L142C1-L143C32

to:

    srs = get_ref(layer)
    srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
    # Get the body (planet or moon, Earth is a planet too ;-) from the projection definition
    # removes the lock-in to EPSG:4326 (WGS84)
    target = srs.CloneGeogCS()
    target.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
tnorkin commented 1 year ago

@thareUSGS, thanks very much for the suggested fix!

thareUSGS commented 1 year ago

Tested for a few Mars GeoTIFFs and Shapefiles. Seems to fix it.

BTW, this could actually be more accurate for Earth datasets. Forcing all Earth calculations to WGS84 (as new definitions for Earth are released) could end up being bad.