Selecting GeoRaster portions using SQL
Hi,
I am interested in selecting a portion of an image stored in the GeoRaster format inside Oracle. After looking at the documentation, I can see there is something useful in the oracle.spatial.georaster.image.GeoRasterImage - in particular the method:
public RenderedImage getRasterImage(int pyramidLevel,JGeometry window)
However looking at the supplied code sample in the API:
//reading a GeoRaster object from database based on a query
ResultSet rs = statement.executeQuery("SELECT a.georaster FROM georaster_table a where a.georaster.rasterdatatable='RDT' and a.georaster.rasterid=1");
STRUCT geor = (oracle.sql.STRUCT) rs.getObject(1);
//construct a JGeoRaster object
JGeoRaster geoRaster = new JGeoRaster(geor);
//get GeoRasterImage instance
GeoRasterImage geoRasterImage=geoRaster.getGeoRasterImageObject();
//fetch a subset of GeoRaster object as a Java image
RenderedImage image=geoRasterImage.getRasterImage(0,0,0,100,100);
it can be seen that the code to get the resultset uses the unique raster ID to get the initial object, then later in the code the sub-image is retrieved using the pyramid level and coordinates desired.
But my question is this: getting the ResultSet in this manner requires the rasterid to be known ahead of time, which negates the whole reason/ability to select a sub-image based on coordinates/bounding box.
How do I do a SELECT statement using a bounding box and pyramid level?
Hopefully that makes sense
Thanks
MH
Thanks, that advice has gone a long way. This worked well, and I managed to retrieve a blob for the bounding box I provided, and know that there is data there (I wrote the binary directly to disk and it had an appropriate file size).
Now I'm trying to write the blob to a proper image file using this code:
ImageInputStream blobStream = ImageIO.createImageInputStream(img_blob.getBinaryStream());
BufferedImage img = ImageIO.read(blobStream);
String fileName = "image_chip_00.tif";
FileOutputStream out = new FileOutputStream(fileName);
TIFFEncodeParam encodeParam = new TIFFEncodeParam();
encodeParam.setCompression(TIFFEncodeParam.COMPRESSION_NONE);
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, encodeParam);
encoder.encode(img);
Unfortunately it comes back with a NullPointerException for the last line of code, i.e. the "img" object is null. For some reason it has not been filled with the blob data (Note that I know the blob is being retrieved and contains data). This blob originates from a stored procedure I wrote using the getRasterSubset mentioned earlier.
Any ideas why the code may not be working?
On a similar but different approach, does the SDO_GEOR.subset function have a Java API equivalent? For this function, is the "inGeoraster IN SDO_GEORASTER" listed in the spec simply a georaster column name? It sounds like SDO_GEOR.subset is very similar to SDO_GEOR.getRasterSubset except that it returns a georaster object instead of a blob (with no metadata), respectively.
Thanks,
MH
Similar Messages
-
How to store a PDF in a BLOB column, then select/search it using SQL?
We have a simple requirement.
(1.) We have an Oracle 10g DB.
(2.) We want to store PDFs/MS Word docs inside BLOB column in a table.
(3.) We need to show PDF/MS Word content to the user, without opening the PDFs/MS World like we normally do (i.e. Using PDV reader/ MS Word).
(4.) i.e. We need to use SQL statements and
(a.) Get all contents of the PDF/MS WORD doc.
(b.) Search for specific strings inside these docs in the BLOB columns.How to do this pls? Code sample would be really great.
Edited by: user12240205 on Jul 18, 2012 9:35 PM
Edited by: user12240205 on Jul 18, 2012 9:37 PMrp0428 wrote:
>
We have a simple requirement.
>
Really? You mean as opposed to a requirement that might actually be doable?Could be that simple is used as in stupid ? Like in, "+look at this simply idiotic requirement, blah.. blah...+"? ;-)
@user12240205:
BLOBs contains binary data. Not text data. How do you propose to search binary data for strings?
PDF and Word formats include actual text strings and identifiers as part of the formatting. How do you propose that this be identified and ignored when searching for specific strings in the document's content?
PL/SQL does not have the ability to take a page from a PDF/Word document, highlight the search string, and display that to the client. A format-parser is needed to parse the PDF/Word format and generate that as content (e.g. HTML or XML) that can be rendered by a client. How do you propose PL/SQL serves up search strings that it found, when it cannot interpret the document format? (cannot even say what page, section or paragraph, that search string occurs)
Documents can be loaded via the DBMS_LOB interface. Either from the db server's file system, or by the client supplying the document as chunks for "write appending" to a BLOB. See Oracle® Database PL/SQL Packages and Types Reference guide for details.
Text search and document indexing are supported by an Oracle feature called Content Management<a> (which includes interMedia, UltraSearch, Oracle Text, etc).
Oracle also supports (on Window server platforms), the Microsoft Component Object Model (COM). COM interfaces (such as COM for Word) can be used for specialised processing (e.g. searching Word documents). Oracle's COM feature allows one to interface directly with external s/w (e.g. MS Word) via its COM interface. -
Dynamically defined GeoRaster theme using WMS parameter values
Hi everyone,
In addition to dynamically defining a GeoRaster theme using SQL (which is documented by Oracle), is it possible to somehow access the WMS values of parameters in the WMS query which is accessing the theme? For example, can I grab the BBOX values from the WMS REQUEST and use that in my dynamic SQL statement?
My goal for doing this is to select the most appropriate pyramid level of the raster imagery given the map scale of the WMS request.
My other question is when using a GeoRaster theme containing a SQL statement, will the MapViewer WMS engine still automatically select imagery from all and any relevant georaster image that has a portion within the BBOX of the query?
Cheers,
MHA Georaster object can have pyramid levels, and in MapViewer you can define a pyramid level for a theme. If you define this parameter, then for any zoom level that you render, MapViewer will read the pixels for this pyramid level. Depending on the zoom level, you may be loading unecessary data due to the screen resolution. If you do not define the pyramid level, MapViewer will calculate the actual screen resolution given the query and device windows, and will load the pixels for the pyramid level that is closest to the actual screen resolution, resulting on a better performance.
-
In a SQL statement, the SELECT clause is used to
In a SQL statement, the SELECT clause is used to select
(a) columns
(b) rows
(c) tables
(d) none of the above
can any one help ImmediatelyIs used to select rows of specified column...
SELECT column_name(s) FROM table_name -
How to get tax break up of TDS using SQL query ?
Hi all,
We are developing a TDS report using SQL query
Report will contain VendorCode,Date(ap inv date),Vendor name,
Bill value,TDS Amount,
Bill Value 100.000,
TDS (2%) - 2.000,
TDS Surcharge(10% on TDS) - 0.2,
TDS Cess(2%(TDS+TDS Surcharge)) - 0.044,
TDS HeCess(1%(TDS+TDS Surcharge)) - 0.022.
We have developed this report which displays upto
VendorCode,Date(ap inv date),Vendor name,
Bill value,TDS Amount.
How to show tax break up of TDS in SQL query ?
Thanks,
With regards,
Jeyakanthan.Hi gauraw,
Thank for your reply.
I modified the query , pasted the query
as below in query generator,
Select T0.DocNum,T0.DocDate,T0.CardCode as 'Ledger',T1.TaxbleAmnt As 'Bill value',T1.WTAmnt as 'TDSAmt',(TDSAmt * 0.1) as 'TDS_Surch',
(((TDSAmt0.1) + TDSAmt)0.02) as 'TDSCess',
(((TDSAmt0.1) + TDSAmt)0.01) as 'TDSHCess'
FROM OPCH T0 INNER JOIN PCH5 T1 ON T0.DocEntry = T1.AbsEntry
WHERE (T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]')
on clicking execute its showing error message invalid column
name 'TDSAmt'.
With regards,
Jeyakanthan -
Help Required -- Can we use SQL Query to READ data from SAP MDM Tables
Hi All,
Please help.........
Can we use SQL Query to READ(No Creation/Updation/Deletion just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
Thanks in Advance
RegardsAll the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
BR,
Alok -
Create statspack report using sql*developer
Hello,
While connecting with PERFSTAT user I can not create statspack report using SQL*Developer:
@?/rdbms/admin/awrrpt
Error starting at line 1 in command:
@?/rdbms/admin/awrrpt
Error report:
Unable to open file: "?/rdbms/admin/awrrpt.sql"
Actually, my problem or question is that how can PERFSTAT user can generate statspack reports from a Client side. What is the other way a non-dba can see the snapshots histroy and generate report (by using perfstat user ) while joing tables or using views?
Thanks a lot.
Best RegardsHi,
for awr reports @?/rdbms/admin/awrrpt (you need EE+Diagnostic Pack) there is a solution.
Grant execute dbms_workload_repository to <user>;
Grant select_catalog_role to <user>;
get all SNAP_IDs
SELECT TO_CHAR(s.startup_time,'YYYY.MM.DD HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME,
di.db_name DB_NAME,
s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'YYYY.MM.DD HH24:MI:SS') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s,
dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND Di.Startup_Time = S.Startup_Time
ORDER BY snap_id desc;
Select * From Table(Sys.Dbms_Workload_Repository.Awr_Report_Html(DBID, 1, BEGIN_SNAP_ID, END_SNAP_ID));
For statspack i don't know a solutuion. I think the best idea is, create a job to make the statspack report on the server side and access it via external tables or mail them forward to you.
Best regards
Thomas -
Date type is not captured in Visual composer 7.0 using SQL server as DB
Date type is not captured in Visual composer 7.0 when using SQL server as DB, and field type is "SmallDateTime" in DB.
Create new Text tab in fields of Table & select Type as Date in VC or use DSRT date function
-
How to show data in a matrix form from a table using SQL
Dear Friends,
I have a table with three columns with the following data:
Market, Product, Date, Value
Market-A Product-A 01/01/04 34
Market-A Product-A 01/02/04 33
Market-A Product-A 01/03/04 67
Market-A Product-A 01/04/04 64
Market-A Product-B 01/01/04 34
Market-A Product-B 01/02/04 36
Market-A Product-B 01/03/04 77
Market-A Product-B 01/04/04 32
Market-B Product-C 01/01/04 25
Market-B Product-C 01/02/04 56
Market-B Product-C 01/03/04 45
Market-B Product-C 01/04/04 68
Market-B Product-D 01/01/04 78
Market-B Product-D 01/02/04 75
Market-B Product-D 01/03/04 32
Market-B Product-D 01/04/04 35
I have a requirement where in I have to filter the products based on market and then show in the following format on the screen:
After filtering based on Market-A (eg) the data should look like:
01/01/04 01/02/04 01/03/04 01/04/04
Product-A 34 33 67 64
Product-B 34 36 77 32
Kinldy suggest how can I write a query to get the data in this format using SQL
Thanks & Regards,
Vinayscott@ORA92> -- test data:
scott@ORA92> SELECT * FROM a_table
2 /
Market-A Product-A 01/01/04 34
Market-A Product-A 01/02/04 33
Market-A Product-A 01/03/04 67
Market-A Product-A 01/04/04 64
Market-A Product-B 01/01/04 34
Market-A Product-B 01/02/04 36
Market-A Product-B 01/03/04 77
Market-A Product-B 01/04/04 32
Market-B Product-C 01/01/04 25
Market-B Product-C 01/02/04 56
Market-B Product-C 01/03/04 45
Market-B Product-C 01/04/04 68
Market-B Product-D 01/01/04 78
Market-B Product-D 01/02/04 75
Market-B Product-D 01/03/04 32
Market-B Product-D 01/04/04 35
scott@ORA92> -- query:
scott@ORA92> SELECT product,
2 SUM (DECODE (the_date, to_date ('01/01/2004', 'mm/dd/yyyy'), value)) AS "01/01/04",
3 SUM (DECODE (the_date, to_date ('01/02/2004', 'mm/dd/yyyy'), value)) AS "01/02/04",
4 SUM (DECODE (the_date, to_date ('01/03/2004', 'mm/dd/yyyy'), value)) AS "01/03/04",
5 SUM (DECODE (the_date, to_date ('01/04/2004', 'mm/dd/yyyy'), value)) AS "01/04/04"
6 FROM a_table
7 WHERE market = 'Market-A'
8 GROUP BY product
9 /
Product-A 34 33 67 64
Product-B 34 36 77 32
scott@ORA92> -
Month Display problem in OBI using SQL server
Hi I am using SQL Server and in one of the reports that I am producing the month is displayed as
CAL_MONTH
APRIL
AUGUST
DECEMBER
FEBRUARY
JANUARY
JULY
JUNE
MARCH
MAY
NOVEMBER
OCTOBER
SEPTEMBER
instead of
CAL_MONTH
JANUARY
FEBRUARY
MARCh
I used the Evaluate function that I used in Cube (ESSBASE) where it worked OK.
I created a logical column "Sort Order" and used the following expression:
EVALUATE('Rank( %1.dimension.currentmember,%2.members)' AS INTEGER , "MIC"."MIC_DL"."dbo"."DM_DATE"."CAL_MONTH", "MIC"."MIC_DL"."dbo"."DM_DATE"."CAL_MONTH")
Then I set the the Sort Order column with the CAL_MONTH column.
But this is giving me the following error when retrieving thru presentation layer
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: 37000 code: 8180 message: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.. [nQSError: 16001] ODBC error state: 37000 code: 1035 message: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Rank', expected 'OVER'.. [nQSError: 16002] Cannot obtain number of columns for the query result. (HY000)
SQL Issued: SELECT DM_DATE.CAL_MONTH saw_0 FROM MIC_DL ORDER BY saw_0
I used the expression Rankover in place of Rank but nothing fruitful.
Pls. guide.
Edited by: user10729112 on Aug 24, 2009 7:52 AMCould anyone guide on this pls....
I could create a duplicate column containing the vlaues 1,2 .....for the month and use "Case - When " expression but the table has already been built with Jan, Feb ......
Pls. help. -
Multiple select statements in PL/SQL
Hi All
I am new to PL/SQL and my experience is in writing TSQL. There we can write a SQL statement like this to return 3 result set
SELECT empname FROM Employee
SELECT authname FROM Author
SELECT athname FROM sport
how can we write the same 3 statements in PL/SQL and attain the 3 resultsets.
I tried to implement the same using PL/SQL anonymous blocks. But it didn't worked.
DECLARE
P_RECORDSET OUT SYS_REFCURSOR
BEGIN
OPEN P_RECORDSET FOR
SELECT empname FROM Employee;
SELECT authname FROM Author;
SELECT athname FROM sport;
END;
can anybody show how it can be done.
Thanks in advance
George
Edited by: user6290570 on Sep 16, 2009 11:23 PMgeorge2009 wrote:
No i just want to select 3 result sets from 3 select statements, so that it is helpful to compare the resultsets. Compare? How? This is done using the SQL language. Not PL/SQL. Not Java. Not VB. Not anything else.
You would use these other language for flow control and certain forms of conditional logic - but the actual comparison of data sets is done in SQL.
Of course, that is if you do want to do it the most optimal way, that will perform well, and scale well.
SQL is not an I/O API layer - to be used to read() a record and write() a record as if the RDBMS is an ISAM file. That form of row-by-row and slow-by-slow processing dates back to the 80's when we used Cobol.. (or at least for those old farts like me that can actually remember coding in Cobol in the 80's ;-) ).
You want to design and code database applications that are fast, robust, and can scale? Then learn how to use SQL correctly. -
How do I add more than one column to a table using SQL?
Hi
I need to add 3 columns to a table using SQL
the syntax
"ALTER TABLE TEST ADD COLUMN newcol1 float";
works fine - for adding one coumn only.
For multiple columns I tried various permutations along the lines of
"ALTER TABLE TEST ADD (COLUMN newcol01 float, COLUMN new2 float,COLUMN new3 float)";
"ALTER TABLE TIPSTEST ADD COLUMN new1 float"
"ALTER TABLE TIPSTEST ADD COLUMN new2 float"
"ALTER TABLE TIPSTEST ADD COLUMN new3 float"
etc., but this doesn't work.
From a web search it sounds like SQL can only add one column at a time.
I have a workaround : create intermediate temporary tables , copying data and adding
one column at each stage. It seems a fairly awkward way of programming though.
Am I missing something simple : is there a way to add multiple columns in one go?
ThanksOK : solved an underlying problem with this one myself
for the code
String createString;
createString = "select COFFEES.* INTO NEWCOFFEES FROM COFFEES"; // example
Statement stmt;
try {
stmt = a_Globals.database1Connection.createStatement();
stmt.executeUpdate(createString);
stmt.close();
a_Globals.database1Connection.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
} commenting out the line:
a_Globals.database1Connection.close();
Allowed the subsequent SQL statement(s) to work OK. Looks like this was the cause of several
difficulties, preventing me doing several SQL instructions in turn.
Thanks for the responses.
Mike2z -
Got an error while creating bind variables using sql database.
iam going to use sql database for ADF-BC .
i created the bind variable and apply the bind position for the corresponding variable in the view object editor.when i click test it shows me "query is valid". when i tried to run that it gives me two errors.
1) sql error during statement preparation.(ie) select empid ,empname......from the emptable where empid like :'emp' and
2) [Microsoft][SQl server 2000 driver for jDBC] invalid parameter bindings
i need help to know the solution for this...(or) is there any other way to create bind variable ......The 3 binding styles supported by JDev:
Oracle Named - ie. SELECT xxxx FROM xxxx WHERE emp_id = :vEmp (note colon and variable name)
Oracle Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = :1 (note colon)
JDBC Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = ?
Literally this query is sent to the database to execute, then the bind variables values are applied as a separate database operation. If SQL Server doesn't suport any of these binding styles, it's not going to work. As Chris Noonan suggests, try the JDBC Positional style though as you're using a JDBC driver to connect to SQL Server and it should support that style (the others are Oracle styles), and make sure you've switched the binding style on the VO query page to "JDBC Positional" too.
You must also on the VO bind variable page define your bind variables.
Also read the 10.1.3 JDev guide on ADF Business Components and View Object bind variables.
CM. -
Error in loading data using SQL loader
I am getting a error like ‘SQL*Loader -350 syntax error of illegal combination of non-alphanumeric characters’ while loading a file using SQL loader in RHEL. The command used to run SQL*Loader is:
Sqlldr userid=<username>/<password> control =data.ctl
The control file, data.ctl is :
LOAD data
infile '/home/oraprod/data.txt'
append into table test
empid terminated by ',',
fname terminated by ',',
lname terminated by ',',
salary terminated by whitespace
The data.txt file is:
1,Kaushal,halani,5000
2,Chetan,halani,1000
I hope, my question is clear.
Please revert with the reply to my query.
RegardsReplace ''{" by "(" in your control file
LOAD data
infile 'c:\data.txt'
append into table emp_t
empid terminated by ',',
fname terminated by ',',
lname terminated by ',',
salary terminated by whitespace
C:\>sqlldr user/pwd@database control=c.ctl
SQL*Loader: Release 10.2.0.3.0 - Production on Wed Nov 13 10:10:24 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 1
Commit point reached - logical record count 2
SQL> select * from emp_t;
EMPID FNAME LNAME SALARY
1 Kaushal halani 5000
2 Chetan halani 1000
Best regards
Mohamed Houri -
Using sql:variable in an insert statement
I'm writing an insert statement for a table with an XML column. Most of the XML is static, but I need to replace the value of an element with the value of a T-SQL variable, as shown here:
CREATE TABLE [dbo].[OrderDetail](
[OrderID] [int] NULL,
[OrderDetail] [xml] NULL
GO
DECLARE @XMLData XML;
DECLARE @ItemID INT;
SET @ItemID = 1000;
SELECT @XMLData = N'
<OrderDetail xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</OrderDetail>
SET @XMLData.modify('insert <ItemID>[sql:variable("@ItemID")]</ItemID> into (/OrderDetail)[1]')
INSERT INTO [dbo].[OrderDetail] ([OrderID], [OrderDetail])
VALUES (@ItemID, @XMLData);
When I run this, it inserts "[sql:variable("@ItemID")]" instead of the value of @ItemID. If someone could show me the proper syntax, I would really appreciate it. Thanks.Yes, that worked. Now I want to change it a little. I also have an attribute that I need to update with the value of a variable.
DECLARE @XMLData XML;
DECLARE @SetID INT;
DECLARE @SetIDStr VARCHAR(12);
DECLARE @SetIDXML XML;
SET @SetID = 9999;
SET @SetIDStr = CONVERT(VARCHAR(12), @SetID);
SET @SetIDXML = CONVERT(XML, @SetIDStr);
SELECT @XMLData = N'
<OrderDetail xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ItemID>1000</ItemID>
<RightOperand ID="15524" Name="ItemName" Value="15524" />
</OrderDetail>
SET @XMLData.modify('replace value of (/OrderDetail/RightOperand/@ID)[1] with sql:variable("@SetIDXML")');
INSERT INTO [dbo].[OrderDetail] ([OrderID], [OrderDetail])
VALUES (@SetID, @XMLData);
SELECT * FROM [dbo].[OrderDetail];
I'm trying to replace "ID="15524"" with the value of @SetID. This code throws an exception:
Msg 9342, Level 16, State 1, Line 23
XQuery [modify()]: An XML instance is only supported as the direct source of an insert using sql:column/sql:variable.
Thanks again for your help.
Maybe you are looking for
-
My I-Phone has music on it that was synced from an I-Tunes library from a previous computer (which is no longer in use) AND purchases from the I-Tunes store. I would now like to transfer ALL of that music (not just the purchases from the I-Tunes sto
-
The weblogic.security.Security.runAs() and JAAS Subject
Let say that I have Java client with some JAAS code that authenticates the user. The LoginContext generates a Subject containing the Principal name of the authenticated user, but also some private credentials that makes the Subject secure. Now I want
-
Export to PDF in Sharepoint Custom web part.
Hi, I want to export my page to pdf in sharepoint custm web part. I am using below code to export to pdf. when i click the export button i am getting below Error. how to resolve this error? pLease help me. Code protected void ExporttoPDF_Click(object
-
My application doesn't running.
but some times they are running. this situations happend after i update ios. plz i need a solution. i have to say every time i can run the main applications on apple home screen. games,news apps , doesn't working.
-
Rescale images based on largest dimension
I want to batch resize photos for web output. Ideally I'd like to set a max size based on whether they are vertical or horizontal, such as 400 high if vertical or 500 wide if horizontal (without presorting into tall and wide folders). If this is not