updated poten&nbs, both work properly again

This commit is contained in:
Riepma 2021-04-12 17:01:17 +02:00
parent c7ab62c911
commit 89d2af5944
17 changed files with 220 additions and 544 deletions

View File

@ -37,9 +37,10 @@ namespace FarmmapsApi.Services
return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
}
public async Task<Item> UploadDataAsync(UserRoot root, string itemType, string filePath, string itemName, string fieldGeomJson = null) {
public async Task<Item> UploadDataAsync(UserRoot root, string itemType, string filePath, string itemName, string geoJsonString = null)
{
var startUpload = DateTime.UtcNow.AddSeconds(-3);
var result = await _farmmapsApiService.UploadFile(filePath, root.Code, fieldGeomJson,
var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString,
progress => _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}"));
if (result.Progress.Status == UploadStatus.Failed)
@ -50,9 +51,9 @@ namespace FarmmapsApi.Services
i.Name.ToLower().Contains(itemName.ToLower()));
}
public async Task<Item> UploadZipWithShapeAsync(UserRoot root, string filePath, string itemName, string fieldGeomJson = null) {
var startUpload = DateTime.UtcNow;
var result = await _farmmapsApiService.UploadFile(filePath, root.Code, fieldGeomJson,
public async Task<Item> UploadZipWithShapeAsync(UserRoot root, string filePath, string itemName, string geoJsonString = null) {
var startUpload = DateTime.UtcNow.AddSeconds(-3);
var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString,
progress => _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}"));
if (result.Progress.Status == UploadStatus.Failed)

View File

@ -23,8 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmMapsBlight", "FarmMapsB
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsZonering", "FarmmapsZonering\FarmmapsZonering.csproj", "{91A58C4A-4A80-4079-B43D-9B851206194F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmmapsPoten_AVRapi", "FarmmapsPoten_AVRapi\FarmmapsPoten_AVRapi.csproj", "{E220AA18-D735-4B07-859B-C0DA11CD1E8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -59,10 +57,6 @@ Global
{91A58C4A-4A80-4079-B43D-9B851206194F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A58C4A-4A80-4079-B43D-9B851206194F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A58C4A-4A80-4079-B43D-9B851206194F}.Release|Any CPU.Build.0 = Release|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -132,11 +132,11 @@ namespace FarmmapsHaulmkilling
}
var selectedAgent = agents[0];
var selectedOption = selectedAgent.SupportedOptions[0];
var selectedOption = selectedAgent.ValidOptions[0];
_logger.LogInformation("Calculating application map");
var applianceMapItem = await _haulmkillingService.CalculateApplicationMapAsync(cropfieldItem,
firstSatelliteItem, inputType, selectedAgent.Name, selectedOption);
firstSatelliteItem, inputType, selectedOption, selectedAgent);
if (applianceMapItem == null)
{
return;

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
@ -6,6 +7,7 @@ using FarmmapsApi.Models;
using FarmmapsApi.Services;
using FarmmapsHaulmkilling.Models;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using static FarmmapsApi.Extensions;
using static FarmmapsApiSamples.Constants;
@ -31,14 +33,11 @@ namespace FarmmapsHaulmkilling
/// <returns>List of haulmkilling agents</returns>
public async Task<List<HaulmkillingAgent>> GetHaulmkillingAgents()
{
var itemType = "vnd.farmmaps.package.vra.haulmkilling";
var vraHerbicideDataItems = await _farmmapsApiService.GetItemsAsync(string.Empty, itemType);
var itemType = "vnd.farmmaps.itemtype.codelist.fm005";
var haulmkillingAgentItems = await _farmmapsApiService.GetItemsAsync(string.Empty, itemType);
var item = vraHerbicideDataItems.FirstOrDefault();
if (item == null)
return null;
return item.Data.ContainsKey("agents") ? item.Data["agents"].ToObject<List<HaulmkillingAgent>>() : null;
return haulmkillingAgentItems.Select(item => item.Data.ToObject<HaulmkillingAgent>())
.ToList();
}
/// <summary>
@ -47,11 +46,11 @@ namespace FarmmapsHaulmkilling
/// <param name="cropfieldItem">The context cropfield item to use</param>
/// <param name="inputItem">The geotiff item to use</param>
/// <param name="inputType">WDVI or NDVI</param>
/// <param name="agentName">One of the available agents</param>
/// <param name="agentCode">code of one of the available agents</param>
/// <param name="selectedOption">One of the available options</param>
/// <returns>Haulmkilling application map item</returns>
public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string inputType,
string agentName, string selectedOption)
string selectedOption, HaulmkillingAgent agent)
{
var taskRequest = new TaskRequest()
{
@ -59,7 +58,7 @@ namespace FarmmapsHaulmkilling
};
taskRequest.attributes["inputCode"] = inputItem.Code;
taskRequest.attributes["inputType"] = inputType;
taskRequest.attributes["agentName"] = agentName;
taskRequest.attributes["agentCode"] = agent.Code;
taskRequest.attributes["selectedOption"] = selectedOption;
taskRequest.attributes["minPercentile"] = "0.0";
@ -79,7 +78,7 @@ namespace FarmmapsHaulmkilling
return null;
}
var itemName = $"VRAHaulmkilling {agentName}";
var itemName = $"VRAHaulmkilling {agent.Label}";
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
i => i.Updated >= itemTask.Finished &&

View File

@ -5,26 +5,11 @@ namespace FarmmapsHaulmkilling.Models
{
public class HaulmkillingAgent
{
public string Name { get; set; }
public List<string> SupportedOptions { get; set; }
public Dictionary<string, List<HaulmkillingAgentValue>> Values { get; set; }
public string Cl { get; set; }
public string Code { get; set; }
public string Label { get; set; }
public string Options { get; set; }
public HaulmkillingAgentValue? GetAgentValue(string inputName, string optionKey)
{
if (!Values.ContainsKey(inputName))
return null;
var agentDataValues = Values[inputName];
return agentDataValues.FirstOrDefault(v => v.Option.Equals(optionKey));
}
}
public struct HaulmkillingAgentValue
{
public string Option { get; set; }
public float Min { get; set; }
public float Max { get; set; }
public float FMul { get; set; }
public float FExp { get; set; }
public List<string> ValidOptions => Options.Split(',').ToList();
}
}

View File

@ -1,41 +0,0 @@
[
{
"UseCreatedCropfield": false,
"storeStatistics": false,
"file": "20210308 WDVI_Harpreet Singh.tif",
"inputVariable": "wdvi",
//"InputLayerName": "Band 1",
"outputFileName": "2021.03.08.Hapreet_Singh_wdvi08_03",
"plantingDate": "2020-04-15",
"measurementDate": "2020-06-27",
"potatoPurposeType": "consumption",
"targetYield": 27,
"fieldName": "Mahindra-Hapreet-Singh",
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 75.929090780177305, 31.639314978348551 ],
[ 75.931353489378182, 31.639409065494881 ],
[ 75.931432810729120, 31.638956841735819 ],
[ 75.929072617175663, 31.638879365370279 ],
[ 75.929090780177305, 31.639314978348551 ]
]
]
},
"GenerateTaskmap": true,
"CellWidth": "3",
"CellHeight": "20",
"Centered": false,
"StartPoint": {
"type": "Point",
"coordinates": [ 75.931353489378182, 31.639409065494881 ]
},
"EndPoint": {
"type": "Point",
"coordinates": [ 75.929090780177305, 31.639314978348551 ]
} // if no angle
//"Angle": "317.0" // if no endpoint
}
]

