6087 const uint32_t set_count = 2;
6089 int pgrastpos[2] = {-1, -1};
6092 int _isempty[2] = {0};
6093 uint32_t bandindex[2] = {0};
6096 int _hasnodata[2] = {0};
6097 double _nodataval[2] = {0};
6098 double _offset[4] = {0.};
6099 double _rastoffset[2][4] = {{0.}};
6100 int _haspixel[2] = {0};
6101 double _pixel[2] = {0};
6102 int _pos[2][2] = {{0}};
6103 uint16_t _dim[2][2] = {{0}};
6105 char *pixtypename = NULL;
6107 char *extenttypename = NULL;
6112 uint16_t dim[2] = {0};
6115 double nodataval = 0;
6116 double gt[6] = {0.};
6118 Oid calltype = InvalidOid;
6120 const uint32_t spi_count = 3;
6121 uint16_t spi_exprpos[3] = {4, 7, 8};
6122 uint32_t spi_argcount[3] = {0};
6125 SPIPlanPtr spi_plan[3] = {NULL};
6126 uint16_t spi_empty = 0;
6127 Oid *argtype = NULL;
6128 uint8_t argpos[3][8] = {{0}};
6129 char *argkw[] = {
"[rast1.x]",
"[rast1.y]",
"[rast1.val]",
"[rast1]",
"[rast2.x]",
"[rast2.y]",
"[rast2.val]",
"[rast2]"};
6133 SPITupleTable *tuptable = NULL;
6136 bool isnull =
FALSE;
6137 int hasargval[3] = {0};
6138 double argval[3] = {0.};
6139 int hasnodatanodataval = 0;
6140 double nodatanodataval = 0;
6143 Oid ufc_noid = InvalidOid;
6145 LOCAL_FCINFO(ufc_info, FUNC_MAX_ARGS);
6147 int ufc_nullcount = 0;
6163 for (i = 0, j = 0; i < set_count; i++) {
6164 if (!PG_ARGISNULL(j)) {
6165 pgrast[i] = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(j));
6172 for (k = 0; k <= i; k++) {
6173 if (k < i &&
rast[k] != NULL)
6175 if (pgrastpos[k] != -1)
6176 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6178 elog(ERROR,
"RASTER_mapAlgebra2: Could not deserialize the %s raster", i < 1 ?
"first" :
"second");
6186 if (!PG_ARGISNULL(j)) {
6187 bandindex[i] = PG_GETARG_INT32(j);
6200 if (
rast[0] == NULL &&
rast[1] == NULL) {
6201 elog(NOTICE,
"The two rasters provided are NULL. Returning NULL");
6202 for (k = 0; k < set_count; k++) {
6203 if (pgrastpos[k] != -1)
6204 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6210 if (_isempty[0] && _isempty[1]) {
6211 elog(NOTICE,
"The two rasters provided are empty. Returning empty raster");
6215 for (k = 0; k < set_count; k++) {
6216 if (
rast[k] != NULL)
6218 if (pgrastpos[k] != -1)
6219 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6221 elog(ERROR,
"RASTER_mapAlgebra2: Could not create empty raster");
6231 SET_VARSIZE(pgrtn, pgrtn->
size);
6232 PG_RETURN_POINTER(pgrtn);
6237 (
rast[0] == NULL || _isempty[0]) ||
6238 (
rast[1] == NULL || _isempty[1])
6241 if (
rast[0] == NULL || _isempty[0]) {
6254 if (_rast[i] != NULL)
6266 if (_rast[i] == NULL) {
6268 for (k = 0; k < set_count; k++) {
6269 if (pgrastpos[k] != -1)
6270 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6272 elog(ERROR,
"RASTER_mapAlgebra2: Could not create NODATA raster");
6306 for (k = 0; k < set_count; k++) {
6307 if (_rast[k] != NULL)
6309 if (pgrastpos[k] != -1)
6310 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6312 elog(ERROR,
"RASTER_mapAlgebra2: Could not test for alignment on the two rasters");
6316 elog(NOTICE,
"The two rasters provided do not have the same alignment. Returning NULL");
6317 for (k = 0; k < set_count; k++) {
6318 if (_rast[k] != NULL)
6320 if (pgrastpos[k] != -1)
6321 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6327 if (!PG_ARGISNULL(5)) {
6328 pixtypename = text_to_cstring(PG_GETARG_TEXT_P(5));
6331 if (pixtype ==
PT_END ) {
6332 for (k = 0; k < set_count; k++) {
6333 if (_rast[k] != NULL)
6335 if (pgrastpos[k] != -1)
6336 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6338 elog(ERROR,
"RASTER_mapAlgebra2: Invalid pixel type: %s", pixtypename);
6344 if (!PG_ARGISNULL(6)) {
6357 for (k = 0; k < set_count; k++) {
6358 if (_rast[k] != NULL)
6360 if (pgrastpos[k] != -1)
6361 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6363 elog(ERROR,
"RASTER_mapAlgebra2: Could not get output raster of correct extent");
6368 _rastoffset[0][0] = _offset[0];
6369 _rastoffset[0][1] = _offset[1];
6370 _rastoffset[1][0] = _offset[2];
6371 _rastoffset[1][1] = _offset[3];
6379 switch (extenttype) {
6389 (extenttype ==
ET_FIRST && i == 0) ||
6393 elog(NOTICE,
"The %s raster is NULL. Returning NULL", (i != 1 ?
"FIRST" :
"SECOND"));
6394 for (k = 0; k < set_count; k++) {
6395 if (_rast[k] != NULL)
6397 if (pgrastpos[k] != -1)
6398 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6406 elog(NOTICE,
"The %s raster does not have the band at index %d. Returning no band raster of correct extent",
6407 (i != 1 ?
"FIRST" :
"SECOND"), bandindex[i]
6410 for (k = 0; k < set_count; k++) {
6411 if (_rast[k] != NULL)
6413 if (pgrastpos[k] != -1)
6414 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6419 if (!pgrtn) PG_RETURN_NULL();
6421 SET_VARSIZE(pgrtn, pgrtn->
size);
6422 PG_RETURN_POINTER(pgrtn);
6430 _isempty[0] || _isempty[1] ||
6433 elog(NOTICE,
"The two rasters provided have no intersection. Returning no band raster");
6436 if (dim[0] || dim[1]) {
6441 for (k = 0; k < set_count; k++) {
6442 if (_rast[k] != NULL)
6444 if (pgrastpos[k] != -1)
6445 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6447 elog(ERROR,
"RASTER_mapAlgebra2: Could not create no band raster");
6455 for (k = 0; k < set_count; k++) {
6456 if (_rast[k] != NULL)
6458 if (pgrastpos[k] != -1)
6459 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6464 if (!pgrtn) PG_RETURN_NULL();
6466 SET_VARSIZE(pgrtn, pgrtn->
size);
6467 PG_RETURN_POINTER(pgrtn);
6472 for (k = 0; k < set_count; k++) {
6473 if (_rast[k] != NULL)
6475 if (pgrastpos[k] != -1)
6476 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6478 elog(ERROR,
"RASTER_mapAlgebra2: ET_LAST and ET_CUSTOM are not implemented");
6488 elog(NOTICE,
"The two rasters provided do not have the respectively specified band indices. Returning no band raster of correct extent");
6490 for (k = 0; k < set_count; k++) {
6491 if (_rast[k] != NULL)
6493 if (pgrastpos[k] != -1)
6494 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6499 if (!pgrtn) PG_RETURN_NULL();
6501 SET_VARSIZE(pgrtn, pgrtn->
size);
6502 PG_RETURN_POINTER(pgrtn);
6506 for (i = 0; i < set_count; i++) {
6515 if (_band[i] == NULL) {
6516 for (k = 0; k < set_count; k++) {
6517 if (_rast[k] != NULL)
6519 if (pgrastpos[k] != -1)
6520 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6523 elog(ERROR,
"RASTER_mapAlgebra2: Could not get band %d of the %s raster",
6525 (i < 1 ?
"FIRST" :
"SECOND")
6537 if ((extenttype ==
ET_SECOND && !_isempty[1]) || _isempty[0])
6544 if (extenttype ==
ET_SECOND && !_isempty[1] && _hasnodata[1]) {
6545 nodataval = _nodataval[1];
6547 else if (!_isempty[0] && _hasnodata[0]) {
6548 nodataval = _nodataval[0];
6550 else if (!_isempty[1] && _hasnodata[1]) {
6551 nodataval = _nodataval[1];
6554 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));
6566 for (k = 0; k < set_count; k++) {
6567 if (_rast[k] != NULL)
6569 if (pgrastpos[k] != -1)
6570 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6573 elog(ERROR,
"RASTER_mapAlgebra2: Could not add new band to output raster");
6580 for (k = 0; k < set_count; k++) {
6581 if (_rast[k] != NULL)
6583 if (pgrastpos[k] != -1)
6584 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6587 elog(ERROR,
"RASTER_mapAlgebra2: Could not get newly added band of output raster");
6592 (
int) _rastoffset[0][0],
6593 (
int) _rastoffset[0][1],
6594 (
int) _rastoffset[1][0],
6595 (
int) _rastoffset[1][1]
6598 POSTGIS_RT_DEBUGF(4,
"metadata = (%f, %f, %d, %d, %f, %f, %f, %f, %d)",
6615 calltype = get_fn_expr_argtype(fcinfo->flinfo, 4);
6622 if (SPI_connect() != SPI_OK_CONNECT) {
6623 for (k = 0; k < set_count; k++) {
6624 if (_rast[k] != NULL)
6626 if (pgrastpos[k] != -1)
6627 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6630 elog(ERROR,
"RASTER_mapAlgebra2: Could not connect to the SPI manager");
6635 memset(hasargval, 0,
sizeof(
int) * spi_count);
6645 for (i = 0; i < spi_count; i++) {
6646 if (!PG_ARGISNULL(spi_exprpos[i])) {
6648 char place[5] =
"$1";
6649 expr = text_to_cstring(PG_GETARG_TEXT_P(spi_exprpos[i]));
6663 sprintf(place,
"$%d", k);
6669 len = strlen(
"SELECT (") + strlen(expr) + strlen(
")::double precision");
6670 sql = (
char *) palloc(len + 1);
6673 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6676 for (k = 0; k < set_count; k++) {
6677 if (_rast[k] != NULL)
6679 if (pgrastpos[k] != -1)
6680 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6684 elog(ERROR,
"RASTER_mapAlgebra2: Could not allocate memory for expression parameter %d", spi_exprpos[i]);
6688 memcpy(
sql,
"SELECT (", strlen(
"SELECT ("));
6689 memcpy(
sql + strlen(
"SELECT ("), expr, strlen(expr));
6690 memcpy(
sql + strlen(
"SELECT (") + strlen(expr),
")::double precision", strlen(
")::double precision"));
6696 if (spi_argcount[i]) {
6697 argtype = (Oid *) palloc(spi_argcount[i] *
sizeof(Oid));
6698 if (argtype == NULL) {
6701 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6704 for (k = 0; k < set_count; k++) {
6705 if (_rast[k] != NULL)
6707 if (pgrastpos[k] != -1)
6708 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6712 elog(ERROR,
"RASTER_mapAlgebra2: Could not allocate memory for prepared plan argtypes of expression parameter %d", spi_exprpos[i]);
6718 if (argpos[i][j] < 1)
continue;
6722 (strstr(argkw[j],
"[rast1.x]") != NULL) ||
6723 (strstr(argkw[j],
"[rast1.y]") != NULL) ||
6724 (strstr(argkw[j],
"[rast2.x]") != NULL) ||
6725 (strstr(argkw[j],
"[rast2.y]") != NULL)
6727 argtype[k] = INT4OID;
6731 argtype[k] = FLOAT8OID;
6737 spi_plan[i] = SPI_prepare(
sql, spi_argcount[i], argtype);
6740 if (spi_plan[i] == NULL) {
6743 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6746 for (k = 0; k < set_count; k++) {
6747 if (_rast[k] != NULL)
6749 if (pgrastpos[k] != -1)
6750 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6754 elog(ERROR,
"RASTER_mapAlgebra2: Could not create prepared plan of expression parameter %d", spi_exprpos[i]);
6760 err = SPI_execute(
sql,
TRUE, 0);
6761 if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
6764 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6767 for (k = 0; k < set_count; k++) {
6768 if (_rast[k] != NULL)
6770 if (pgrastpos[k] != -1)
6771 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6775 elog(ERROR,
"RASTER_mapAlgebra2: Could not evaluate expression parameter %d", spi_exprpos[i]);
6780 tupdesc = SPI_tuptable->tupdesc;
6781 tuptable = SPI_tuptable;
6782 tuple = tuptable->vals[0];
6784 datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
6785 if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
6788 if (SPI_tuptable) SPI_freetuptable(tuptable);
6789 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
6792 for (k = 0; k < set_count; k++) {
6793 if (_rast[k] != NULL)
6795 if (pgrastpos[k] != -1)
6796 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6800 elog(ERROR,
"RASTER_mapAlgebra2: Could not get result of expression parameter %d", spi_exprpos[i]);
6806 argval[i] = DatumGetFloat8(datum);
6809 if (SPI_tuptable) SPI_freetuptable(tuptable);
6819 if (!PG_ARGISNULL(9)) {
6820 hasnodatanodataval = 1;
6821 nodatanodataval = PG_GETARG_FLOAT8(9);
6824 hasnodatanodataval = 0;
6827 case REGPROCEDUREOID: {
6829 if (!PG_ARGISNULL(4)) {
6832 ufc_noid = PG_GETARG_OID(4);
6835 fmgr_info(ufc_noid, &ufl_info);
6839 if (ufl_info.fn_retset) {
6843 else if (ufl_info.fn_nargs < 3 || ufl_info.fn_nargs > 4) {
6853 for (k = 0; k < set_count; k++) {
6854 if (_rast[k] != NULL)
6856 if (pgrastpos[k] != -1)
6857 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6862 elog(ERROR,
"RASTER_mapAlgebra2: Function provided must have three or four input parameters");
6864 elog(ERROR,
"RASTER_mapAlgebra2: Function provided must return double precision not resultset");
6868 if (func_volatile(ufc_noid) ==
'v') {
6869 elog(NOTICE,
"Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
6873 InitFunctionCallInfoData(
6874 *ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL, NULL);
6875 ufc_info->args[0].isnull =
FALSE;
6876 ufc_info->args[1].isnull =
FALSE;
6877 ufc_info->args[2].isnull =
FALSE;
6878 if (ufl_info.fn_nargs == 4)
6879 ufc_info->args[3].isnull =
FALSE;
6881 if (ufl_info.fn_nargs != 4)
6885 if (!PG_ARGISNULL(7))
6887 ufc_info->args[k].value = PG_GETARG_DATUM(7);
6891 ufc_info->args[k].value = (Datum)NULL;
6892 ufc_info->args[k].isnull =
TRUE;
6899 for (k = 0; k < set_count; k++) {
6900 if (_rast[k] != NULL)
6902 if (pgrastpos[k] != -1)
6903 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
6906 elog(ERROR,
"RASTER_mapAlgebra2: Invalid data type for expression or userfunction");
6914 (calltype == TEXTOID) && (
6915 (spi_empty != spi_count) || hasnodatanodataval
6918 (calltype == REGPROCEDUREOID) && (ufc_noid != InvalidOid)
6920 for (
x = 0;
x < dim[0];
x++) {
6921 for (
y = 0;
y < dim[1];
y++) {
6924 for (i = 0; i < set_count; i++) {
6929 _x = (int)
x - (
int)_rastoffset[i][0];
6930 _y = (int)
y - (
int)_rastoffset[i][1];
6933 _pos[i][0] = _x + 1;
6934 _pos[i][1] = _y + 1;
6937 if (_band[i] == NULL) {
6938 if (!_hasnodata[i]) {
6940 _pixel[i] = _nodataval[i];
6945 (_x >= 0 && _x < _dim[i][0]) &&
6946 (_y >= 0 && _y < _dim[i][1])
6951 if (calltype == TEXTOID) {
6952 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 pixel of %s raster", (i < 1 ?
"FIRST" :
"SECOND"));
6968 if (!_hasnodata[i] || !isnodata)
6987 if (!_haspixel[0] && !_haspixel[1])
6991 else if (_haspixel[0] && !_haspixel[1])
6995 else if (!_haspixel[0] && _haspixel[1])
7004 if (hasnodatanodataval) {
7006 pixel = nodatanodataval;
7010 else if (hasargval[i]) {
7015 else if (spi_plan[i] != NULL) {
7019 memset(values, (Datum) NULL,
sizeof(Datum) *
ARGKWCOUNT);
7024 if (spi_argcount[i]) {
7028 if (idx < 1)
continue;
7031 if (strstr(argkw[j],
"[rast1.x]") != NULL) {
7032 values[idx] = _pos[0][0];
7034 else if (strstr(argkw[j],
"[rast1.y]") != NULL) {
7035 values[idx] = _pos[0][1];
7038 (strstr(argkw[j],
"[rast1.val]") != NULL) ||
7039 (strstr(argkw[j],
"[rast1]") != NULL)
7041 if (_isempty[0] || !_haspixel[0])
7044 values[idx] = Float8GetDatum(_pixel[0]);
7046 else if (strstr(argkw[j],
"[rast2.x]") != NULL) {
7047 values[idx] = _pos[1][0];
7049 else if (strstr(argkw[j],
"[rast2.y]") != NULL) {
7050 values[idx] = _pos[1][1];
7053 (strstr(argkw[j],
"[rast2.val]") != NULL) ||
7054 (strstr(argkw[j],
"[rast2]") != NULL)
7056 if (_isempty[1] || !_haspixel[1])
7059 values[idx] = Float8GetDatum(_pixel[1]);
7065 err = SPI_execute_plan(spi_plan[i], values, nulls,
TRUE, 1);
7066 if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
7068 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7071 for (k = 0; k < set_count; k++) {
7072 if (_rast[k] != NULL)
7074 if (pgrastpos[k] != -1)
7075 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7079 elog(ERROR,
"RASTER_mapAlgebra2: Unexpected error when running prepared statement %d", i);
7084 tupdesc = SPI_tuptable->tupdesc;
7085 tuptable = SPI_tuptable;
7086 tuple = tuptable->vals[0];
7088 datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
7089 if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
7091 if (SPI_tuptable) SPI_freetuptable(tuptable);
7092 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7095 for (k = 0; k < set_count; k++) {
7096 if (_rast[k] != NULL)
7098 if (pgrastpos[k] != -1)
7099 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7103 elog(ERROR,
"RASTER_mapAlgebra2: Could not get result of prepared statement %d", i);
7109 pixel = DatumGetFloat8(datum);
7112 if (SPI_tuptable) SPI_freetuptable(tuptable);
7115 case REGPROCEDUREOID: {
7120 for (i = 0; i < set_count; i++) {
7121 ufc_info->args[i].value = Float8GetDatum(_pixel[i]);
7123 ufc_info->args[i].isnull =
FALSE;
7127 ufc_info->args[i].isnull =
TRUE;
7134 if (ufl_info.fn_strict && ufc_nullcount)
7138 if (ufl_info.fn_nargs == 4) {
7141 for (i = 0; i < set_count; i++) {
7143 d[0] = Int32GetDatum(_pos[i][0]);
7144 d[1] = Int32GetDatum(_pos[i][1]);
7147 d[2] = Int32GetDatum(_pos[i][0]);
7148 d[3] = Int32GetDatum(_pos[i][1]);
7152 a = construct_array(d, 4, INT4OID,
sizeof(
int32),
true,
'i');
7153 ufc_info->args[2].value = PointerGetDatum(a);
7154 ufc_info->args[2].isnull =
FALSE;
7157 datum = FunctionCallInvoke(ufc_info);
7160 if (!ufc_info->isnull)
7163 pixel = DatumGetFloat8(datum);
7172 if (calltype == TEXTOID) {
7173 for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
7177 for (k = 0; k < set_count; k++) {
7178 if (_rast[k] != NULL)
7180 if (pgrastpos[k] != -1)
7181 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7185 elog(ERROR,
"RASTER_mapAlgebra2: Could not set pixel value of output raster");
7197 if (calltype == TEXTOID) {
7198 for (i = 0; i < spi_count; i++) {
7199 if (spi_plan[i] != NULL) SPI_freeplan(spi_plan[i]);
7204 for (k = 0; k < set_count; k++) {
7205 if (_rast[k] != NULL)
7207 if (pgrastpos[k] != -1)
7208 PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
7213 if (!pgrtn) PG_RETURN_NULL();
7217 SET_VARSIZE(pgrtn, pgrtn->
size);
7218 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,...)