C# Download SRTM HGT Files
C# Download SRTM HGT Files
Hi there,
I have a simple issue when i try to download HGT file from earthdata via unity+ C#
I'm Getting this Error :
WebException: The remote server returned an error: (401) Unauthorized.
Any Help would be grateful.
My Script :
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using UnityEngine;
public class DownloadSRTM : MonoBehaviour
{
public string FileUrl = "https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/2000.02.11/N38E001.SRTMGL1.hgt.zip";
public string User = "username";
public string Pass = "userpassword";
public string DownloadPath = @"D:\SRTM\srtm.zip";
// Start is called before the first frame update
async void Start()
{
await SRTMDownload();
}
// Update is called once per frame
void Update()
{
}
private async Task SRTMDownload()
{
var client = new WebClient();
client.Credentials = new NetworkCredential(User, Pass, "https://e4ftl01.cr.usgs.gov");
client.UseDefaultCredentials = true;
await client.DownloadFileTaskAsync(new Uri(FileUrl),DownloadPath);
}
}
I have a simple issue when i try to download HGT file from earthdata via unity+ C#
I'm Getting this Error :
WebException: The remote server returned an error: (401) Unauthorized.
Any Help would be grateful.
My Script :
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using UnityEngine;
public class DownloadSRTM : MonoBehaviour
{
public string FileUrl = "https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/2000.02.11/N38E001.SRTMGL1.hgt.zip";
public string User = "username";
public string Pass = "userpassword";
public string DownloadPath = @"D:\SRTM\srtm.zip";
// Start is called before the first frame update
async void Start()
{
await SRTMDownload();
}
// Update is called once per frame
void Update()
{
}
private async Task SRTMDownload()
{
var client = new WebClient();
client.Credentials = new NetworkCredential(User, Pass, "https://e4ftl01.cr.usgs.gov");
client.UseDefaultCredentials = true;
await client.DownloadFileTaskAsync(new Uri(FileUrl),DownloadPath);
}
}
Filters:
-
- User Services
- Posts: 349
- Joined: Mon Sep 30, 2019 12:39 pm America/New_York
- Has thanked: 10 times
Re: C# Download SRTM HGT Files
We have forwarded your inquiry to our Subject Matter expert for further guidance.
-
- Subject Matter Expert
- Posts: 71
- Joined: Tue Nov 12, 2019 4:02 pm America/New_York
- Been thanked: 3 times
Re: C# Download SRTM HGT Files
@sisocano,
We may have to put out a call for someone more familiar with C#, but I did potentially notice something in your script. I think the URL in the following line is incorrect.
Try substituting "https://e4ftl01.cr.usgs.gov" with "urs.earthdata.nasa.gov".
Let us know if that works.
We may have to put out a call for someone more familiar with C#, but I did potentially notice something in your script. I think the URL in the following line is incorrect.
Code: Select all
client.Credentials = new NetworkCredential(User, Pass, "https://e4ftl01.cr.usgs.gov");
Let us know if that works.
Re: C# Download SRTM HGT Files
Hi there,
Thanks for the quick replay, i have found a solution in that link.
https://wiki.earthdata.nasa.gov/pages/viewpage.action?pageId=76519934
Best Regards
Thanks for the quick replay, i have found a solution in that link.
https://wiki.earthdata.nasa.gov/pages/viewpage.action?pageId=76519934
Best Regards