 # About the function

#1

Hello all.
I have a big mass of data with integer data. This data has some error. Question: Is scidb has some functions to make spatial filtering? Or how I can do that?

#2

We can help a lot more if you post your schema–CREATE ARRAY statements–and some idea of what you’ve tried so far.

If what you have is an array :

``````CREATE ARRAY My_Data
<
attr1 : int64,
attr2 : int64
>
[ X=0:*,1000,0, Y=0:*,1000,0 ];``````

Then a query like:

``between ( My_Data, :Min_X, :Min_Y, :Max_X, :Max_Y )``

Will get you everything in a spatial box described by ( :Min_X, :Min_Y ) to ( :Max_X, :Max_Y ).

#3

So, what I have. I have integer data (array A 522x451). This data I load in scidb’s array. Next, I want to create matrix (B) like this:

```0,7 0,5 0,7 0,8 1 0,8 0,7 0,5 0,7 ```
On next step I want to make subarray of A with width 3 and height 3, multiply them and put this subarray in array A in some place. And so on. How can I do that?

#4

So …

``````CREATE ARRAY A
<
attr : int64
>
[ I=0:521,522,0, J=0:450,451,0 ];

CREATE ARRAY B
<
attr : int64
>
[ I=0:2,3,0, J=0:2,3,0];``````

First, what you want to do is to take a subarray(…) of A of the size you want (3x3). Now, the multiply(…) operator is designed to work for double precision values only, so you next need to turn the attrs in the input arrays subarray(A…) and B (which are both int64) into doubles. You accomplish this using the apply(…) and project(…) operators. Having gotten two arrays of the right size, shape and with the appropriately typed attribute, you next multiply(…) them, and store(…) the result into a new array, which we’ll call C.

The point about SciDB is that all of these operations can be combined into a single expression that looks something like this:

``````store (
multiply (
project (
apply (
subarray (
A,
:IMin, :JMin, :IMax, :JMax
),
val, double ( attr )
),
val
),
project (
apply (
B,
val, double ( attr )
),
val
)
),
Result
);``````

Some more notes:

1. I think what you’re doing here is something small and simple to “try things out”. Before you try to make this work on big matrices, I really suggest you spend a little quality time with the documentation concerning chunk sizes, etc. The example arrays above, A and B, aren’t really representative of what you want to do once your arrays get very big.

2. I’ve been careful to use the multiply(…) operator here, because I’m not sure if your input array A is sparse or dense. For dense arrays, consult the documentation. We have implemented a much more efficient and scalable mechanism for handling them.

Hope this helps!

#5

Thank you a lot! Maybe, can you tell me, how can I write stored function on C++, which I compile it to .so library and load into sciDB. I think, it’s easy way to solve my task.