Update zonering to find the right output files

Added taskmap creator to NBS
This commit is contained in:
Riepma
2021-02-15 17:06:09 +01:00
parent c02b232837
commit 101b683daa
9 changed files with 194 additions and 95 deletions

View File

@@ -23,5 +23,9 @@
<ItemGroup>
<ProjectReference Include="..\FarmmapsApi\FarmmapsApi.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data" />
</ItemGroup>
</Project>

View File

@@ -49,13 +49,11 @@ namespace FarmmapsZonering.Services
return null;
}
var itemName = $"VRAZonering";
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
//i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) &&
// i.Name.ToLower().Contains(itemName.ToLower()));
i =>
i.Name.ToLower().Contains(itemName.ToLower()));
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
GEOTIFF_PROCESSED_ITEMTYPE, output.Name,
i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) &&
i.Name.ToLower().Contains(output.Name.ToLower()));
if (applianceMapItem == null)
{
_logger.LogError("Could not find the VRAZonering geotiff child item under cropfield");

View File

@@ -73,7 +73,7 @@ namespace FarmmapsZonering
return;
}
bool useCreatedCropfield = true;
bool useCreatedCropfield = false;
bool GetWatBal = input.GetWatBal;
bool getVanDerSat = input.GetVanDerSat;
bool StoreVanDerSatStatistics = input.storeVanDerSatStatistics;
@@ -91,7 +91,7 @@ namespace FarmmapsZonering
}
Item cropfieldItem;
if (string.IsNullOrEmpty(_settings.CropfieldItemCode) || input.CreateNewCropfield == true)
if (input.CreateNewCropfield == true) // || string.IsNullOrEmpty(_settings.CropfieldItemCode) ## CHECK IT!!
{
_logger.LogInformation("Creating cropfield");
@@ -103,8 +103,8 @@ namespace FarmmapsZonering
_settings.CropfieldItemCode = cropfieldItem.Code;
SaveSettings(settingsfile);
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield VRA Zonering", 2020,
@"{ ""type"": ""Polygon"", ""coordinates"": [ [ [ 5.670991253771027, 52.796788997702613 ], [ 5.671526456638633, 52.797291618546666 ], [ 5.671275936147413, 52.797422436717852 ], [ 5.671959173850738, 52.798269302728798 ], [ 5.670649634919365, 52.798778791408822 ], [ 5.671503682048522, 52.799591206957416 ], [ 5.675159003761311, 52.798193567415474 ], [ 5.673029579585948, 52.796024727480535 ], [ 5.670991253771027, 52.796788997702613 ] ] ] }");
//cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield VRA Zonering", 2020,
// @"{ ""type"": ""Polygon"", ""coordinates"": [ [ [ 5.670991253771027, 52.796788997702613 ], [ 5.671526456638633, 52.797291618546666 ], [ 5.671275936147413, 52.797422436717852 ], [ 5.671959173850738, 52.798269302728798 ], [ 5.670649634919365, 52.798778791408822 ], [ 5.671503682048522, 52.799591206957416 ], [ 5.675159003761311, 52.798193567415474 ], [ 5.673029579585948, 52.796024727480535 ], [ 5.670991253771027, 52.796788997702613 ] ] ] }");
_settings.CropfieldItemCode = cropfieldItem.Code;
SaveSettings(settingsfile);
}
@@ -147,19 +147,24 @@ namespace FarmmapsZonering
var inputOneItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
Path.Combine("Data", $"{input.InputItemOne}"), Path.GetFileNameWithoutExtension($"{input.InputItemOne}"));
if (inputOneItem == null) {
if (inputOneItem == null)
{
_logger.LogError("Could not find item for uploaded data");
return;
}
var inputTwoItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
Path.Combine("Data", $"{input.InputItemTwo}"), Path.GetFileNameWithoutExtension($"{input.InputItemTwo}"));
if (inputTwoItem == null) {
_logger.LogError("Could not find item for uploaded data");
return;
}
//var inputTwoItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
// Path.Combine("Data", $"{input.InputItemTwo}"), Path.GetFileNameWithoutExtension($"{input.InputItemTwo}"));
//if (inputTwoItem == null)
//{
// _logger.LogError("Could not find item for uploaded data");
// return;
//}
//var inputOneItem = input.InputItemOne;
//var inputTwoItem = input.InputItemTwo;
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, input.Formula, new Output()
{
@@ -172,12 +177,14 @@ namespace FarmmapsZonering
{
ItemCode = inputOneItem.Code,
LayerName = inputOneItem.Data["layers"][0]["name"].ToString()
},
new InputParameter()
{
ItemCode = inputOneItem.Code,
LayerName = inputOneItem.Data["layers"][0]["name"].ToString()
});
}
//,
//new InputParameter()
//{
// //ItemCode = inputOneItem.Code,
// //LayerName = inputOneItem.Data["layers"][0]["name"].ToString()
//}
);;
_logger.LogInformation("Downloading output");

View File

