MCPcopy Create free account
hub / github.com/OSGeo/gdal / ProcessRasterZones

Function ProcessRasterZones

alg/zonal.cpp:1115–1325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113 }
1114
1115 bool ProcessRasterZones(GDALProgressFunc pfnProgress, void *pProgressData)
1116 {
1117 if (!Init())
1118 {
1119 return false;
1120 }
1121
1122 GDALRasterBand *poZonesBand = std::get<GDALRasterBand *>(m_zones);
1123 WarnIfZonesNotCovered(poZonesBand);
1124
1125 OGRLayer *poDstLayer = GetOutputLayer(true);
1126 if (!poDstLayer)
1127 return false;
1128
1129 // Align the src dataset to the zones.
1130 bool resampled;
1131 std::unique_ptr<GDALDataset> poAlignedValuesDS =
1132 GetVRT(m_src, *poZonesBand->GetDataset(), resampled);
1133 if (resampled)
1134 {
1135 CPLError(CE_Warning, CPLE_AppDefined,
1136 "Resampled source raster to match zones using average "
1137 "resampling.");
1138 }
1139
1140 // Align the weighting dataset to the zones.
1141 std::unique_ptr<GDALDataset> poAlignedWeightsDS;
1142 GDALRasterBand *poWeightsBand = nullptr;
1143 if (m_weights)
1144 {
1145 poAlignedWeightsDS =
1146 GetVRT(*m_weights, *poZonesBand->GetDataset(), resampled);
1147 if (!poAlignedWeightsDS)
1148 {
1149 return false;
1150 }
1151 if (resampled)
1152 {
1153 CPLError(CE_Warning, CPLE_AppDefined,
1154 "Resampled weighting raster to match zones using "
1155 "average resampling.");
1156 }
1157
1158 poWeightsBand =
1159 poAlignedWeightsDS->GetRasterBand(m_options.weights_band);
1160 }
1161
1162 struct CompareNaNAware
1163 {
1164 bool operator()(double lhs, double rhs) const
1165 {
1166 return (std::isnan(lhs) && !std::isnan(rhs)) || lhs < rhs;
1167 }
1168 };
1169
1170 std::map<double, std::vector<gdal::RasterStats<double>>,
1171 CompareNaNAware>
1172 stats;

Callers 1

ProcessFunction · 0.85

Calls 15

InitFunction · 0.85
WarnIfZonesNotCoveredFunction · 0.85
GetOutputLayerFunction · 0.85
GetVRTFunction · 0.85
CPLErrorFunction · 0.85
CreateBufferFunction · 0.85
ReallocFunction · 0.85
CalculateCellCentersFunction · 0.85
ReadWindowFunction · 0.85
CreateStatsFunction · 0.85
SetStatFieldsFunction · 0.85
IterateWindowsMethod · 0.80

Tested by

no test coverage detected