6251 const uint32_t set_count = 2;
6253 int pgrastpos[2] = {-1, -1};
6256 int _isempty[2] = {0};
6257 uint32_t bandindex[2] = {0};
6260 int _hasnodata[2] = {0};
6261 double _nodataval[2] = {0};
6262 double _offset[4] = {0.};
6263 double _rastoffset[2][4] = {{0.}};
6264 int _haspixel[2] = {0};
6265 double _pixel[2] = {0};
6266 int _pos[2][2] = {{0}};
6267 uint16_t _dim[2][2] = {{0}};
6269 char *pixtypename = NULL;
6271 char *extenttypename = NULL;
6276 uint16_t dim[2] = {0};
6279 double nodataval = 0;
6280 double gt[6] = {0.};
6282 Oid calltype = InvalidOid;
6284 const uint32_t spi_count = 3;
6285 uint16_t spi_exprpos[3] = {4, 7, 8};
6286 uint32_t spi_argcount[3] = {0};
6289 SPIPlanPtr spi_plan[3] = {NULL};
6290 uint16_t spi_empty = 0;
6291 Oid *argtype = NULL;
6292 uint8_t argpos[3][8] = {{0}};
6293 char *argkw[] = {
"[rast1.x]",
"[rast1.y]",
"[rast1.val]",
"[rast1]",
"[rast2.x]",
"[rast2.y]",
"[rast2.val]",
"[rast2]"};
6297 SPITupleTable *tuptable = NULL;
6300 bool isnull =
FALSE;
6301 int hasargval[3] = {0};
6302 double argval[3] = {0.};
6303 int hasnodatanodataval = 0;
6304 double nodatanodataval = 0;
6307 Oid ufc_noid = InvalidOid;
6309 LOCAL_FCINFO(ufc_info, FUNC_MAX_ARGS);
6311 int ufc_nullcount = 0;
6327 for (i = 0, j = 0; i < set_count; i++) {
6328 if (!PG_ARGISNULL(j)) {
6329 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
6336 for (k = 0; k <= i; k++) {
6337 if (k < i &&
rast[k] != NULL)
6339 if (pgrastpos[k] != -1)
6340 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6342 elog(ERROR,
"RASTER_mapAlgebra2: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
6350 if (!PG_ARGISNULL(j)) {
6351 bandindex[i] = PG_GETARG_INT32(j);
6364 if (
rast[0] == NULL &&
rast[1] == NULL) {
6365 elog(NOTICE,
"The two rasters provided are NULL. Returning NULL");
6366 for (k = 0; k < set_count; k++) {
6367 if (pgrastpos[k] != -1)
6368 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6374 if (_isempty[0] && _isempty[1]) {
6375 elog(NOTICE,
"The two rasters provided are empty. Returning empty raster");
6379 for (k = 0; k < set_count; k++) {
6380 if (
rast[k] != NULL)
6382 if (pgrastpos[k] != -1)
6383 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6385 elog(ERROR,
"RASTER_mapAlgebra2: Could not create empty raster");
6395 SET_VARSIZE(pgrtn, pgrtn->
size);
6396 PG_RETURN_POINTER(pgrtn);
6401 (
rast[0] == NULL || _isempty[0]) ||
6402 (
rast[1] == NULL || _isempty[1])
6405 if (
rast[0] == NULL || _isempty[0]) {
6418 if (_rast[i] != NULL)
6430 if (_rast[i] == NULL) {
6432 for (k = 0; k < set_count; k++) {
6433 if (pgrastpos[k] != -1)
6434 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6436 elog(ERROR,
"RASTER_mapAlgebra2: Could not create NODATA raster");
6470 for (k = 0; k < set_count; k++) {
6471 if (_rast[k] != NULL)
6473 if (pgrastpos[k] != -1)
6474 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6476 elog(ERROR,
"RASTER_mapAlgebra2: Could not test for alignment on the two rasters");
6480 elog(NOTICE,
"The two rasters provided do not have the same alignment. Returning NULL");
6481 for (k = 0; k < set_count; k++) {
6482 if (_rast[k] != NULL)
6484 if (pgrastpos[k] != -1)
6485 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6491 if (!PG_ARGISNULL(5)) {
6492 pixtypename = text_to_cstring(PG_GETARG_TEXT_P(5));
6495 if (pixtype ==
PT_END ) {
6496 for (k = 0; k < set_count; k++) {
6497 if (_rast[k] != NULL)
6499 if (pgrastpos[k] != -1)
6500 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6502 elog(ERROR,
"RASTER_mapAlgebra2: Invalid pixel type: %s", pixtypename);
6508 if (!PG_ARGISNULL(6)) {
6521 for (k = 0; k < set_count; k++) {
6522 if (_rast[k] != NULL)
6524 if (pgrastpos[k] != -1)
6525 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6527 elog(ERROR,
"RASTER_mapAlgebra2: Could not get output raster of correct extent");
6532 _rastoffset[0][0] = _offset[0];
6533 _rastoffset[0][1] = _offset[1];
6534 _rastoffset[1][0] = _offset[2];
6535 _rastoffset[1][1] = _offset[3];
6543 switch (extenttype) {
6553 (extenttype ==
ET_FIRST && i == 0) ||
6557 elog(NOTICE,
"The %s raster is NULL. Returning NULL", (i != 1 ?
"FIRST" :
"SECOND"));
6558 for (k = 0; k < set_count; k++) {
6559 if (_rast[k] != NULL)
6561 if (pgrastpos[k] != -1)
6562 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6570 elog(NOTICE,
"The %s raster does not have the band at index %d. Returning no band raster of correct extent",
6571 (i != 1 ?
"FIRST" :
"SECOND"), bandindex[i]
6574 for (k = 0; k < set_count; k++) {
6575 if (_rast[k] != NULL)
6577 if (pgrastpos[k] != -1)
6578 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6583 if (!pgrtn) PG_RETURN_NULL();
6585 SET_VARSIZE(pgrtn, pgrtn->
size);
6586 PG_RETURN_POINTER(pgrtn);
6594 _isempty[0] || _isempty[1] ||
6597 elog(NOTICE,
"The two rasters provided have no intersection. Returning no band raster");
6600 if (dim[0] || dim[1]) {
6605 for (k = 0; k < set_count; k++) {
6606 if (_rast[k] != NULL)
6608 if (pgrastpos[k] != -1)
6609 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6611 elog(ERROR,
"RASTER_mapAlgebra2: Could not create no band raster");
6619 for (k = 0; k < set_count; k++) {
6620 if (_rast[k] != NULL)
6622 if (pgrastpos[k] != -1)
6623 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6628 if (!pgrtn) PG_RETURN_NULL();
6630 SET_VARSIZE(pgrtn, pgrtn->
size);
6631 PG_RETURN_POINTER(pgrtn);
6636 for (k = 0; k < set_count; k++) {
6637 if (_rast[k] != NULL)
6639 if (pgrastpos[k] != -1)
6640 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6642 elog(ERROR,
"RASTER_mapAlgebra2: ET_LAST and ET_CUSTOM are not implemented");
6652 elog(NOTICE,
"The two rasters provided do not have the respectively specified band indices. Returning no band raster of correct extent");
6654 for (k = 0; k < set_count; k++) {
6655 if (_rast[k] != NULL)
6657 if (pgrastpos[k] != -1)
6658 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6663 if (!pgrtn) PG_RETURN_NULL();
6665 SET_VARSIZE(pgrtn, pgrtn->
size);
6666 PG_RETURN_POINTER(pgrtn);
6670 for (i = 0; i < set_count; i++) {
6679 if (_band[i] == NULL) {
6680 for (k = 0; k < set_count; k++) {
6681 if (_rast[k] != NULL)
6683 if (pgrastpos[k] != -1)
6684 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6687 elog(ERROR,
"RASTER_mapAlgebra2: Could not get band %d of the %s raster",
6689 (i < 1 ?
"FIRST" :
"SECOND")
6701 if ((extenttype ==
ET_SECOND && !_isempty[1]) || _isempty[0])
6708 if (extenttype ==
ET_SECOND && !_isempty[1] && _hasnodata[1]) {
6709 nodataval = _nodataval[1];
6711 else if (!_isempty[0] && _hasnodata[0]) {
6712 nodataval = _nodataval[0];
6714 else if (!_isempty[1] && _hasnodata[1]) {
6715 nodataval = _nodataval[1];
6718 elog(NOTICE,
"Neither raster provided has a NODATA value for the specified band indices. NODATA value set to minimum possible for %s",
rt_pixtype_name(pixtype));
6730 for (k = 0; k < set_count; k++) {
6731 if (_rast[k] != NULL)
6733 if (pgrastpos[k] != -1)
6734 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6737 elog(ERROR,
"RASTER_mapAlgebra2: Could not add new band to output raster");
6744 for (k = 0; k < set_count; k++) {
6745 if (_rast[k] != NULL)
6747 if (pgrastpos[k] != -1)
6748 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6751 elog(ERROR,
"RASTER_mapAlgebra2: Could not get newly added band of output raster");
6756 (
int) _rastoffset[0][0],
6757 (
int) _rastoffset[0][1],
6758 (
int) _rastoffset[1][0],
6759 (
int) _rastoffset[1][1]
6762 POSTGIS_RT_DEBUGF(4,
"metadata = (%f, %f, %d, %d, %f, %f, %f, %f, %d)",
6779 calltype = get_fn_expr_argtype(fcinfo->flinfo, 4);
6786 if (SPI_connect() != SPI_OK_CONNECT) {
6787 for (k = 0; k < set_count; k++) {
6788 if (_rast[k] != NULL)
6790 if (pgrastpos[k] != -1)
6791 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6794 elog(ERROR,
"RASTER_mapAlgebra2: Could not connect to the SPI manager");
6799 memset(hasargval, 0,
sizeof(
int) * spi_count);
6809 for (i = 0; i < spi_count; i++) {
6810 if (!PG_ARGISNULL(spi_exprpos[i])) {
6812 char place[5] =
"$1";
6813 expr = text_to_cstring(PG_GETARG_TEXT_P(spi_exprpos[i]));
6827 sprintf(place,
"$%d", k);
6833 len = strlen(
"SELECT (") + strlen(expr) + strlen(
")::double precision");
6834 sql = (
char *) palloc(len + 1);
6837 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6840 for (k = 0; k < set_count; k++) {
6841 if (_rast[k] != NULL)
6843 if (pgrastpos[k] != -1)
6844 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6848 elog(ERROR,
"RASTER_mapAlgebra2: Could not allocate memory for expression parameter %d", spi_exprpos[i]);
6852 memcpy(
sql,
"SELECT (", strlen(
"SELECT ("));
6853 memcpy(
sql + strlen(
"SELECT ("), expr, strlen(expr));
6854 memcpy(
sql + strlen(
"SELECT (") + strlen(expr),
")::double precision", strlen(
")::double precision"));
6860 if (spi_argcount[i]) {
6861 argtype = (Oid *) palloc(spi_argcount[i] *
sizeof(Oid));
6862 if (argtype == NULL) {
6865 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6868 for (k = 0; k < set_count; k++) {
6869 if (_rast[k] != NULL)
6871 if (pgrastpos[k] != -1)
6872 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6876 elog(ERROR,
"RASTER_mapAlgebra2: Could not allocate memory for prepared plan argtypes of expression parameter %d", spi_exprpos[i]);
6882 if (argpos[i][j] < 1)
continue;
6886 (strstr(argkw[j],
"[rast1.x]") != NULL) ||
6887 (strstr(argkw[j],
"[rast1.y]") != NULL) ||
6888 (strstr(argkw[j],
"[rast2.x]") != NULL) ||
6889 (strstr(argkw[j],
"[rast2.y]") != NULL)
6891 argtype[k] = INT4OID;
6895 argtype[k] = FLOAT8OID;
6901 spi_plan[i] = SPI_prepare(
sql, spi_argcount[i], argtype);
6904 if (spi_plan[i] == NULL) {
6907 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6910 for (k = 0; k < set_count; k++) {
6911 if (_rast[k] != NULL)
6913 if (pgrastpos[k] != -1)
6914 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6918 elog(ERROR,
"RASTER_mapAlgebra2: Could not create prepared plan of expression parameter %d", spi_exprpos[i]);
6924 err = SPI_execute(
sql,
TRUE, 0);
6925 if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
6928 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6931 for (k = 0; k < set_count; k++) {
6932 if (_rast[k] != NULL)
6934 if (pgrastpos[k] != -1)
6935 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6939 elog(ERROR,
"RASTER_mapAlgebra2: Could not evaluate expression parameter %d", spi_exprpos[i]);
6944 tupdesc = SPI_tuptable->tupdesc;
6945 tuptable = SPI_tuptable;
6946 tuple = tuptable->vals[0];
6948 datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
6949 if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
6952 if (SPI_tuptable) SPI_freetuptable(tuptable);
6953 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6956 for (k = 0; k < set_count; k++) {
6957 if (_rast[k] != NULL)
6959 if (pgrastpos[k] != -1)
6960 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6964 elog(ERROR,
"RASTER_mapAlgebra2: Could not get result of expression parameter %d", spi_exprpos[i]);
6970 argval[i] = DatumGetFloat8(datum);
6973 if (SPI_tuptable) SPI_freetuptable(tuptable);
6983 if (!PG_ARGISNULL(9)) {
6984 hasnodatanodataval = 1;
6985 nodatanodataval = PG_GETARG_FLOAT8(9);
6988 hasnodatanodataval = 0;
6991 case REGPROCEDUREOID: {
6993 if (!PG_ARGISNULL(4)) {
6996 ufc_noid = PG_GETARG_OID(4);
6999 fmgr_info(ufc_noid, &ufl_info);
7003 if (ufl_info.fn_retset) {
7007 else if (ufl_info.fn_nargs < 3 || ufl_info.fn_nargs > 4) {
7017 for (k = 0; k < set_count; k++) {
7018 if (_rast[k] != NULL)
7020 if (pgrastpos[k] != -1)
7021 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7026 elog(ERROR,
"RASTER_mapAlgebra2: Function provided must have three or four input parameters");
7028 elog(ERROR,
"RASTER_mapAlgebra2: Function provided must return double precision not resultset");
7032 if (func_volatile(ufc_noid) ==
'v') {
7033 elog(NOTICE,
"Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
7037 InitFunctionCallInfoData(
7038 *ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL, NULL);
7039 ufc_info->args[0].isnull =
FALSE;
7040 ufc_info->args[1].isnull =
FALSE;
7041 ufc_info->args[2].isnull =
FALSE;
7042 if (ufl_info.fn_nargs == 4)
7043 ufc_info->args[3].isnull =
FALSE;
7045 if (ufl_info.fn_nargs != 4)
7049 if (!PG_ARGISNULL(7))
7051 ufc_info->args[k].value = PG_GETARG_DATUM(7);
7055 ufc_info->args[k].value = (Datum)NULL;
7056 ufc_info->args[k].isnull =
TRUE;
7063 for (k = 0; k < set_count; k++) {
7064 if (_rast[k] != NULL)
7066 if (pgrastpos[k] != -1)
7067 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7070 elog(ERROR,
"RASTER_mapAlgebra2: Invalid data type for expression or userfunction");
7078 (calltype == TEXTOID) && (
7079 (spi_empty != spi_count) || hasnodatanodataval
7082 (calltype == REGPROCEDUREOID) && (ufc_noid != InvalidOid)
7084 for (
x = 0;
x < dim[0];
x++) {
7085 for (
y = 0;
y < dim[1];
y++) {
7088 for (i = 0; i < set_count; i++) {
7093 _x = (int)
x - (
int)_rastoffset[i][0];
7094 _y = (int)
y - (
int)_rastoffset[i][1];
7097 _pos[i][0] = _x + 1;
7098 _pos[i][1] = _y + 1;
7101 if (_band[i] == NULL) {
7102 if (!_hasnodata[i]) {
7104 _pixel[i] = _nodataval[i];
7109 (_x >= 0 && _x < _dim[i][0]) &&
7110 (_y >= 0 && _y < _dim[i][1])
7115 if (calltype == TEXTOID) {
7116 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7120 for (k = 0; k < set_count; k++) {
7121 if (_rast[k] != NULL)
7123 if (pgrastpos[k] != -1)
7124 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7128 elog(ERROR,
"RASTER_mapAlgebra2: Could not get pixel of %s raster", (i < 1 ?
"FIRST" :
"SECOND"));
7132 if (!_hasnodata[i] || !isnodata)
7151 if (!_haspixel[0] && !_haspixel[1])
7155 else if (_haspixel[0] && !_haspixel[1])
7159 else if (!_haspixel[0] && _haspixel[1])
7168 if (hasnodatanodataval) {
7170 pixel = nodatanodataval;
7174 else if (hasargval[i]) {
7179 else if (spi_plan[i] != NULL) {
7183 memset(values, (Datum) NULL,
sizeof(Datum) *
ARGKWCOUNT);
7188 if (spi_argcount[i]) {
7192 if (idx < 1)
continue;
7195 if (strstr(argkw[j],
"[rast1.x]") != NULL) {
7196 values[idx] = _pos[0][0];
7198 else if (strstr(argkw[j],
"[rast1.y]") != NULL) {
7199 values[idx] = _pos[0][1];
7202 (strstr(argkw[j],
"[rast1.val]") != NULL) ||
7203 (strstr(argkw[j],
"[rast1]") != NULL)
7205 if (_isempty[0] || !_haspixel[0])
7208 values[idx] = Float8GetDatum(_pixel[0]);
7210 else if (strstr(argkw[j],
"[rast2.x]") != NULL) {
7211 values[idx] = _pos[1][0];
7213 else if (strstr(argkw[j],
"[rast2.y]") != NULL) {
7214 values[idx] = _pos[1][1];
7217 (strstr(argkw[j],
"[rast2.val]") != NULL) ||
7218 (strstr(argkw[j],
"[rast2]") != NULL)
7220 if (_isempty[1] || !_haspixel[1])
7223 values[idx] = Float8GetDatum(_pixel[1]);
7229 err = SPI_execute_plan(spi_plan[i], values, nulls,
TRUE, 1);
7230 if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
7232 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7235 for (k = 0; k < set_count; k++) {
7236 if (_rast[k] != NULL)
7238 if (pgrastpos[k] != -1)
7239 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7243 elog(ERROR,
"RASTER_mapAlgebra2: Unexpected error when running prepared statement %d", i);
7248 tupdesc = SPI_tuptable->tupdesc;
7249 tuptable = SPI_tuptable;
7250 tuple = tuptable->vals[0];
7252 datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
7253 if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
7255 if (SPI_tuptable) SPI_freetuptable(tuptable);
7256 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7259 for (k = 0; k < set_count; k++) {
7260 if (_rast[k] != NULL)
7262 if (pgrastpos[k] != -1)
7263 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7267 elog(ERROR,
"RASTER_mapAlgebra2: Could not get result of prepared statement %d", i);
7273 pixel = DatumGetFloat8(datum);
7276 if (SPI_tuptable) SPI_freetuptable(tuptable);
7279 case REGPROCEDUREOID: {
7284 for (i = 0; i < set_count; i++) {
7285 ufc_info->args[i].value = Float8GetDatum(_pixel[i]);
7287 ufc_info->args[i].isnull =
FALSE;
7291 ufc_info->args[i].isnull =
TRUE;
7298 if (ufl_info.fn_strict && ufc_nullcount)
7302 if (ufl_info.fn_nargs == 4) {
7305 for (i = 0; i < set_count; i++) {
7307 d[0] = Int32GetDatum(_pos[i][0]);
7308 d[1] = Int32GetDatum(_pos[i][1]);
7311 d[2] = Int32GetDatum(_pos[i][0]);
7312 d[3] = Int32GetDatum(_pos[i][1]);
7316 a = construct_array(d, 4, INT4OID,
sizeof(
int32),
true,
'i');
7317 ufc_info->args[2].value = PointerGetDatum(a);
7318 ufc_info->args[2].isnull =
FALSE;
7321 datum = FunctionCallInvoke(ufc_info);
7324 if (!ufc_info->isnull)
7327 pixel = DatumGetFloat8(datum);
7336 if (calltype == TEXTOID) {
7337 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7341 for (k = 0; k < set_count; k++) {
7342 if (_rast[k] != NULL)
7344 if (pgrastpos[k] != -1)
7345 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7349 elog(ERROR,
"RASTER_mapAlgebra2: Could not set pixel value of output raster");
7361 if (calltype == TEXTOID) {
7362 for (i = 0; i < spi_count; i++) {
7363 if (spi_plan[i] != NULL) SPI_freeplan(spi_plan[i]);
7368 for (k = 0; k < set_count; k++) {
7369 if (_rast[k] != NULL)
7371 if (pgrastpos[k] != -1)
7372 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7377 if (!pgrtn) PG_RETURN_NULL();
7381 SET_VARSIZE(pgrtn, pgrtn->
size);
7382 PG_RETURN_POINTER(pgrtn);
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
double rt_raster_get_x_skew(rt_raster raster)
Get skew about the X axis.
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
int rt_raster_generate_new_band(rt_raster raster, rt_pixtype pixtype, double initialvalue, uint32_t hasnodata, double nodatavalue, int index)
Generate a new inline band and add it to a raster.
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
rt_pixtype rt_pixtype_index_from_name(const char *pixname)
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
rt_extenttype rt_util_extent_type(const char *name)
double rt_pixtype_get_min_value(rt_pixtype pixtype)
Return minimum value possible for pixel type.
int rt_raster_has_band(rt_raster raster, int nband)
Return TRUE if the raster has a band of this number.
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
uint16_t rt_raster_get_height(rt_raster raster)
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
const char * rt_pixtype_name(rt_pixtype pixtype)
uint16_t rt_raster_get_width(rt_raster raster)
rt_errorstate rt_raster_from_two_rasters(rt_raster rast1, rt_raster rast2, rt_extenttype extenttype, rt_raster *rtnraster, double *offset)
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
char * rtpg_strtoupper(char *str)
char * rtpg_trim(const char *input)
char * rtpg_strreplace(const char *str, const char *oldstr, const char *newstr, int *count)
#define POSTGIS_RT_DEBUG(level, msg)
#define POSTGIS_RT_DEBUGF(level, msg,...)