View File

@ -18,12 +18,16 @@ namespace FarmmapsNbs.Models
public string fieldName{ get; set; }
public bool storeSatelliteStatistics { get; set; }
public bool GenerateTaskmap { get; set; }
public string OutputType { get; set; }
public string DdiCode { get; set; }
public string CellWidth { get; set; }
public string CellHeight { get; set; }
public bool Centered { get; set; }
public string Centered { get; set; }
public JObject StartPoint { get; set; }
public JObject EndPoint { get; set; }
public string Angle { get; set; }
public string Precision { get; set; }
public string MaximumClasses { get; set; }
}

View File

@ -37,7 +37,7 @@ namespace FarmmapsNbs
public async Task RunAsync()
{
var nitrogenInputJson = File.ReadAllText("InputData-NBS.json"); //NitrogenInput.json
var nitrogenInputJson = File.ReadAllText("NitrogenInput.json");
List<NitrogenInput> nitrogenInputs = JsonConvert.DeserializeObject<List<NitrogenInput>>(nitrogenInputJson);
if (!Directory.Exists(DownloadFolder))
@ -64,7 +64,7 @@ namespace FarmmapsNbs
{
// !!specify if you are using an already created cropfield:
bool useCreatedCropfield = input. UseCreatedCropfield;
bool useCreatedCropfield = input.UseCreatedCropfield;
var plantingDate = input.PlantingDate;
var FieldName = input.fieldName;
bool StoreStatistics = input.storeSatelliteStatistics;
@ -105,12 +105,14 @@ namespace FarmmapsNbs
var geotiffItem = (Item)null;
// No file input, use most recent satellite image
if (string.IsNullOrEmpty(input.File)) {
// If no input file is specified, use most recent satellite image
if (string.IsNullOrEmpty(input.File))
{
_logger.LogInformation("No specific data given, retrieving most recent satellite image");
// check if satellite task not yet done, do here and save taskcode
if (useCreatedCropfield == false || string.IsNullOrEmpty(_settings.SatelliteTaskCode)) {
if (useCreatedCropfield == false || string.IsNullOrEmpty(_settings.SatelliteTaskCode))
{
var satelliteTaskCode = await _generalService.RunSatelliteTask(cropfieldItem);
_settings.SatelliteTaskCode = satelliteTaskCode;
SaveSettings(settingsfile);
@ -126,14 +128,17 @@ namespace FarmmapsNbs
//Console.WriteLine($"Satellite image statistics for band {satelliteBand}: {satelliteStatistics}");
//Store data to csv
if (StoreStatistics==true) {
var SatelliteFile = $"C:\\Akkerweb\\DataSatellite_{FieldName}.csv";
if (StoreStatistics == true)
{
var SatelliteFile = $"\\Downloads\\DataSatellite_{FieldName}.csv";
var NewLineField = $"\"Field\":{FieldName}" + Environment.NewLine;
var NewLineDate = $"\"date\":{satalliteItem.DataDate}" + Environment.NewLine;
var i = 0;
foreach (var item in satelliteStatistics) {
foreach (var item in satelliteStatistics)
{
//var NewLines2;
if (i == 0) {
if (i == 0)
{
File.AppendAllText(SatelliteFile, NewLineDate);
i++;
}
@ -145,7 +150,8 @@ namespace FarmmapsNbs
// must be wdvi[1]
var inputType = (satalliteItem.Data["layers"] as JArray)?[1]["name"].ToString();
if (string.IsNullOrEmpty(inputType)) {
if (string.IsNullOrEmpty(inputType))
{
_logger.LogError("Could not get the input type name from the satellite item");
return;
}
@ -167,34 +173,39 @@ namespace FarmmapsNbs
// (geo)tiff input:
else if (input.File.Contains(".tif") || input.File.Contains(".geotiff")) {
else if (input.File.Contains(".tif") || input.File.Contains(".geotiff"))
{
_logger.LogInformation("input = tiff data");
var dataPath = Path.Combine("Data", input.File);
geotiffItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE, dataPath,
Path.GetFileNameWithoutExtension(input.File));
if (geotiffItem == null) {
if (geotiffItem == null)
{
_logger.LogError("Could not find item for uploaded data");
return;
}
}
// json/shape input
else {
else
{
var isGeoJson = input.File.Contains("json");
var dataPath = Path.Combine("Data", input.File);
var shapeItem = isGeoJson ?
await _generalService.UploadDataAsync(uploadedRoot, SHAPE_PROCESSED_ITEMTYPE, dataPath, Path.GetFileNameWithoutExtension(input.File)) :
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.File));
await _generalService.UploadDataAsync(uploadedRoot, SHAPE_PROCESSED_ITEMTYPE, dataPath, Path.GetFileNameWithoutExtension(input.File), input.GeometryJson.ToString(Formatting.None)) :
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.File), input.GeometryJson.ToString(Formatting.None));
if (shapeItem == null) {
if (shapeItem == null)
{
_logger.LogError("Could not find item for uploaded data");
return;
}
_logger.LogInformation($"Converting shape to geotiff");
geotiffItem = await _generalService.ShapeToGeotiff(shapeItem);
if (geotiffItem == null) {
if (geotiffItem == null)
{
_logger.LogError("Something went wrong with shape to geotiff transformation");
return;
}
@ -226,7 +237,8 @@ namespace FarmmapsNbs
var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate,
measurementDate, input.PotatoPurposeType, input.TargetYield);
if (targetNData == null) {
if (targetNData == null)
{
_logger.LogError("Something went wrong with TargetN calculation");
return;
}
@ -244,7 +256,8 @@ namespace FarmmapsNbs
var uptakeMapItem =
await _nitrogenService.CalculateUptakeMap(cropfieldItem, geotiffItem, plantingDate,
measurementDate, input.InputVariable, input.InputLayerName);
if (uptakeMapItem == null) {
if (uptakeMapItem == null)
{
_logger.LogError("Something went wrong with creating the uptakeMap");
return;
}
@ -252,57 +265,79 @@ namespace FarmmapsNbs
_logger.LogInformation("Downloading uptake map");
await _farmmapsApiService.DownloadItemAsync(uptakeMapItem.Code,
Path.Combine(DownloadFolder, $"{input.OutputFileName}.uptake.zip"));
_logger.LogInformation("UptakeMap downloaded to {0}", Path.Combine(DownloadFolder, $"{input.OutputFileName}.uptake.zip"));
_logger.LogInformation("UptakeMap downloaded");
_logger.LogInformation("Calculating application map");
var applicationMapItem =
var applianceMapItem =
await _nitrogenService.CalculateApplicationMap(cropfieldItem, geotiffItem, plantingDate,
measurementDate, input.InputVariable, targetNData.TargetN, input.InputLayerName);
if (applicationMapItem == null) {
if (applianceMapItem == null)
{
_logger.LogError("Something went wrong with creating the applicationMap");
return;
}
_logger.LogInformation("Downloading application map");
await _farmmapsApiService.DownloadItemAsync(applicationMapItem.Code,
await _farmmapsApiService.DownloadItemAsync(applianceMapItem.Code,
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;
var tiffItem = applianceMapItem;
if (tiffItem == null) {
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;
//}
//ApplicationMap (GEOTIFF) To Taskmap
_logger.LogInformation($"Converting geotiff to taskmap");
var taskmap = await _generalService.CreateTaskmap(cropfieldItem, tiffItem, input.CellWidth, input.CellHeight, input.StartPoint.ToString(Formatting.None),
input.Centered.ToString(), input.EndPoint.ToString(Formatting.None), input.Angle);
if (taskmap == null)
if (input.GenerateTaskmap)
{
_logger.LogError("Something went wrong with geotiff to shape transformation");
return;
//GEOTIFF TO Taskmap
_logger.LogInformation($"Converting geotiff to taskmap");
var taskmap = (Item)null;
if (input.OutputType == "isoxml")
{
if (input.DdiCode == null)
{
_logger.LogInformation("DDi not given. Using expected identifiers");
input.DdiCode = input.DdiCode = "0006";
}
taskmap = await _generalService.CreateTaskmap(cropfieldItem: cropfieldItem, tiffItem: applianceMapItem, outputType: input.OutputType, cellWidth: input.CellWidth,
cellHeight: input.CellHeight, startPoint: input.StartPoint.ToString(Formatting.None), ddiCode: input.DdiCode, centered: input.Centered,
endPoint: input.EndPoint.ToString(Formatting.None), angle: input.Angle, precision: input.Precision,
cropTypeName: null, costumerName: null, ProductGroupName: null, productName: null, resolution: null, unitScale: null, maximumClasses: input.MaximumClasses);
}
else
{
taskmap = await _generalService.CreateTaskmap(cropfieldItem: cropfieldItem, tiffItem: applianceMapItem, outputType: input.OutputType, cellWidth: input.CellWidth,
cellHeight: input.CellHeight, startPoint: input.StartPoint.ToString(Formatting.None), centered: input.Centered,
endPoint: input.EndPoint.ToString(Formatting.None), angle: input.Angle, precision: input.Precision, maximumClasses: input.MaximumClasses);
}
if (taskmap == null)
{
_logger.LogError("Something went wrong with geotiff to taskmap 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"));
}
// Functions to save previously created cropfields
private void LoadSettings(string file)
{
@ -325,7 +360,8 @@ namespace FarmmapsNbs
var json = JsonConvert.SerializeObject(_settings);
File.WriteAllText(file, json);
}
private void SaveInfo(string file) {
private void SaveInfo(string file)
{
if (_settings == null)
return;
@ -334,5 +370,5 @@ namespace FarmmapsNbs
}
}
}
}

View File

@ -1,310 +1,105 @@
[
{
"file": "Scan_1_20190605.json",
"inputVariable": "irmi",
"outputFileName": "vranbs1",
"plantingDate": "2019-04-18",
"measurementDate": "2019-06-05",
"potatoPurposeType": "consumption",
"targetYield": 45,
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 3.40843828875524, 50.638966444680605 ],
[ 3.408953272886064, 50.639197789621612 ],
[ 3.409242951459603, 50.639469958681836 ],
[ 3.409328782148028, 50.639612846807708 ],
[ 3.409457528180712, 50.639789755314411 ],
[ 3.409639918393741, 50.640014292074966 ],
[ 3.409833037442765, 50.640211611372706 ],
[ 3.410069071836049, 50.640395321698435 ],
[ 3.410380208081761, 50.640572227259661 ],
[ 3.410605513638958, 50.640715112034222 ],
[ 3.411925160474145, 50.641177783561204 ],
[ 3.411935889310142, 50.640728720085136 ],
[ 3.412590348309737, 50.63948356709389 ],
[ 3.413244807309242, 50.638224772339846 ],
[ 3.413400375432099, 50.637901562841307 ],
[ 3.413539850300779, 50.637449065809889 ],
[ 3.413475477284437, 50.637418445552932 ],
[ 3.40999396998362, 50.637449065810451 ],
[ 3.409940325803365, 50.638102293212661 ],
[ 3.409575545377398, 50.638483338338325 ],
[ 3.409060561246574, 50.638707881340494 ],
[ 3.40843828875524, 50.638966444680605 ]
]
]
},
//{
//"file": "[...].json",
//"inputVariable": "wdvi",
//"outputFileName": "20201211_Mahindra",
//"plantingDate": "2020-11-25",
//"measurementDate": "2020-12-08",
//"potatoPurposeType": "consumption",
//"targetYield": 45,
//"geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 75.4652734163369, 31.26328617861426 ],
// [ 75.46527659380338, 31.26437743805827 ],
// [ 75.46494267602188, 31.26438166160194 ],
// [ 75.46493257618651, 31.26462192072676 ],
// [ 75.46438242791261, 31.26462132638865 ],
// [ 75.46438225728252, 31.26334267015003 ],
// [ 75.46448543502072, 31.26333463263533 ],
// [ 75.46448842093658, 31.26302891147988 ],
// [ 75.46507631089699, 31.26299589154944 ],
// [ 75.46509039016291, 31.26329023051392 ],
// [ 75.4652734163369, 31.26328617861426 ]
// ]
// ]
//}
//}
//},
//{
// "file": "Scan_1_20190605.zip",
// "inputVariable": "irmi",
// "outputFileName": "vranbs2",
// "plantingDate": "2019-04-18",
// "measurementDate": "2019-06-05",
// "potatoPurposeType": "starch",
// "targetYield": 45,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 3.40843828875524, 50.638966444680605 ],
// [ 3.408953272886064, 50.639197789621612 ],
// [ 3.409242951459603, 50.639469958681836 ],
// [ 3.409328782148028, 50.639612846807708 ],
// [ 3.409457528180712, 50.639789755314411 ],
// [ 3.409639918393741, 50.640014292074966 ],
// [ 3.409833037442765, 50.640211611372706 ],
// [ 3.410069071836049, 50.640395321698435 ],
// [ 3.410380208081761, 50.640572227259661 ],
// [ 3.410605513638958, 50.640715112034222 ],
// [ 3.411925160474145, 50.641177783561204 ],
// [ 3.411935889310142, 50.640728720085136 ],
// [ 3.412590348309737, 50.63948356709389 ],
// [ 3.413244807309242, 50.638224772339846 ],
// [ 3.413400375432099, 50.637901562841307 ],
// [ 3.413539850300779, 50.637449065809889 ],
// [ 3.413475477284437, 50.637418445552932 ],
// [ 3.40999396998362, 50.637449065810451 ],
// [ 3.409940325803365, 50.638102293212661 ],
// [ 3.409575545377398, 50.638483338338325 ],
// [ 3.409060561246574, 50.638707881340494 ],
// [ 3.40843828875524, 50.638966444680605 ]
// ]
// ]
// }
//},
//{
// "file": "Scan_1_20190605.zip",
// "inputVariable": "irmi",
{
"file": "", // keep emptpy to use satellite image
"inputVariable": "wdvi",
"InputLayerName": "wdvi",
"outputFileName": "rtest1",
"plantingDate": "2020-05-01",
"measurementDate": "2020-06-14",
{
"file": "Scan_1_20190605.json",
"inputVariable": "irmi",
"inputLayerName": "",
"outputFileName": "vranbs1",
"plantingDate": "2019-04-18",
"measurementDate": "2019-06-05",
"potatoPurposeType": "consumption",
"targetYield": 60,
"targetYield": 45,
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 4.960707146896585, 52.800583669708487 ],
[ 4.960645975538824, 52.800470217610922 ],
[ 4.962140695752897, 52.799177147194797 ],
[ 4.967523821195745, 52.801502400041208 ],
[ 4.966336768950911, 52.802543735879809 ],
[ 4.961711880764330, 52.801009996856429 ],
[ 4.960707146896585, 52.800583669708487 ]
[ 3.40843828875524, 50.638966444680605 ],
[ 3.408953272886064, 50.639197789621612 ],
[ 3.409242951459603, 50.639469958681836 ],
[ 3.409328782148028, 50.639612846807708 ],
[ 3.409457528180712, 50.639789755314411 ],
[ 3.409639918393741, 50.640014292074966 ],
[ 3.409833037442765, 50.640211611372706 ],
[ 3.410069071836049, 50.640395321698435 ],
[ 3.410380208081761, 50.640572227259661 ],
[ 3.410605513638958, 50.640715112034222 ],
[ 3.411925160474145, 50.641177783561204 ],
[ 3.411935889310142, 50.640728720085136 ],
[ 3.412590348309737, 50.63948356709389 ],
[ 3.413244807309242, 50.638224772339846 ],
[ 3.413400375432099, 50.637901562841307 ],
[ 3.413539850300779, 50.637449065809889 ],
[ 3.413475477284437, 50.637418445552932 ],
[ 3.40999396998362, 50.637449065810451 ],
[ 3.409940325803365, 50.638102293212661 ],
[ 3.409575545377398, 50.638483338338325 ],
[ 3.409060561246574, 50.638707881340494 ],
[ 3.40843828875524, 50.638966444680605 ]
]
]
},
"GenerateTaskmap": true,
"OutputType": "shape", // "shape" or "isoxml" if isoxml also add ddiCode
"Precision": "2",
"MaximumClasses": "4",
"DdiCode": "0006",
"CellWidth": "3",
"CellHeight": "10",
"Centered": "true",
"StartPoint": {
"type": "Point",
"coordinates": [ 3.409341600000000, 50.638991900000001 ]
},
"EndPoint": { // if no angle
"type": "Point",
"coordinates": [ 3.411897000000000, 50.638981500000000 ]
}
}
//,
//"Angle": "317.0" // if no endpoint
},
//{
// "file": "", // keep emptpy to use satellite image
// "inputVariable": "wdvi",
// "InputLayerName": "wdvi",
// "outputFileName": "mtest1",
// "plantingDate": "2020-04-01",
// "measurementDate": "2020-06-24",
// "outputFileName": "rtest1",
// "plantingDate": "2020-05-01",
// "measurementDate": "2020-06-14",
// "potatoPurposeType": "consumption",
// "targetYield": 60,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 3.575458869234128, 51.308707885669762 ],
// [ 3.575508957999423, 51.30878478562019 ],
// [ 3.576188404403633, 51.309372997559777 ],
// [ 3.576188872410267, 51.309374219701091 ],
// [ 3.576210290749152, 51.309430091473608 ],
// [ 3.57621266537704, 51.309483685674898 ],
// [ 3.576213477455834, 51.309502027981374 ],
// [ 3.577543136860447, 51.310682367527122 ],
// [ 3.57796629328866, 51.31104321405175 ],
// [ 3.578442479292087, 51.311449273042747 ],
// [ 3.57866702353106, 51.311636072786726 ],
// [ 3.57880446997978, 51.31157117599529 ],
// [ 3.579155910205885, 51.311863542729718 ],
// [ 3.579175814007489, 51.311875435159394 ],
// [ 3.579293885246395, 51.311936532835396 ],
// [ 3.579413896180069, 51.311998649478575 ],
// [ 3.579514543462617, 51.312041110734917 ],
// [ 3.579611760655688, 51.312082118352606 ],
// [ 3.579635115371588, 51.312093949652223 ],
// [ 3.579793143414486, 51.312189437140432 ],
// [ 3.579966991648108, 51.312286148850511 ],
// [ 3.580079704980967, 51.312332458349751 ],
// [ 3.580203717638148, 51.312336471368539 ],
// [ 3.580307101018293, 51.312330239539847 ],
// [ 3.580383836270609, 51.312317097185243 ],
// [ 3.580505207977176, 51.312279163554869 ],
// [ 3.580610387713855, 51.312233723091026 ],
// [ 3.5806309754483, 51.312226093729677 ],
// [ 3.580638516049738, 51.312223727082049 ],
// [ 3.58075536599681, 51.312186990706344 ],
// [ 3.580787745633303, 51.312176820129551 ],
// [ 3.580829682241423, 51.312167665428959 ],
// [ 3.58086828456562, 51.312162614898625 ],
// [ 3.580980493636721, 51.312147935609723 ],
// [ 3.581014352632766, 51.312145662592656 ],
// [ 3.581028980583245, 51.312145592849248 ],
// [ 3.581119189823368, 51.312145103215911 ],
// [ 3.581195330198145, 51.312144693075908 ],
// [ 3.581243537809229, 51.312148741603245 ],
// [ 3.58132480221972, 51.312163110548383 ],
// [ 3.581426517039001, 51.312181089466016 ],
// [ 3.581448095953263, 51.312184910295024 ],
// [ 3.581474337475052, 51.312191038736145 ],
// [ 3.581709405982819, 51.312260068944951 ],
// [ 3.581727319558337, 51.312266163697757 ],
// [ 3.581753583356718, 51.312276407881612 ],
// [ 3.581841655772683, 51.312310743468075 ],
// [ 3.581878851795624, 51.312325234405343 ],
// [ 3.581905889860924, 51.312338260798654 ],
// [ 3.581906254501594, 51.312338472113815 ],
// [ 3.582048236499295, 51.312422439022804 ],
// [ 3.58189849928915, 51.312481944577037 ],
// [ 3.583044298383354, 51.312095780444281 ],
// [ 3.582984006671231, 51.312017283925279 ],
// [ 3.582743535862999, 51.311699343434064 ],
// [ 3.582628599916243, 51.311582190756774 ],
// [ 3.581446834435509, 51.310511259982569 ],
// [ 3.580621864908701, 51.309767270412806 ],
// [ 3.579610575760466, 51.308860440593946 ],
// [ 3.579112608916012, 51.308394999612226 ],
// [ 3.578688808506157, 51.307968441218165 ],
// [ 3.578394256007207, 51.307644098092617 ],
// [ 3.578355980318371, 51.307607614964702 ],
// [ 3.578217977585775, 51.307654179547846 ],
// [ 3.577480636332469, 51.307921035607997 ],
// [ 3.575695560441006, 51.308577167973212 ],
// [ 3.575668643609169, 51.30855384769157 ],
// [ 3.575666204524265, 51.308551734020703 ],
// [ 3.575506397192348, 51.308609906947261 ],
// [ 3.575459139533024, 51.308653178431456 ],
// [ 3.575458869234128, 51.308707885669762 ]
// [ 4.960707146896585, 52.800583669708487 ],
// [ 4.960645975538824, 52.800470217610922 ],
// [ 4.962140695752897, 52.799177147194797 ],
// [ 4.967523821195745, 52.801502400041208 ],
// [ 4.966336768950911, 52.802543735879809 ],
// [ 4.961711880764330, 52.801009996856429 ],
// [ 4.960707146896585, 52.800583669708487 ]
// ]
// ]
// },
// "GenerateTaskmap": true,
// "OutputType": "shape", // "shape" or "isoxml" if isoxml also add ddiCode
// "Precision": "2",
// "MaximumClasses": "4",
// "DdiCode": "0006",
// "CellWidth": "3",
// "CellHeight": "10",
// "Centered": "true",
// "StartPoint": {
// "type": "Point",
// "coordinates": [ 4.960707146896585, 52.800583669708487 ]
// },
// "EndPoint": { // if no angle
// "type": "Point",
// "coordinates": [ 4.961711880764330, 52.801009996856429 ]
// }
// //"Angle": "317.0" // if no endpoint
//}
//,
//{
// "file": "Scan_1_20190605.zip",
// "inputVariable": "irmi",
// "InputLayerName": "IRMI",
// "outputFileName": "vranbs3",
// "plantingDate": "2019-04-18",
// "measurementDate": "2019-06-20",
// "potatoPurposeType": "starch",
// "targetYield": 45,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 3.40843828875524, 50.638966444680605 ],
// [ 3.408953272886064, 50.639197789621612 ],
// [ 3.409242951459603, 50.639469958681836 ],
// [ 3.409328782148028, 50.639612846807708 ],
// [ 3.409457528180712, 50.639789755314411 ],
// [ 3.409639918393741, 50.640014292074966 ],
// [ 3.409833037442765, 50.640211611372706 ],
// [ 3.410069071836049, 50.640395321698435 ],
// [ 3.410380208081761, 50.640572227259661 ],
// [ 3.410605513638958, 50.640715112034222 ],
// [ 3.411925160474145, 50.641177783561204 ],
// [ 3.411935889310142, 50.640728720085136 ],
// [ 3.412590348309737, 50.63948356709389 ],
// [ 3.413244807309242, 50.638224772339846 ],
// [ 3.413400375432099, 50.637901562841307 ],
// [ 3.413539850300779, 50.637449065809889 ],
// [ 3.413475477284437, 50.637418445552932 ],
// [ 3.40999396998362, 50.637449065810451 ],
// [ 3.409940325803365, 50.638102293212661 ],
// [ 3.409575545377398, 50.638483338338325 ],
// [ 3.409060561246574, 50.638707881340494 ],
// [ 3.40843828875524, 50.638966444680605 ]
// ]
// ]
// }
//},
//{
// "file": "Scan_1_20190605.zip",
// "inputVariable": "irmi",
//}
//,
//{
// "file": "Scan_1_20190605.zip",
// "inputVariable": "irmi",
// "InputLayerName": "",
// "outputFileName": "vranbs4",
// "plantingDate": "2019-04-18",
// "measurementDate": "2019-07-03",
// "potatoPurposeType": "starch",
// "targetYield": 45,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 3.40843828875524, 50.638966444680605 ],
// [ 3.408953272886064, 50.639197789621612 ],
// [ 3.409242951459603, 50.639469958681836 ],
// [ 3.409328782148028, 50.639612846807708 ],
// [ 3.409457528180712, 50.639789755314411 ],
// [ 3.409639918393741, 50.640014292074966 ],
// [ 3.409833037442765, 50.640211611372706 ],
// [ 3.410069071836049, 50.640395321698435 ],
// [ 3.410380208081761, 50.640572227259661 ],
// [ 3.410605513638958, 50.640715112034222 ],
// [ 3.411925160474145, 50.641177783561204 ],
// [ 3.411935889310142, 50.640728720085136 ],
// [ 3.412590348309737, 50.63948356709389 ],
// [ 3.413244807309242, 50.638224772339846 ],
// [ 3.413400375432099, 50.637901562841307 ],
// [ 3.413539850300779, 50.637449065809889 ],
// [ 3.413475477284437, 50.637418445552932 ],
// [ 3.40999396998362, 50.637449065810451 ],
// [ 3.409940325803365, 50.638102293212661 ],
// [ 3.409575545377398, 50.638483338338325 ],
// [ 3.409060561246574, 50.638707881340494 ],
// [ 3.40843828875524, 50.638966444680605 ]
// ]
// ]
// }
}
//}
]

View File

@ -1,57 +0,0 @@
[
{
"File": "BBL-lutum.tif",
"OutputFileName": "BBL-poten_30_10_Shadow-True_TifInput",
"FieldName": "lutum",
"PlantingYear": 2020,
"MeanDensity": "30",
"Variation": "20",
"UseShadow": true,
"CountPerArea": false,
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 4.61098862747705418, 52.22974843124053734 ],
[ 4.61338362824790682, 52.22993593073885421 ],
[ 4.61949010053501397, 52.22667042162688489 ],
[ 4.61954106663577324, 52.22670579437124871 ],
[ 4.61953075937382085, 52.22671128094363269 ],
[ 4.61954202811175296, 52.22670563321562298 ],
[ 4.61901745087585081, 52.22634382962637289 ],
[ 4.61812211075603685, 52.22571430401869463 ],
[ 4.61736058962494678, 52.22611942369080396 ],
[ 4.61464150409827134, 52.2275669988328346 ],
[ 4.61407137489250019, 52.22787370291415243 ],
[ 4.61242270952427802, 52.2287649864655279 ],
[ 4.61261020576063618, 52.22887063061121182 ],
[ 4.61256645484349015, 52.22889713517798072 ],
[ 4.61229657126373027, 52.22904994233584119 ],
[ 4.61207777596369262, 52.2291602791168188 ],
[ 4.61174554282434013, 52.22933965721241378 ],
[ 4.61169310584479941, 52.22934596082312453 ],
[ 4.61143525446537428, 52.22949107699816551 ],
[ 4.61100843013417183, 52.22973689585098356 ],
[ 4.61098862747705418, 52.22974843124053734 ]
]
]
},
"GenerateTaskmap": true,
"CellWidth": "3",
"CellHeight": "10",
"Centered": "false",
"StartPoint": {
"type": "Point",
"coordinates": [ 4.61812211075603685, 52.22571430401869463 ] // BBL
},
"EndPoint": {
"type": "Point",
"coordinates": [ 4.61242270952427802, 52.2287649864655279 ] // BBL
} // if no angle
//"Angle": "317.0" // if no endpoint
}
]

View File

@ -78,11 +78,7 @@ namespace FarmmapsVRApoten
$"VRA Poten cropfield {input.OutputFileName}", input.PlantingYear,
input.GeometryJson.ToString(Formatting.None));
//Item cropfieldItem;
// _logger.LogInformation("Cropfield already exists, trying to get it");
//cropfieldItem = await _farmmapsApiService.GetItemAsync("2927b80f63b946afb36821470b9c5c23");
//Calculating shadow map
//Downloading shadowMap for own interpretation
if (useShadow) {
_logger.LogInformation("Calculate shadow map for field");
var shadowItem = await _generalService.RunShadowTask(cropfieldItem);
@ -96,7 +92,6 @@ namespace FarmmapsVRApoten
Path.Combine(DownloadFolder, $"{input.OutputFileName}.shadow.zip"));
}
_logger.LogInformation("Looking for local data to use");
var localDataAvailable = input.File;
var geotiffItem = (Item)null;
@ -186,6 +181,12 @@ namespace FarmmapsVRApoten
if (input.OutputType == "isoxml")
{
if (input.DdiCode == null)
{
_logger.LogInformation("DDi not given. Using expected identifiers");
if (countPerArea == true) {input.DdiCode = input.DdiCode = "0011";}
else { input.DdiCode = "0016"; };
}
taskmap = await _generalService.CreateTaskmap(cropfieldItem: cropfieldItem, tiffItem: applianceMapItem, outputType: input.OutputType, cellWidth: input.CellWidth,
cellHeight: input.CellHeight, startPoint: input.StartPoint.ToString(Formatting.None), ddiCode: input.DdiCode, centered: input.Centered,
endPoint: input.EndPoint.ToString(Formatting.None), angle: input.Angle, precision: input.Precision,

View File

@ -1,54 +1,13 @@
[
//{
// "File": "ClaassenVRA_Kruising_LutEmptyPointsErased_largerExtent.zip",
// "OutputFileName": "2021.03.31.ClaassenVRA_Kruising_Lut_EmptyPointsErased_largeExtent",
// "FieldName": "Lutum",
// "PlantingYear": 2021,
// "MeanDensity": "15",
// "Variation": "20",
// "UseShadow": true,
// "CountPerArea": false,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 6.3070655, 53.3623397 ],
// [ 6.3070875, 53.3623898 ],
// [ 6.3069749, 53.3623074 ],
// [ 6.3070314, 53.3623125 ],
// [ 6.3070655, 53.3623397 ]
// ]
// ]
// },
// "GenerateTaskmap": true,
// "OutputType": "isoxml", // "shape" or "isoxml" if isoxml also add ddiCode
// "DdiCode": "0001",
// "CellWidth": "3",
// "CellHeight": "10",
// "Centered": "false",
// "StartPoint": {
// "type": "Point",
// "coordinates": [ 6.306901145501940, 53.362318269638386 ]
// },
// "EndPoint": {
// "type": "Point",
// "coordinates": [ 6.298561552458957, 53.363541544243297 ]
// } // if no angle
// // "Angle": "317.0" // if no endpoint
//}
{
"File": "PlantingSampleDataLutum.zip",
"OutputFileName": "2021.04.09_vraPoten_SampleData4",
"OutputFileName": "2021.04.12_vraPoten_SampleData",
"FieldName": "lutum",
"PlantingYear": 2021,
"MeanDensity": "30",
"Variation": "20",
"UseShadow": false,
"CountPerArea": false,
"UseShadow": true,
"CountPerArea": false, // don't forget to change ddi if isoxml is created
"geometryJson": {
"type": "Polygon",
"coordinates": [
@ -72,17 +31,17 @@
"Centered": "true",
"StartPoint": {
"type": "Point",
//"coordinates": [ 5.669032078413372, 52.527906465105254 ] // 1
//"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 2
//"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 3
"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 4
//"coordinates": [ 5.66886041703652044, 52.52929999060298627 ] // 1
//"coordinates": [ 5.6716230923214912, 52.52946316399909676 ] // 2
//"coordinates": [ 5.67185376229668581, 52.5280565894154563 ] // 3
"coordinates": [ 5.66903207841337231, 52.52790646510525363 ] // 4
},
"EndPoint": {
"type": "Point",
"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 1
//"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 2
//"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 3
//"coordinates": [ 5.671853762296686, 52.528056589415456 ] // 4
"coordinates": [ 5.66886041703652044, 52.52929999060298627 ] // 1
//"coordinates": [ 5.6716230923214912, 52.52946316399909676 ] // 2
//"coordinates": [ 5.67185376229668581, 52.5280565894154563 ] // 3
//"coordinates": [ 5.66903207841337231, 52.52790646510525363 ] // 4
} // if no angle
//"Angle": "317.0" // if no endpoint