Select satellite image and assign datalayer
This commit is contained in:
@@ -67,7 +67,7 @@ namespace FarmmapsNbs
|
||||
|
||||
private async Task Process(List<UserRoot> roots, NitrogenInput input)
|
||||
{
|
||||
// specify if you are using an already created cropfield:
|
||||
// !!specify if you are using an already created cropfield:
|
||||
bool useCreatedCropfield = false;
|
||||
var plantingDate = input.PlantingDate;
|
||||
var measurementDate = input.MeasurementDate;
|
||||
@@ -121,12 +121,12 @@ namespace FarmmapsNbs
|
||||
}
|
||||
|
||||
|
||||
// Find most recent satellite item
|
||||
Item recentSatalliteItem = await _generalService.FindSatelliteItems(cropfieldItem, _settings.SatelliteTaskCode);
|
||||
// Select a particular satellite item from satelliteTask
|
||||
Item satalliteItem = await _generalService.FindSatelliteItem(cropfieldItem, _settings.SatelliteTaskCode);
|
||||
|
||||
|
||||
// must be ndvi[0] or wdvi[1]
|
||||
var inputType = (recentSatalliteItem.Data["layers"] as JArray)?[1]["name"].ToString();
|
||||
// must be wdvi[1]
|
||||
var inputType = (satalliteItem.Data["layers"] as JArray)?[1]["name"].ToString();
|
||||
if (string.IsNullOrEmpty(inputType))
|
||||
{
|
||||
_logger.LogError("Could not get the input type name from the satellite item");
|
||||
@@ -135,10 +135,14 @@ namespace FarmmapsNbs
|
||||
|
||||
// download the geotiff
|
||||
_logger.LogInformation("Downloading geotiff file");
|
||||
await _farmmapsApiService.DownloadItemAsync(recentSatalliteItem.Code,
|
||||
await _farmmapsApiService.DownloadItemAsync(satalliteItem.Code,
|
||||
Path.Combine(DownloadFolder, $"nbs_inputSatelliteGeotiff_{input.OutputFileName}.zip"));
|
||||
|
||||
geotiffItem = recentSatalliteItem;
|
||||
|
||||
// overwrite measurement date by date of satellite item
|
||||
measurementDate = satalliteItem.DataDate.Value;
|
||||
|
||||
geotiffItem = satalliteItem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -225,8 +229,7 @@ namespace FarmmapsNbs
|
||||
_logger.LogInformation("Calculating application map");
|
||||
var applicationMapItem =
|
||||
await _nitrogenService.CalculateApplicationMap(cropfieldItem, geotiffItem, plantingDate,
|
||||
measurementDate,
|
||||
input.InputVariable, targetNData.TargetN);
|
||||
measurementDate, input.InputVariable, targetNData.TargetN, input.InputLayerName);
|
||||
|
||||
if (applicationMapItem == null)
|
||||
{
|
||||
@@ -238,25 +241,25 @@ namespace FarmmapsNbs
|
||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.application.zip"));
|
||||
_logger.LogInformation("Application map can be found in {0}", Path.Combine(DownloadFolder, $"{input.OutputFileName}.application.zip"));
|
||||
|
||||
//transforming tiff to shape
|
||||
var tiffItem = applicationMapItem;
|
||||
// //transforming tiff to shape
|
||||
// var tiffItem = applicationMapItem;
|
||||
|
||||
if (tiffItem == null)
|
||||
{
|
||||
_logger.LogError("Could not find item for uploaded data");
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation($"Converting geotiff to shape");
|
||||
var taskmap = await _generalService.GeotiffToShape(tiffItem);
|
||||
if (taskmap == null)
|
||||
{
|
||||
_logger.LogError("Something went wrong with geotiff to shape transformation");
|
||||
return;
|
||||
}
|
||||
// if (tiffItem == null)
|
||||
// {
|
||||
// _logger.LogError("Could not find item for uploaded data");
|
||||
// return;
|
||||
// }
|
||||
// _logger.LogInformation($"Converting geotiff to shape");
|
||||
// var taskmap = await _generalService.GeotiffToShape(tiffItem);
|
||||
// if (taskmap == null)
|
||||
// {
|
||||
// _logger.LogError("Something went wrong with geotiff to shape transformation");
|
||||
// return;
|
||||
// }
|
||||
|
||||
_logger.LogInformation("Downloading taskmap");
|
||||
await _farmmapsApiService.DownloadItemAsync(taskmap.Code,
|
||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.taskmap.zip"));
|
||||
// _logger.LogInformation("Downloading taskmap");
|
||||
// await _farmmapsApiService.DownloadItemAsync(taskmap.Code,
|
||||
// Path.Combine(DownloadFolder, $"{input.OutputFileName}.taskmap.zip"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user