@@ -1,71 +1,101 @@
[
//Formule kan meerdere inputs aan
// Met blokhaken en een nummer specificeer je een input:
//[0], [10]. etc...
// Aan de hand van de volgorde van input wordt momenteel bepaald welk nummer bij welk input hoort.
//[0] is dus de eerst tiff opgegeven.Als het goed is maakt het nummer nu niks uit, dus als er 2 inputs zijn en in de formule staan[0] en[10] dan zal die nog steeds werken.
//De volgorde van de tiff kun je verslepen, bij de formule inputs kun je de input van het ene[0] slot naar het andere slepen[10]
//Functies: abs, min en max
//Constanten: pi en e
//Formule kan meerdere inputs aan
// Met blokhaken en een nummer specificeer je een input:
//[0], [10]. etc...
// Aan de hand van de volgorde van input wordt momenteel bepaald welk nummer bij welk input hoort.
//[0] is dus de eerst tiff opgegeven.Als het goed is maakt het nummer nu niks uit, dus als er 2 inputs zijn en in de formule staan[0] en[10] dan zal die nog steeds werken.
//De volgorde van de tiff kun je verslepen, bij de formule inputs kun je de input van het ene[0] slot naar het andere slepen[10]
//Functies: abs, min en max
//Constanten: pi en e
//if ([0] -[1])/ ([0] +[1]) < 0 then 0
//else if ([0] -[1])/ ([0] +[1]) > 1 then 1
//else ([0] -[1]) / ([0] +[1])
//if ([0] -[1])/ ([0] +[1]) < 0 then 0
//else if ([0] -[1])/ ([0] +[1]) > 1 then 1
//else ([0] -[1]) / ([0] +[1])
//{
// "InputItemOne": "20201106_Sentinel2_L2A_B04.tiff",
// "InputItemTwo": "20201106_Sentinel2_L2A_B08.tiff",
// "Formula": "([1]-[0])/([1]+[0])",
// "CreatedLayerName": "Biomassa",
// "CalculatedQuantity": "NDVI",
// "CalculatedUnit": "ndviValue",
//{
// "InputItemOne": "20201106_Sentinel2_L2A_B04.tiff",
// "InputItemTwo": "20201106_Sentinel2_L2A_B08.tiff",
// "Formula": "([1]-[0])/([1]+[0])",
// "CreatedLayerName": "Biomassa",
// "CalculatedQuantity": "NDVI",
// "CalculatedUnit": "ndviValue",
// "OutputFileName": "FullField_NDVI",
// "CropFieldName": "FullField",
// "CreateNewCropfield": false,
// "CropYear": 2020,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// "OutputFileName": "FullField_NDVI",
// "CropFieldName": "FullField",
// "CreateNewCropfield": false,
// "CropYear": 2020,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 4.9593709, 52.8014339 ],
// [ 4.9675488, 52.7943149 ],
// [ 4.9735195, 52.7968665 ],
// [ 4.9667833, 52.8030414 ],
// [ 4.9593709, 52.8014339 ]
// ]
// [
// [ 4.9593709, 52.8014339 ],
// [ 4.9675488, 52.7943149 ],
// [ 4.9735195, 52.7968665 ],
// [ 4.9667833, 52.8030414 ],
// [ 4.9593709, 52.8014339 ]
// ]
// ]
// },
{
"InputItemOne": "data_9001.tif",
"InputItemTwo": "data_times_two_4326.tiff",
"Formula": "if [0] >= 1.28 then [1] else 0",
"CreatedLayerName": "Biomassa",
"CalculatedQuantity": "NDVI",
"CalculatedUnit": "ndviValue",
"OutputFileName": "Zoning",
"CropFieldName": "Data_whole",
"UseShadow": false,
"GetWatBal": false,
"GetVanDerSat": true,
"storeVanDerSatStatistics": true,
"CropYear": 2020,
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 5.66886041703652044, 52.52929999060298627 ],
[ 5.6716230923214912, 52.52946316399909676 ],
[ 5.67185376229668581, 52.5280565894154563 ],
[ 5.66903207841337231, 52.52790646510525363 ],
[ 5.66886041703652044, 52.52929999060298627 ]
]
]
// ]
// }
//,
//{
// "InputItemOne": "data_9001.tif",
// "InputItemTwo": "data_times_two_4326.tiff",
// "Formula": "if [0] >= 1.28 then [1] else 0",
// "CreatedLayerName": "Biomassa",
// "CalculatedQuantity": "NDVI",
// "CalculatedUnit": "ndviValue",
// "OutputFileName": "Zoning",
// "CropFieldName": "Data_whole",
// "UseShadow": false,
// "GetWatBal": false,
// "GetVanDerSat": false,
// "storeVanDerSatStatistics": false,
// "CropYear": 2020,
// "geometryJson": {
// "type": "Polygon",
// "coordinates": [
// [
// [ 5.66886041703652044, 52.52929999060298627 ],
// [ 5.6716230923214912, 52.52946316399909676 ],
// [ 5.67185376229668581, 52.5280565894154563 ],
// [ 5.66903207841337231, 52.52790646510525363 ],
// [ 5.66886041703652044, 52.52929999060298627 ]
// ]
// ]
// }
//},
{
"InputItemOne": "VRApoten_appliancemap_20210215_vraPoten_SampleData_CovertArea.tif",
//"InputItemTwo": "",
"Formula": "((100/[0])/0.75)",
"LayerName": "CountPerAreaConversion",
"CalculatedQuantity": "CountPerArea",
"CalculatedUnit": "#/m2",
"OutputFileName": "CountPerAreaConversionOutput",
"CropFieldName": "ZoningCpA",
"CreateNewCropfield": true,
"UseShadow": false,
"GetWatBal": false,
"GetVanDerSat": false,
"storeVanDerSatStatistics": false,
"CropYear": 2020,
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 5.66886041703652044, 52.52929999060298627 ],
[ 5.6716230923214912, 52.52946316399909676 ],
[ 5.67185376229668581, 52.5280565894154563 ],
[ 5.66903207841337231, 52.52790646510525363 ],
[ 5.66886041703652044, 52.52929999060298627 ]
]
]
}
}
}
]