double value;
rt_bandstats stats = NULL;
+ uint32_t do_sample = 0;
uint32_t sample_size = 0;
int byY = 0;
uint32_t outer = 0;
}
/* clamp percentage */
- if (sample <= 0 || sample > 1)
+ if (
+ (sample < 0 || fabs(sample - 0.0) < FLT_EPSILON) ||
+ (sample > 1 || fabs(sample - 1.0) < FLT_EPSILON)
+ ) {
+ do_sample = 0;
sample = 1;
+ }
+ else
+ do_sample = 1;
+ RASTER_DEBUGF(3, "do_sample = %d", do_sample);
/* sample all pixels */
- if (sample == 1) {
+ if (do_sample != 1) {
sample_size = band->width * band->height;
sample_per = inner;
}
diff = 0;
for (i = 0, z = 0; i < sample_per; i++) {
- if (sample == 1)
+ if (do_sample != 1)
y = i;
else {
offset = (rand() % sample_int) + 1;
j++;
if (rtn != -1) {
if (
- !hasnodata ||
- (hasnodata && (hasnodata_flag != FALSE) && (value != nodata))
+ !hasnodata || (
+ hasnodata &&
+ (hasnodata_flag != FALSE) &&
+ (fabs(value - nodata) > FLT_EPSILON)
+ )
) {
/* inc_vals set, collect pixel values */
- if (inc_vals) {
- values[k] = value;
- }
+ if (inc_vals) values[k] = value;
/* average */
k++;
stats->mean = sum / k;
/* standard deviation */
- if (sample == 1)
+ if (do_sample != 1)
stats->stddev = sqrt(Q / k);
/* sample deviation */
else {
/* bin width must be positive numbers and not zero */
if (NULL != bin_width && bin_width_count > 0) {
for (i = 0; i < bin_width_count; i++) {
- if (bin_width[i] <= 0.) {
+ if (bin_width[i] < 0 || fabs(bin_width[i] - 0.0) < FLT_EPSILON) {
rterror("rt_util_get_histogram: bin_width element is less than or equal to zero");
return NULL;
}
}
/* min and max the same */
- if (stats->min == stats->max)
+ if (fabs(stats->max - stats->min) < FLT_EPSILON)
bin_count = 1;
RASTER_DEBUGF(3, "bin_count = %d", bin_count);
if (!right) {
for (j = 0; j < bin_count; j++) {
if (
- (!bins[j].inc_max && value < bins[j].max) ||
- (bins[j].inc_max && value <= bins[j].max)
+ (!bins[j].inc_max && value < bins[j].max) || (
+ bins[j].inc_max && (
+ (value < bins[j].max) ||
+ (fabs(value - bins[j].max) < FLT_EPSILON)
+ )
+ )
) {
bins[j].count++;
sum++;
else {
for (j = 0; j < bin_count; j++) {
if (
- (!bins[j].inc_min && value > bins[j].min) ||
- (bins[j].inc_min && value >= bins[j].min)
+ (!bins[j].inc_min && value > bins[j].min) || (
+ bins[j].inc_min && (
+ (value > bins[j].min) ||
+ (fabs(value - bins[j].min) < FLT_EPSILON)
+ )
+ )
) {
bins[j].count++;
sum++;
expr = exprset[i];
/* ov matches min and max*/
- if (expr->src.min == ov && ov == expr->src.max) {
+ if (
+ fabs(expr->src.min - ov) < FLT_EPSILON &&
+ fabs(expr->src.max - ov) < FLT_EPSILON
+ ) {
do_nv = 1;
break;
}
/* process min */
- if (
- (expr->src.exc_min && expr->src.min >= ov) ||
- (expr->src.inc_min && expr->src.min <= ov) ||
- (expr->src.min < ov)
- ) {
+ if ((
+ expr->src.exc_min && (
+ expr->src.min > ov ||
+ fabs(expr->src.min - ov) < FLT_EPSILON
+ )) || (
+ expr->src.inc_min && (
+ expr->src.min < ov ||
+ fabs(expr->src.min - ov) < FLT_EPSILON
+ )) || (
+ expr->src.min < ov
+ )) {
/* process max */
- if (
- (expr->src.exc_max && ov >= expr->src.max) ||
- (expr->src.inc_max && ov <= expr->src.max) ||
- (ov < expr->src.max)
- ) {
+ if ((
+ expr->src.exc_max && (
+ ov > expr->src.max ||
+ fabs(expr->src.max - ov) < FLT_EPSILON
+ )) || (
+ expr->src.inc_max && (
+ ov < expr->src.max ||
+ fabs(expr->src.max - ov) < FLT_EPSILON
+ )) || (
+ ov < expr->src.max
+ )) {
do_nv = 1;
break;
}
*/
/* nodata */
- if (src_hasnodata && hasnodata && ov == src_nodataval) {
+ if (
+ src_hasnodata &&
+ hasnodata &&
+ fabs(ov - src_nodataval) < FLT_EPSILON
+ ) {
nv = nodataval;
}
/*
"src" min and max is the same, prevent division by zero
set nv to "dst" min, which should be the same as "dst" max
*/
- else if (expr->src.min == expr->src.max) {
+ else if (fabs(expr->src.max - expr->src.min) < FLT_EPSILON) {
nv = expr->dst.min;
}
else {
oldnumbands = rt_raster_get_num_bands(raster);
if (index < 0)
index = 0;
- else if (index > rt_raster_get_num_bands(raster) + 1)
- index = rt_raster_get_num_bands(raster) + 1;
+ else if (index > oldnumbands + 1)
+ index = oldnumbands + 1;
/* Determine size of memory block to allocate and allocate it */
width = rt_raster_get_width(raster);
numBands = rt_raster_get_num_bands(raster);
for (i = 0; i < numBands; i++) {
rtband = rt_raster_get_band(raster, i);
- if (0 == rtband) {
+ if (NULL == rtband) {
rterror("rt_raster_to_gdal_mem: Unable to get requested band\n");
GDALClose(ds);
if (drv_gen) {
}
pixeltypename = PG_GETARG_TEXT_P(2);
- new_pixeltypename = (char *) palloc(VARSIZE(pixeltypename) + 1 - VARHDRSZ);
- SET_VARSIZE(new_pixeltypename, VARSIZE(pixeltypename));
- memcpy(new_pixeltypename, VARDATA(pixeltypename),
- VARSIZE(pixeltypename) - VARHDRSZ);
- new_pixeltypename[VARSIZE(pixeltypename) - VARHDRSZ] = 0; /* null terminate */
+ new_pixeltypename = text_to_cstring(pixeltypename);
/* Get the pixel type index */
pixtype = rt_pixtype_index_from_name(new_pixeltypename);
PG_FUNCTION_INFO_V1(RASTER_summaryStats);
Datum RASTER_summaryStats(PG_FUNCTION_ARGS)
{
- rt_pgraster *pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ rt_pgraster *pgraster = NULL;
rt_raster raster = NULL;
rt_band band = NULL;
int32_t bandindex = 0;
HeapTuple tuple;
Datum result;
+ /* pgraster is null, return null */
+ if (PG_ARGISNULL(0)) PG_RETURN_NULL();
+ pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
raster = rt_raster_deserialize(pgraster);
if (!raster) {
elog(ERROR, "RASTER_summaryStats: Could not deserialize raster");
rt_raster_destroy(raster);
PG_RETURN_NULL();
}
- else if (sample == 0)
+ else if (fabs(sample - 0.0) < FLT_EPSILON)
sample = 1;
}
else
if (SRF_IS_FIRSTCALL()) {
MemoryContext oldcontext;
- rt_pgraster *pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ rt_pgraster *pgraster = NULL;
rt_raster raster = NULL;
rt_band band = NULL;
int32_t bandindex = 0;
/* switch to memory context appropriate for multiple function calls */
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+ /* pgraster is null, return nothing */
+ if (PG_ARGISNULL(0)) SRF_RETURN_DONE(funcctx);
+ pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
raster = rt_raster_deserialize(pgraster);
if (!raster) {
elog(ERROR, "RASTER_histogram: Could not deserialize raster");
rt_raster_destroy(raster);
SRF_RETURN_DONE(funcctx);
}
- else if (sample == 0)
+ else if (fabs(sample - 0.0) < FLT_EPSILON)
sample = 1;
}
else
break;
}
- if (width < 0) {
+ if (width < 0 || fabs(width - 0.0) < FLT_EPSILON) {
elog(NOTICE, "Invalid value for width (must be greater than 0). Returning NULL");
pfree(bin_width);
rt_raster_destroy(raster);
if (SRF_IS_FIRSTCALL()) {
MemoryContext oldcontext;
- rt_pgraster *pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ rt_pgraster *pgraster = NULL;
rt_raster raster = NULL;
rt_band band = NULL;
int32_t bandindex = 0;
/* switch to memory context appropriate for multiple function calls */
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+ /* pgraster is null, return nothing */
+ if (PG_ARGISNULL(0)) SRF_RETURN_DONE(funcctx);
+ pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
raster = rt_raster_deserialize(pgraster);
if (!raster) {
elog(ERROR, "RASTER_quantile: Could not deserialize raster");
rt_raster_destroy(raster);
SRF_RETURN_DONE(funcctx);
}
- else if (sample == 0)
+ else if (fabs(sample - 0.0) < FLT_EPSILON)
sample = 1;
}
else
*/
PG_FUNCTION_INFO_V1(RASTER_reclass);
Datum RASTER_reclass(PG_FUNCTION_ARGS) {
- rt_pgraster *pgrast = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ rt_pgraster *pgrast = NULL;
rt_raster raster = NULL;
rt_band band = NULL;
rt_band newband = NULL;
POSTGIS_RT_DEBUG(3, "RASTER_reclass: Starting");
+ /* pgraster is null, return null */
+ if (PG_ARGISNULL(0)) PG_RETURN_NULL();
+ pgrast = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
/* raster */
raster = rt_raster_deserialize(pgrast);
if (!raster) {
PG_FUNCTION_INFO_V1(RASTER_asGDALRaster);
Datum RASTER_asGDALRaster(PG_FUNCTION_ARGS)
{
- rt_pgraster *pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ rt_pgraster *pgraster = NULL;
rt_raster raster;
text *formattext = NULL;
POSTGIS_RT_DEBUG(3, "RASTER_asGDALRaster: Starting");
+ /* pgraster is null, return null */
+ if (PG_ARGISNULL(0)) PG_RETURN_NULL();
+ pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
raster = rt_raster_deserialize(pgraster);
if (!raster) {
elog(ERROR, "RASTER_asGDALRaster: Could not deserialize raster");
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
, 1, 5, 5, 3.14159
)
);
-SELECT ST_Histogram(
- ST_SetValue(
- ST_SetValue(
- ST_SetValue(
- ST_AddBand(
- ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
- , 1, '64BF', 0, 0
- )
- , 1, 1, 1, -10
- )
- , 1, 5, 4, 0
- )
- , 1, 5, 5, 3.14159
- )
-);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, FALSE, 0, ARRAY[]::double precision[], FALSE
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, FALSE, 1, FALSE
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, FALSE, 5
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, FALSE
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, 0, ARRAY[5]::double precision[], FALSE
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, 3, FALSE
);
-SELECT * FROM ST_Histogram(
+SELECT
+ round(min::numeric, 3),
+ round(max::numeric, 3),
+ count,
+ round(proportion::numeric, 3)
+FROM ST_Histogram(
ST_SetValue(
ST_SetValue(
ST_SetValue(
--10|-3.429205|1|0.5
--3.429205|3.14159|1|0.5
-(-10,-3.429205,1,0.5)
-(-3.429205,3.14159,1,0.5)
--10|-8.357301|1|0.01
--8.357301|-6.714602|0|0
--6.714602|-5.071904|0|0
--5.071904|-3.429205|0|0
--3.429205|-1.786506|0|0
--1.786506|-0.143807|0|0
--0.143807|1.498891|98|0.98
-1.498891|3.14159|1|0.01
--10|3.14159|100|-1
--10|-7.371682|1|0.01
--7.371682|-4.743364|0|0
--4.743364|-2.115046|0|0
--2.115046|0.513272|98|0.98
-0.513272|3.14159|1|0.01
--10|-8.357301|1|0.01
--8.357301|-6.714602|0|0
--6.714602|-5.071904|0|0
--5.071904|-3.429205|0|0
--3.429205|-1.786506|0|0
--1.786506|-0.143807|0|0
--0.143807|1.498891|98|0.98
-1.498891|3.14159|1|0.01
--10|-3.429205|1|0.5
--3.429205|3.14159|1|0.5
--10|-5|1|0.5
--5|0|0|0
-0|5|1|0.5
--10|-5.61947|1|0.5
--5.61947|-1.23894|0|0
--1.23894|3.14159|1|0.5
--10|-7.371682|1|0.5
--7.371682|-4.743364|0|0
--4.743364|-2.115046|0|0
--2.115046|0.513272|0|0
-0.513272|3.14159|1|0.5
+-10.000|-3.429|1|0.500
+-3.429|3.142|1|0.500
+-10.000|-8.357|1|0.010
+-8.357|-6.715|0|0.000
+-6.715|-5.072|0|0.000
+-5.072|-3.429|0|0.000
+-3.429|-1.787|0|0.000
+-1.787|-0.144|0|0.000
+-0.144|1.499|98|0.980
+1.499|3.142|1|0.010
+-10.000|3.142|100|-1.000
+-10.000|-7.372|1|0.010
+-7.372|-4.743|0|0.000
+-4.743|-2.115|0|0.000
+-2.115|0.513|98|0.980
+0.513|3.142|1|0.010
+-10.000|-8.357|1|0.010
+-8.357|-6.715|0|0.000
+-6.715|-5.072|0|0.000
+-5.072|-3.429|0|0.000
+-3.429|-1.787|0|0.000
+-1.787|-0.144|0|0.000
+-0.144|1.499|98|0.980
+1.499|3.142|1|0.010
+-10.000|-3.429|1|0.500
+-3.429|3.142|1|0.500
+-10.000|-5.000|1|0.500
+-5.000|0.000|0|0.000
+0.000|5.000|1|0.500
+-10.000|-5.619|1|0.500
+-5.619|-1.239|0|0.000
+-1.239|3.142|1|0.500
+-10.000|-7.372|1|0.500
+-7.372|-4.743|0|0.000
+-4.743|-2.115|0|0.000
+-2.115|0.513|0|0.000
+0.513|3.142|1|0.500
-SELECT * FROM ST_Mean(
+SELECT round(ST_Mean(
ST_SetValue(
ST_SetValue(
ST_SetValue(
, 1, 5, 5, 3.14159
)
, TRUE
-);
-SELECT ST_Mean(
- ST_SetValue(
- ST_SetValue(
- ST_SetValue(
- ST_AddBand(
- ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
- , 1, '64BF', 0, 0
- )
- , 1, 1, 1, -10
- )
- , 1, 5, 4, 0
- )
- , 1, 5, 5, 3.14159
- )
- , TRUE
-);
-SELECT mean FROM ST_Mean(
+)::numeric, 3);
+SELECT round(mean::numeric, 3) FROM ST_Mean(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, TRUE
);
-SELECT mean FROM ST_Mean(
+SELECT round(mean::numeric, 3) FROM ST_Mean(
ST_SetValue(
ST_SetValue(
ST_SetValue(
SELECT generate_series(1, 10) AS id
) AS id
ON 1 = 1;
-SELECT * FROM ST_Mean('test', 'rast', 1, TRUE);
-SELECT * FROM ST_Mean('test', 'rast', 1, FALSE);
-SELECT * FROM ST_Mean('test', 'rast', 1);
-SELECT * FROM ST_Mean('test', 'rast');
+SELECT round(mean::numeric, 3) FROM ST_Mean('test', 'rast', 1, TRUE);
+SELECT round(mean::numeric, 3) FROM ST_Mean('test', 'rast', 1, FALSE);
+SELECT round(mean::numeric, 3) FROM ST_Mean('test', 'rast', 1);
+SELECT round(mean::numeric, 3) FROM ST_Mean('test', 'rast');
ROLLBACK;
--3.429205
--3.429205
--3.429205
--0.068584
+-3.429
+-3.429
+-0.069
BEGIN
--3.429205
--0.068584
--3.429205
--3.429205
+-3.429
+-0.069
+-3.429
+-3.429
COMMIT
-SELECT min, max FROM ST_MinMax(
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, TRUE
);
-SELECT ST_MinMax(
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, 1, 5, 5, 3.14159
)
- , TRUE
+ , FALSE
);
-SELECT min FROM ST_MinMax(
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax(
ST_SetValue(
ST_SetValue(
ST_SetValue(
, 1, 5, 4, 0
)
, 1, 5, 5, 3.14159
- )
- , TRUE
+ ),
+ 1, TRUE
);
-SELECT max,max FROM ST_MinMax(
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax(
ST_SetValue(
ST_SetValue(
ST_SetValue(
, 1, 5, 4, 0
)
, 1, 5, 5, 3.14159
- )
- , TRUE
+ ),
+ 1
);
+BEGIN;
+CREATE TEMP TABLE test
+ ON COMMIT DROP AS
+ SELECT
+ rast.rast
+ FROM (
+ SELECT ST_SetValue(
+ ST_SetValue(
+ ST_SetValue(
+ ST_AddBand(
+ ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
+ , 1, '64BF', 0, 0
+ )
+ , 1, 1, 1, -10
+ )
+ , 1, 5, 4, 0
+ )
+ , 1, 5, 5, 3.14159
+ ) AS rast
+ ) AS rast
+ FULL JOIN (
+ SELECT generate_series(1, 10) AS id
+ ) AS id
+ ON 1 = 1;
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax('test', 'rast', 1, TRUE);
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax('test', 'rast', 1, FALSE);
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax('test', 'rast', 1);
+SELECT round(min::numeric, 3), round(max::numeric, 3) FROM ST_MinMax('test', 'rast');
+ROLLBACK;
--10|3.14159
-(-10,3.14159)
--10
-3.14159|3.14159
+-10.000|3.142
+-10.000|3.142
+-10.000|3.142
+-10.000|3.142
+BEGIN
+-10.000|3.142
+-10.000|3.142
+-10.000|3.142
+-10.000|3.142
+COMMIT
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, 1, FALSE, ARRAY[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]::double precision[]
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, 1, ARRAY[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]::double precision[]
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, FALSE
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
ARRAY[0.05, 0.95]::double precision[]
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
, 1, 5, 5, 3.14159
)
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, FALSE, 0.05
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
1, 0.95
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
),
FALSE, 0.7
);
-SELECT * FROM ST_Quantile(
+SELECT
+ round(quantile::numeric, 3),
+ round(value::numeric, 3)
+FROM ST_Quantile(
ST_SetValue(
ST_SetValue(
ST_SetValue(
-0|-10
-0.1|0
-0.2|0
-0.3|0
-0.4|0
-0.5|0
-0.6|0
-0.7|0
-0.8|0
-0.9|0
-1|3.14159
-0|-10
-0.1|-8.685841
-0.2|-7.371682
-0.3|-6.057523
-0.4|-4.743364
-0.5|-3.429205
-0.6|-2.115046
-0.7|-0.800887
-0.8|0.513272
-0.9|1.827431
-1|3.14159
-0|-10
-0.25|0
-0.5|0
-0.75|0
-1|3.14159
-0|-10
-0.25|-6.714602
-0.5|-3.429205
-0.75|-0.143807
-1|3.14159
-0.05|-9.34292
-0.95|2.484511
-0|-10
-0.25|-6.714602
-0.5|-3.429205
-0.75|-0.143807
-1|3.14159
-0.05|0
-0.95|2.484511
-0.7|0
-0.45|-4.086285
+0.000|-10.000
+0.100|0.000
+0.200|0.000
+0.300|0.000
+0.400|0.000
+0.500|0.000
+0.600|0.000
+0.700|0.000
+0.800|0.000
+0.900|0.000
+1.000|3.142
+0.000|-10.000
+0.100|-8.686
+0.200|-7.372
+0.300|-6.058
+0.400|-4.743
+0.500|-3.429
+0.600|-2.115
+0.700|-0.801
+0.800|0.513
+0.900|1.827
+1.000|3.142
+0.000|-10.000
+0.250|0.000
+0.500|0.000
+0.750|0.000
+1.000|3.142
+0.000|-10.000
+0.250|-6.715
+0.500|-3.429
+0.750|-0.144
+1.000|3.142
+0.050|-9.343
+0.950|2.485
+0.000|-10.000
+0.250|-6.715
+0.500|-3.429
+0.750|-0.144
+1.000|3.142
+0.050|0.000
+0.950|2.485
+0.700|0.000
+0.450|-4.086
-SELECT * FROM ST_StdDev(
+SELECT round(ST_StdDev(
ST_SetValue(
ST_SetValue(
ST_SetValue(
, 1, 5, 5, 3.14159
)
, TRUE
-);
-SELECT ST_StdDev(
- ST_SetValue(
- ST_SetValue(
- ST_SetValue(
- ST_AddBand(
- ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
- , 1, '64BF', 0, 0
- )
- , 1, 1, 1, -10
- )
- , 1, 5, 4, 0
- )
- , 1, 5, 5, 3.14159
- )
- , TRUE
-);
-SELECT stddev FROM ST_StdDev(
+)::numeric, 3);
+SELECT round(stddev::numeric, 3) FROM ST_StdDev(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, TRUE
);
-SELECT stddev FROM ST_StdDev(
+SELECT round(stddev::numeric, 3) FROM ST_StdDev(
ST_SetValue(
ST_SetValue(
ST_SetValue(
SELECT generate_series(1, 10) AS id
) AS id
ON 1 = 1;
-SELECT * FROM ST_StdDev('test', 'rast', 1, TRUE);
-SELECT * FROM ST_StdDev('test', 'rast', 1, FALSE);
-SELECT * FROM ST_StdDev('test', 'rast', 1);
-SELECT * FROM ST_StdDev('test', 'rast');
+SELECT round(stddev::numeric, 3) FROM ST_StdDev('test', 'rast', 1, TRUE);
+SELECT round(stddev::numeric, 3) FROM ST_StdDev('test', 'rast', 1, FALSE);
+SELECT round(stddev::numeric, 3) FROM ST_StdDev('test', 'rast', 1);
+SELECT round(stddev::numeric, 3) FROM ST_StdDev('test', 'rast');
ROLLBACK;
-6.570795
-6.570795
-6.570795
-1.045941
+6.571
+6.571
+1.046
BEGIN
-6.570795
-1.045941
-6.570795
-6.570795
+6.571
+1.046
+6.571
+6.571
COMMIT
-SELECT * FROM ST_SummaryStats(
- ST_SetValue(
- ST_SetValue(
- ST_SetValue(
- ST_AddBand(
- ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
- , 1, '64BF', 0, 0
- )
- , 1, 1, 1, -10
- )
- , 1, 5, 4, 0
- )
- , 1, 5, 5, 3.14159
- )
- , TRUE
-);
-SELECT ST_SummaryStats(
+SELECT
+ count,
+ round(sum::numeric, 3),
+ round(mean::numeric, 3),
+ round(stddev::numeric, 3),
+ round(min::numeric, 3),
+ round(max::numeric, 3)
+FROM ST_SummaryStats(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, FALSE
);
-SELECT mean, stddev FROM ST_SummaryStats(
+SELECT round(mean::numeric, 3), round(stddev::numeric, 3) FROM ST_SummaryStats(
ST_SetValue(
ST_SetValue(
ST_SetValue(
)
, TRUE
);
-SELECT mean, stddev FROM ST_SummaryStats(
+SELECT round(mean::numeric, 3), round(stddev::numeric, 3) FROM ST_SummaryStats(
ST_SetValue(
ST_SetValue(
ST_SetValue(
SELECT generate_series(1, 10) AS id
) AS id
ON 1 = 1;
-SELECT * FROM ST_SummaryStats('test', 'rast', 1, TRUE);
-SELECT * FROM ST_SummaryStats('test', 'rast', 1, FALSE);
-SELECT * FROM ST_SummaryStats('test', 'rast', 1);
-SELECT * FROM ST_SummaryStats('test', 'rast');
+SELECT
+ count,
+ round(sum::numeric, 3),
+ round(mean::numeric, 3),
+ round(stddev::numeric, 3),
+ round(min::numeric, 3),
+ round(max::numeric, 3)
+FROM ST_SummaryStats('test', 'rast', 1, TRUE);
+SELECT
+ count,
+ round(sum::numeric, 3),
+ round(mean::numeric, 3),
+ round(stddev::numeric, 3),
+ round(min::numeric, 3),
+ round(max::numeric, 3)
+FROM ST_SummaryStats('test', 'rast', 1, FALSE);
+SELECT
+ count,
+ round(sum::numeric, 3),
+ round(mean::numeric, 3),
+ round(stddev::numeric, 3),
+ round(min::numeric, 3),
+ round(max::numeric, 3)
+FROM ST_SummaryStats('test', 'rast', 1);
+SELECT
+ count,
+ round(sum::numeric, 3),
+ round(mean::numeric, 3),
+ round(stddev::numeric, 3),
+ round(min::numeric, 3),
+ round(max::numeric, 3)
+FROM ST_SummaryStats('test', 'rast');
ROLLBACK;
-2|-6.85841|-3.429205|6.570795|-10|3.14159
-(2,-6.85841,-3.429205,6.570795,-10,3.14159)
+2|-6.858|-3.429|6.571|-10.000|3.142
2
100
--3.429205|6.570795
--0.068584|1.045941
+-3.429|6.571
+-0.069|1.046
BEGIN
-20|-6.85841|-3.429205|6.570795|-10|3.14159
-1000|-6.85841|-0.0685841|1.045941|-10|3.14159
-20|-6.85841|-3.429205|6.570795|-10|3.14159
-20|-6.85841|-3.429205|6.570795|-10|3.14159
+20|-6.858|-3.429|6.571|-10.000|3.142
+1000|-6.858|-0.069|1.046|-10.000|3.142
+20|-6.858|-3.429|6.571|-10.000|3.142
+20|-6.858|-3.429|6.571|-10.000|3.142
COMMIT