ajnisbet / opentopodata

Open alternative to the Google Elevation API!
https://www.opentopodata.org
MIT License
312 stars 69 forks source link

Trouble building/using the EMOD dataset #61

Closed bjorn-iversen closed 2 years ago

bjorn-iversen commented 2 years ago

Hello,

I'm having some trouble building/using the EMOD dataset. I downloaded the 2020 version of the dataset from the website referenced in the docs, and managed to build a single .vrt file and linking it in config.yaml, although gdalbuildvrt doesn't recognize -co as an option, so I tried to set VRT_SHARED_SOURCE=0 as an environment variable instead (perhaps this is wrong? I'm not that familiar with the gdal toolchain and geospatial data in general, unfortunately). The linking of the dataset in config.yaml seems to work, but when I try to query a location, I get the following error message:

{
  "error": "Dataset has no coordinate reference system. Check the file 'data/emod2020-vrt/emod2020.vrt' is a geo raster. Otherwise you'll have to add the crs manually with a tool like gdaltranslate.", 
  "status": "INVALID_REQUEST"
}

I've also tried using the option -oo, but that results in the same error.

Any pointers here would be greatly appreciated.

ajnisbet commented 2 years ago

Hi there, sorry you're having this issue!

For starters, here's what my .vrt file for that dataset on the public API looks like (a .vrt file is in XML format):

<VRTDataset rasterXSize="75841" rasterYSize="72001">
  <SRS>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]</SRS>
  <GeoTransform> -3.6000000120000003e+01,  1.0416666699999985e-03,  0.0000000000000000e+00,  9.0000000290040006e+01,  0.0000000000000000e+00, -1.0416666699999985e-03</GeoTransform>
  <VRTRasterBand dataType="Float32" band="1">
    <NoDataValue>99</NoDataValue>
    <ColorInterp>Gray</ColorInterp>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">../emod-2018/A1.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="9492" RasterYSize="9012" DataType="Float32" BlockXSize="9492" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="9492" ySize="9012" />
      <DstRect xOff="0" yOff="0" xSize="9492" ySize="9012" />
      <NODATA>99</NODATA>
    </ComplexSource>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">../emod-2018/A2.tif</SourceFilename>

the <SRS> tag refers to the coordinate reference system (CRS) that the error message says is missing. Could you check if your .vrt file has that?

The next thing to check is that the source files (A1.asc or A1.tif) have correct CRS info. If you run

gdalinfo A1_2018.asc

you should get a section called Coordinate System is

Driver: GTiff/GeoTIFF
Files: A1.tif
Size is 9492, 9012
Coordinate System is:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (-36.000000120000003,90.000000290040006)
Pixel Size = (0.001041666670000,-0.001041666670000)

let me know if your files are missing that: we might have to manually set the CRS if it's missing.

The last thing is the version of gdal: I don't think it's a huge problem if VRT_SHARED_SOURCE isn't set, though it may point to an issue with your gdal installation (it's infamously very hard to install!!!) Could you let me know what version of gdal you're using, and what platform?

gdalinfo --version
# GDAL 3.3.2, released 2021/09/01
bjorn-iversen commented 2 years ago

Thanks for the thorough answer!

  1. My .vrt file seems to be missing the <SRS> tag.
  2. When I run gdalinfo A1_2020.asc, the output I get is missing the "Coordinate System is" bit.
  3. I'm running GDAL 3.0.4, released 2020/01/28, inside WSL with a Ubuntu 20.04 distribution. I installed it using sudo apt install gdal-bin, I believe.
ajnisbet commented 2 years ago

Thanks for that info!

I think there is a bug in the instructions (I personally converted the files to .tif first, so mustn't have testet the .asc instructions).

Could you try this command instead:

gdalbuildvrt -a_srs=epsg:4326 emod2018.vrt ../emod2018/*.asc

Let me know if it works and I can update the instructions!

bjorn-iversen commented 2 years ago

Seems to have fixed the issue (at least I get an elevation for a given query point)! I ran the command you wrote above, but for me at least, I had to remove the = in -a_srs=epsg:4326 and replace it with a space. I also used the 2020 dataset.

ajnisbet commented 2 years ago

I've updated the documentation, thanks for helping to improve opentopodata!