HydrologicEngineeringCenter / Vortex

data processing utilities
MIT License
26 stars 7 forks source link

java.lang.RuntimeException: java.lang.RuntimeException: OGR Error: General Error #55

Closed danhamill closed 2 years ago

danhamill commented 2 years ago

With this grid UTQI_SM_030m_roff_2003_04_10.zip I am trying to import to dss and get the following traceback:

  File "C:\workspace\temp\scripts\vortex\import_HMET.py", line 32, in <module>
    myImport.process()
        at org.gdal.osr.osrJNI.SpatialReference_ExportToWkt__SWIG_1(Native Method)
        at org.gdal.osr.SpatialReference.ExportToWkt(SpatialReference.java:674)
        at org.gdal.osr.SpatialReference.ExportToWkt(SpatialReference.java:60)
        at mil.army.usace.hec.vortex.geo.RasterUtils.getDatasetFromVortexGrid(RasterUtils.java:46)
        at mil.army.usace.hec.vortex.geo.Resampler.resample(Resampler.java:96)
        at mil.army.usace.hec.vortex.io.ImportableUnit.lambda$process$0(ImportableUnit.java:143)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfInt.accept(ForEachOps.java:204)
        at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104)
        at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:711)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:686)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfInt.evaluateParallel(ForEachOps.java:188)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at java.base/java.util.stream.IntPipeline.forEach(IntPipeline.java:463)
        at java.base/java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:620)
        at mil.army.usace.hec.vortex.io.ImportableUnit.process(ImportableUnit.java:122)
        at mil.army.usace.hec.vortex.io.BatchImporter.lambda$process$3(BatchImporter.java:129)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:686)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765)
        at mil.army.usace.hec.vortex.io.BatchImporter.process(BatchImporter.java:121)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
java.lang.RuntimeException: java.lang.RuntimeException: OGR Error: General Error

The source grid is in EPSG 32604. The nedcdf file originated from SnowModel and does not follow the CF metadata Conventions. Do you think this is realted to the projection, or does it have to do with the structure of the NetCDF file?

tombrauer commented 2 years ago

A troubleshooting measure: Do you have any errors if you use gdal_translate to go from NetCDF to say, GeoTIFF?

danhamill commented 2 years ago

No errors. gdalsrsinfo appears to be the same for the .nc and .tif file formats

C:\workspace\temp\Data>gdal_translate -of GTIFF UTQI_SM_030m_roff_2003_04_10.nc UTQI_SM_030m_roff_2003_04_10.tif
Input file size is 391, 424
0...10...20...30...40...50...60...70...80...90...100 - done.

C:\workspace\temp\Data>gdalsrsinfo UTQI_SM_030m_roff_2003_04_10.nc

PROJ.4 : +proj=utm +zone=4 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

OGC WKT :
PROJCS["UTM Zone 4, Northern Hemisphere",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9108"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-159],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]

C:\workspace\temp\Data>gdalsrsinfo UTQI_SM_030m_roff_2003_04_10.tif

PROJ.4 : +proj=utm +zone=4 +datum=WGS84 +units=m +no_defs

OGC WKT :
PROJCS["WGS 84 / UTM zone 4N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-159],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","32604"]]
tombrauer commented 2 years ago

I added handling for the transverse mercator projection. There was none there previously and given that no one has reported this before, I suspect it's not that common for distributing scientific data.

The projection parameters look correct for the imported grid: image

The grid data looks like: image

Notice the pathname parts have no parameters. I'm guessing this is because the file is not CF, so vortex can't provide all of the automated parsing that it normally would.

danhamill commented 2 years ago

Thanks Tom!

tombrauer commented 2 years ago

I added an rc release here if you want to test.

danhamill commented 2 years ago

Thanks Tom. 

The data are from the north slope of Alaska.  It’s not surprising that most people don’t use that projection.  I wonder how accurate utm grids are that far north.  

I’ll report back on our tests.   

On December 15, 2021, nnk2193 @.***> wrote:

I added an rc release here https://github.com/HydrologicEngineeringCenter/Vortex/releases/tag/v0.10.27- rc.1 if you want to test.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HydrologicEngineeringCenter/Vortex/issues/55#issuecomment- 995357560, or unsubscribe https://github.com/notifications/unsubscribe- auth/ACX5GUQZPIZKKTZTXNZK3L3URE6FHANCNFSM5KEIBVUA.

danhamill commented 2 years ago

Tests are looking good!