Spatial data load
Hi,
we have couple of files to be loaded into Oracle spatial.
One file has columns like SITE, LAT(NAD83),LON(NAD83),LAT(DEGREE),LAT(MIN),LAT(SEC),
LON(DEGREE),LON(MIN),LON(MIN).
sample data(Plymouth,37.237778,121.832111,37,14,16,121,49,55.6)
and other file has SITENUM,LAT(DEGREE),LAT(MIN),LAT(SEC),LON(DEGREE),LON(MIN),LON(SEC)
Sample data(1,24,55,6.34,80,38,6.99)
I can be able to create the table structures to accommodate the
data,But I'm not sure to setting up the data in order while loading it.I know how to update the metadata and creating spatial indexes once the data successfully loaded.
My question is how to organize the coordinates using SDO_GEOMETRY?
Could somebody help me to create table structures for those files and load the data?
Thanks in advance
Scott
Hi Scott,
I was able to get this to work for the first one:
create table a (site varchar2(20),geometry mdsys.sdo_geometry,
latd number, latm number, lats number,
lond number, lonm number, lons number);
then I made a control file called a.ctl that included the data:
LOAD DATA
INFILE *
INTO TABLE a
replace
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
site,
geometry COLUMN OBJECT
( sdo_gtype constant 2001,
sdo_srid constant 8265,
SDO_POINT COLUMN OBJECT
( Y INTEGER EXTERNAL,
X INTEGER EXTERNAL
latd,
latm,
lats,
lond,
lonm,
lons
begindata
Plymouth,37.237778,121.832111,37,14,16,121,49,55.6
I loaded the data like this:
sqlldr scott/tiger a.ctl
Note data is loaded into spatial as long/lat, so I reversed x and y in the sdo_point field. Also, the SRID for nad83 is 8265.
Regarding the second set of data, you will need to write a function that takes as input degrees, minutes, seconds in lat/long and returns an sdo_geometry object that can be loaded.
Hope this helps,
Dan
Similar Messages
-
Need Help about Spatial Data Load - Mapviewer
Hello everybody,
I need an immediate help about spatial data load. I installed Oracle mapviwer quick start and try to work on it. However, I could not pass the load step. My questions are;
1- Where can I find and download my country's data set (spatial data)
2- With mapviwer, how can I load spatial data to my tables on database (Oracle). Those tables have sdo_geometry columns and I want to query location data, but could not load
Regards,
DilekFor Mapviewer questions, please post in the following forum:
MapViewer
Thanks -
Hello everyone,
I need to load location information of the cities in my country (TURKEY) in an oracle table. Meaning that, geometry column, whose data type is SDO_GEOMETRY should be filled with the location information. How can I accomplish this task? I installed mapviewer quick start. Is there an option for loading data in mapviewer?
Please help me
Regards,
DilekDalik,
Are you looking to buy data, or just use open-source data?
OSM probably has the best open-source data, but your government may also provide data at low or no cost. The most difficult part will be getting it converted into a format you can consume. OSM can output shapefiles, which can be easily converted to sdo_geometry - so that is one way to go.
OSM page for Istanbul: OpenStreetMap: Istanbul, Turkey Metro Region
Bryan -
Conversion of .dgn file to .shp files for spatial data processing
Hi All,
Presently I am working oracle spatial database (10gR2). I have following task:
Task: Spatial data loading into oracle database 10g Release 2:
Task process description: Client has given the input file as with .dgn extension. So we have to convert that to .shp file and load to spatial database.
There is utility in OTN site for loading data .shp file data into spatial database. This we can able to do.
Now I am looking for how to convert the .dgn file to .shp file? I mean, if there is any tool for it or any commands to do this in specific environment.
Any help would appreciate.
Thanks,
[email protected]Hi,
There are several ways to do this.
Get a general GIS format translator. I use FME. This can be obtained from SAFE at safe.com. There is a free 30 day evaluation.
Get GIS software which has a data translation facility. Take your pick of the systems.
Write some code to read the DGN into Oracle. The DGN format can be found at http://www.bentley.com/en-US/Products/MicroStation/OpenDGN/. You need to know the version of DGN.
Ask your client to supply data in SHP format.
Ivan -
Oracle 11g R2, Problem Loading Spatial Data
We have a geodatabase which has been implemented by oracle spatial. it has been working quite fine since 2 years ago. Recently the data center serving our geodatabase has been upgraded on both software and hardware specifications. The handler application now has difficulty retrieving spatial data. The problem is somehow strange; only some spatial objects are loaded and then application encounters exceptions.
Previous working database engine was an Oracle 11g R1 and the new one is Oracle 11g R2. The application is a java application mostly written by swing. Here is the stack trace:
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1200)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1155)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:279)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:202)
at oracle.jdbc.driver.T4CCallableStatement.fetch(T4CCallableStatement.java:1079)
at oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:369)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:273)
at ir.mas.aamar.service.map.MapService.getModifiedMap(MapService.java:405)
at ir.mas.aamar.map.MapPanel.redrawLayers(MapPanel.java:504)
at ir.mas.aamar.map.LayersTree.onSnapshotDisplayCheckBoxItemChanged(LayersTree.java:420)
at ir.mas.aamar.map.LayersTree.onMouseReleased(LayersTree.java:204)
at ir.mas.aamar.map.LayersTree.access$0(LayersTree.java:188)
at ir.mas.aamar.map.LayersTree$1.mouseReleased(LayersTree.java:170)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1200)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1155)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:279)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:194)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:853)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1267)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1469)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:389)
at ir.mas.aamar.service.map.MapService.executeJDBCQuery(MapService.java:78)
at ir.mas.aamar.service.map.MapService.getSnapshotsForThisTermPlusHoze(MapService.java:1013)
at ir.mas.aamar.dialog.edit.EditTools.refreshLayersCombo(EditTools.java:327)
at ir.mas.aamar.dialog.edit.EditTools.refresh(EditTools.java:301)
at ir.mas.aamar.dialog.edit.EditTools.<init>(EditTools.java:103)
at ir.mas.aamar.dialog.edit.EditTools.editTools(EditTools.java:62)
at ir.mas.aamar.map.MapPanel.paintComponent(MapPanel.java:7591)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.sql.SQLRecoverableException: Closed Resultset: next
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:224)
at ir.mas.aamar.service.map.MapService.getSnapshotsForThisTermPlusHoze(MapService.java:1014)
at ir.mas.aamar.dialog.edit.EditTools.refreshLayersCombo(EditTools.java:327)
at ir.mas.aamar.dialog.edit.EditTools.refresh(EditTools.java:301)
at ir.mas.aamar.dialog.edit.EditTools.<init>(EditTools.java:103)
at ir.mas.aamar.dialog.edit.EditTools.editTools(EditTools.java:62)
at ir.mas.aamar.map.MapPanel.paintComponent(MapPanel.java:7591)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at ir.mas.aamar.dialog.edit.EditTools.setTypeOfEditModel(EditTools.java:452)
at ir.mas.aamar.dialog.edit.EditTools.<init>(EditTools.java:104)
at ir.mas.aamar.dialog.edit.EditTools.editTools(EditTools.java:62)
at ir.mas.aamar.map.MapPanel.paintComponent(MapPanel.java:7591)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I read in some forums that the problem could be caused by jdbc version incompatibility, so I just copied jdbc archives from the installed oracle 11g R2 jdbc folder but the problem persists. Last thing I should mention is that only spatial data is problemistic and non-spatial data is easily loaded.
Please Help, Thanks.Hi storm,
During the installation of oracle as you said if you have given the global password, basically this specific password will reflect to users such as
-sys
-system
-dbsnmp
-sysman
As you are new to oracle the basics that you should know is that "SYS" user is the highly privileged user in Oracle and should be logged in as "sys as sysdba" with his respective password (i.e. the global password that you have entered during database installation) to obtain his privilege. Remember to manipulate your database with caution when you are logged in as the sys user. You can log into the database using the sys user in the following way:
c\> sqlplus sys as sysdba
password: ****** --It will ask you for the password and you will have to give the global password that was given during installation
Hope this helps!!!
Regards, -
Loading spatial data by sql *loader
hi there
i have a load_kat_opcina.ctl file from which i should load spatial data into my 10g db table.
load_data.ctl file is as shown below:
LOAD DATA
INFILE *
REPLACE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE KAT_OPCINA
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(KO_MBR NULLIF KO_MBR=BLANKS,
KO_SIFRA NULLIF KO_SIFRA=BLANKS,
KO_NAZIV NULLIF KO_NAZIV=BLANKS,
KO_ID NULLIF KO_ID=BLANKS,
ID NULLIF ID=BLANKS,
is_null1 FILLER CHAR,
POVRSINA COLUMN OBJECT NULLIF is_null1='E'
( sdo_gtype INTEGER EXTERNAL,
sdo_srid INTEGER EXTERNAL NULLIF POVRSINA.sdo_srid=BLANKS,
SDO_POINT COLUMN OBJECT NULLIF is_null1='C'
( X INTEGER EXTERNAL,
Y INTEGER EXTERNAL,
Z INTEGER EXTERNAL NULLIF POVRSINA.SDO_POINT.Z=BLANKS),
SDO_ELEM_INFO VARRAY terminated by ';' NULLIF is_null1='P'
(SDO_ORDINATES INTEGER EXTERNAL),
SDO_ORDINATES VARRAY terminated by ':' NULLIF is_null1='P'
(SDO_ORDINATES INTEGER EXTERNAL)
BEGINDATA
0|426|MARKU[EVEC|314717|6789094|
0|3131|VURNOVEC|16605787|6789097|
#C|2003|||||1|1005|3|1|2|1|169|......|5589490440|5082192250:
0|3034|\UR\EKOVEC|16225011|6789100|
0|35|^EHI|12297784|6789190|
#C|2003|||||1|1005|2|1|2|1|239|....|5574944600|5064714553:
0|221|ODRANSKI OBRE@|12441649|6789193|
0|353|TRPUCI|14071974|6789199|
i have deleted most of data here due to space savings.
i call sql *loader from winxp command prompt as follows:
SQLLDR CONTROL=C:\temp\load_kat_opcina.ctl, USERID=username/pswrd@sid, LOG=logfile.log,BAD==baz.bad, DISCARD=DISCARD=toss.dsc
after executing command, table 'kat_opcina' is not filled with data from this .ctl file.
the following is the content of the log file:
SQL*Loader: Release 10.2.0.1.0 - Production on Sri Svi 31 14:20:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: C:\TEMP\load_kat_opcina.ctl
Data File: C:\TEMP\load_kat_opcina.ctl
Bad File: C:\TEMP\baz.bad
Discard File: C:\TEMP\toss.dsc
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: 1:1 = 0X23(character '#'), in next physical record
Path used: Conventional
Table KAT_OPCINA, loaded from every logical record.
Insert option in effect for this table: REPLACE
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
KO_MBR FIRST * | O(") CHARACTER
NULL if KO_MBR = BLANKS
KO_SIFRA NEXT * | O(") CHARACTER
NULL if KO_SIFRA = BLANKS
KO_NAZIV NEXT * | O(") CHARACTER
NULL if KO_NAZIV = BLANKS
KO_ID NEXT * | O(") CHARACTER
NULL if KO_ID = BLANKS
ID NEXT * | O(") CHARACTER
NULL if ID = BLANKS
IS_NULL1 NEXT * | O(") CHARACTER
(FILLER FIELD)
POVRSINA DERIVED * COLUMN OBJECT
NULL if IS_NULL1 = 0X45(character 'E')
*** Fields in POVRSINA
SDO_GTYPE NEXT * | O(") CHARACTER
SDO_SRID NEXT * | O(") CHARACTER
NULL if POVRSINA.SDO_SRID = BLANKS
SDO_POINT DERIVED * COLUMN OBJECT
NULL if IS_NULL1 = 0X43(character 'C')
*** Fields in POVRSINA.SDO_POINT
X NEXT * | O(") CHARACTER
Y NEXT * | O(") CHARACTER
Z NEXT * | O(") CHARACTER
NULL if POVRSINA.SDO_POINT.Z = BLANKS
*** End of fields in POVRSINA.SDO_POINT
SDO_ELEM_INFO DERIVED * ; VARRAY
NULL if IS_NULL1 = 0X50(character 'P')
*** Fields in POVRSINA.SDO_ELEM_INFO
SDO_ORDINATES FIRST * | O(") CHARACTER
*** End of fields in POVRSINA.SDO_ELEM_INFO
SDO_ORDINATES DERIVED * : VARRAY
NULL if IS_NULL1 = 0X50(character 'P')
*** Fields in POVRSINA.SDO_ORDINATES
SDO_ORDINATES FIRST * | O(") CHARACTER
*** End of fields in POVRSINA.SDO_ORDINATES
*** End of fields in POVRSINA
Record 1: Rejected - Error on table KAT_OPCINA.
ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
ORA-13365: layer SRID does not match geometry SRID
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
Record 2: Rejected - Error on table KAT_OPCINA.
ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
ORA-13365: layer SRID does not match geometry SRID
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
Record 33: Rejected - Error on table KAT_OPCINA.
ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
ORA-13365: layer SRID does not match geometry SRID
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
SQL*Loader-510: Physical record in data file (C:\TEMP\load_kat_opcina.ctl) is longer than the maximum(65536)
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
Specify SKIP=33 when continuing the load.
Table KAT_OPCINA:
0 Rows successfully loaded.
33 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 215168 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 33
Total logical records rejected: 33
Total logical records discarded: 0
Run began on Sri Svi 31 14:20:28 2006
Run ended on Sri Svi 31 14:20:32 2006
Elapsed time was: 00:00:04.51
CPU time was: 00:00:00.26
error messages are all the same for record numbers: 3-32.
so, i'd like to know what am i doing wrong that table cannot be filled with data using sql *loader.
also, would like to know if there's another way of loading data into table from .ctl file (using maybe some other tool)
appreciate any help
thanksHi,
You receive:
ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
ORA-13365: layer SRID does not match geometry SRID
Have you created spatial index for table PORVSINA? I guess that yes, and you have created it with non NULL SRID value? So, ORA-13365 means that you are trying to insert spatial data with SRID that is not the same as SRID defined in spatial index.
Check index SRID and your data SRID, they must be the same. Or, you can disable spatial index.
Andrejus -
How to load spatial data from .shp file
Could anyone suggest an easy to use, free tool to upload spatial data from .shp file (or/and other open source spatial file sources) into an Oracle Locator database?
We have licensing for ArcGIS10, but nobody (including ArcGIS) have been able to successfully create a direct connection from their software to our Oracle 10.2 database.
Client desktops here are Windows 7 64bit, which further complicates matters (tend to find neither ArcGIS nor Oracle support 64bit OS in a cogent fashion)790951,
. . . .You can also try Oracle's ShapeFile Converter (shp2sdo). It's a command line utility so there's automation potential.
. . . .Note that ESRI's tools may (depending on how they're used) store spatial content in Oracle Spatial as BLOBs containing their ST_GEOMETRY data-type (rather than Oracle's SDO_GEOMETRY type).
Regards,
Noel -
How to load an image as spatial data
Hi,
I am very new to oracle spatial.
Currently, i have created an image (floor plan - using MS Visio 2003). Can anyone please advise me how i can store this floor plan as a spatial data?
And how to mark a point on the map when i have selected the place?
Thanks and regards,
EstherThe only solution for a JSP page to browse your directories and upload a file is the <input type="file"> component.
You then submit your form, which will send an HttpRequest.
Your form needs to use method="post" and enctype="multipart/form-data"
It is recommended you use a library such as the [Jakarta commons Fileupload component|http://commons.apache.org/fileupload/] to handle the file upload at the server end.
Cheers,
evnafets -
Best Practice for Storing Spatial Data in Multiple Projections?
From what I've been able to determine MS SQL can't do reprojections is that correct? Assuming it is, the state of Washington requires that our GIS data be managed in Washington Stat Plane South
but for our web mapping sites need the data in Web Mercator. Is it OK then to have two geometry columns in a spatial enabled table, say a county table, one in WSPS and the other in WM?
I’m coming at this from a 30 year background in GIS using ESRI software.
Usually we would store the shape / geometry in one projection and project it to other on the fly when needed.
That way there is only one definitive source. I don’t see a way to do this in MS SQL.Hi Scott.
Storing two columns of spatial data is fine in SQL Server. And you are correct that there is no built-in reprojection in SQL Server, most folks do that as part of data loading. There was talk of porting parts of ogr2ogr to SQLCLR, but I don't think anyone
did that.
Cheers, Bob -
DISPLAY SPATIAL DATA USING JDBC ON A JAVA FRAME
I am trying to set up some spatial data and need help in getting some sample
code for displaying the data on a Java Frame using JDBC.
The shapes I am setting up are simple polygons, lines, circles. I was going
through the samples in the demo directory under $ORACLE_HOME/md/demo/examples, but could not find any JDBC
I would really appreciate if you can point me towards some sample code and any other spatial resources.
MadhukarHere you go. It uses JDBC to fetch geoms, convert them into Java JGeometry objects, which then create Java2D shapes (these are functions of the public sdoapi.jar library). It then uses some class in the sdovis.jar library (the rendering engine of MapViewer) to setup the necessary viewport transform. If you know how to setup the viewport transform, then you dont even need sdovis. sdovis.jar is found in an deployed MapViewer's WEB-INF/lib directory. Or you can extract it from the mapviewer.ear's web.war file.
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.awt.image.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import oracle.jdbc.OracleDriver;
import oracle.sdovis.*;
import oracle.sdovis.style.*;
import oracle.sdovis.util.*;
import oracle.spatial.geometry.JGeometry;
import oracle.sql.STRUCT;
* A very simple program that shows stuff from db in a JFrame
* <p>
public class tilsvgui2 extends JFrame
final static int mapWidth = 640;
final static int mapHeight = 480;
static JSDOGeometry geom = null;
public tilsvgui2()
setSize(mapWidth+40, mapHeight+40);
setVisible(true);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) { System.exit(0); }
public void paint(Graphics g)
super.paint(g);
int w = this.getWidth(), h = this.getHeight();
Insets inset = this.getInsets();
double[] mbr = geom.getMBR();
//from sdovis; it will setup the viewport transform
XFViewPort xfp = new XFViewPort();
xfp.setDeviceView(inset.left, inset.top, w-inset.left-inset.right-1, h-inset.top-inset.bottom-1);
xfp.setDataView(mbr[0], mbr[1], mbr[2], mbr[3]);
AffineTransform af = xfp.getAffineTransform(); //get the viewport transform
Shape shp = geom.createShape(af); //create a proper shape that fits the viewport
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.red);
g2.drawRect(inset.left, inset.top, w-inset.left-inset.right-1, h-inset.top-inset.bottom-1);
//draw the shape itself
g2.setColor(Color.blue);
g2.draw(shp);
public static void getStuff() throws Exception
System.out.println("Loading geometry...");
Connection conn = getConnection("mapsrus.us.oracle.com", "1521", "orcl", "scott", "tiger");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select geom, totpop from counties where county='Merrimack' and state_abrv='NH'");
while(rset.next())
STRUCT st = (STRUCT) rset.getObject(1);
geom = JSDOGeometry.loadFromDB(st);
int population = rset.getInt(2);
break; //displaying only the first geometry
rset.close();
stmt.close();
conn.close();
private static Connection getConnection(String host,
String port,
String sid,
String username,
String password)
throws SQLException
String thinConn = "jdbc:oracle:thin:@"+host+":"+port+":"+sid;
Driver d = new OracleDriver();
Connection conn = DriverManager.getConnection(thinConn,username,password);
conn.setAutoCommit(false);
return conn;
public static void main(String[] args)
try{
getStuff();
}catch(Exception e)
e.printStackTrace(System.err);
new tilsvgui2();
} -
Cannot edit Oracle Spatial data
Hello,
I am running into some problems with my Oracle Spatial data. Maybe somebody has some insight. Here's what is going on:
1) I am able to connect to and view the data in uDig but I cannot edit the data and also the data shows up in the table of contents with a line symbol even though it is polygon data (it renders correctly in the map as polygons). I try using the 'Create Polygon Geometries' tool and it errors saying 'Create Polygon Tool' cannot operate on current layer.
2) When I try testing edits through WFS-T it errors and tells me that the table is read only.
The table is in the USERS tablespace and I have verified that it is read/write. I also set object permissions on the user: ALTER, DELETE, INSERT, SELECT, UPDATE
Am I missing something obvious? Anyone else have this problem? Thanks a lot for any ideas anyone has.My apologies for the confusion. My insert statement DID work just fine. I just wasn't seeing it...probably because I was querying the table in Enterprise Manager DB Control and it looks like it takes some time to refresh. So it appears that user permissions are not the issue.
I have used two data loading methods:
Before loading data, I needed to create a user defined coordinate reference system:
1 create projection operation for my custom projection
2 configure projection parameters
3 create the projected CRS in mdsys.sdo_coord_ref_system
First data load steps
1 shp2sdo.exe my_shapefile my_table -g geom -s 1000002 -v
2 execute my_table.sql
3 execute sqlldr.exe
4 EXECUTE SDO_MIGRATE.TO_CURRENT('my_table','GEOM');
5 CREATE INDEX my_table_index ON my_table(geom) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
Second data load steps:
1 open up MapBuilder, make a connection, and go through the Import Shapefile wizard. MapBuilder automatically creates a spatial index.
Does it appear that I am missing any steps or doing anything obviously wrong that would be causing me to not be able to edit the data through clients such as uDig or WFS-T? -
Mapviewer - Spatial Data Cache
I am trying to clear the spatial data cache in two different versions (mv10 & mv11ea) of Mapviewer without success. To confirm that the cache is being cleared I have enabled the report_stats as below in the mapViewerConfig.xml for both versions
<spatial_data_cache max_cache_size="64"
report_stats="true"
/>After a few requests I note the following in the log:
Cache group PARCEL_VIEW_SHAPE_82473_PDT_GEOM statistics:
capacity: 262144
size: 145988
load factor: 0.95
# of chains: 88837
max chain depth: 8
avg chain depth: 1.6433242905546113
empty bucket %: 0.6611137390136719
total mem size : 28169KBKnowing (assuming) that this cache group is populated by a single theme that references the PARCEL_VIEW table I then issue the following via the Admin section of the Mapviewer control.
<?xml version="1.0" standalone="yes"?>
<non_map_request>
<clear_theme_cache data_source="vicmap" theme="THEME_PARCEL" />
</non_map_request>Then, after waiting patiently for the next set of statistics to appear in the log (BTW, is there a way to change the frequency from 10 minutes to something more regular?) I notice that the information for the cache group has not changed.
Am I following the correct steps here? If I wish to clear the spatial cache, should I be monitoring these statistics?
All advice most welcome.
Ross.Hi Ross,
we'll review the statistics reported and check why it is not changing. The frequency is currently hard-coded (5 minutes), and there is no parameter on the configuration file to change that. We may consider this in the future.
Joao -
Export to "insert" spatial data
I'm using sqldeveloper-1.1.3.with an 11g R1 database. I'm trying to get the insert statements (including the SDO_GEOMETRY) from a table which I loaded from Shapefile.
I am getting inert statements without any spatial data like below:
Insert into TU (TRID,GEOM) values (100,'MDSYS.SDO_GEOMETRY');
I am using this method: Right-click on the table in the "connections explorer tree", select Export Data, then insert...
Is there any other way to export spatial data to insert sql.Thnx Irian
I used the same with sql Developer 2.1. It worked fine -
3D visualization of spatial data
Hi,
I am just wondering if anybody has managed to do 3d visualization of spatial data on web either vrml or x3d ?
also any help on loading 3d data in oracle spaital would be really appriciated as well.
Regards
VikeshHi LievenD,
If you want to view TDMS files (which I would recommend), you have two options:
1) Make a LabVIEW program. This is very trivial though. I attached a VI that pulls out the data in two different ways and as you can see it only has four functions.
2) You can view all of the data in Microsoft Excel using this add-on: TDM Excel Add-In For Microsoft Excel Download
Have a great day,
Chris V
Applications Engineer
National Instruments
Attachments:
Visualizing TDMS.vi 12 KB -
Updating spatial data USING JAVA
I want to update spatial data using java.Does anyone know how can i do this;;;
for example i have created the following table.
CREATE TABLE customers (
customer_id NUMBER,
last_name VARCHAR2(30),
first_name VARCHAR2(30),
street_address VARCHAR2(40),
city VARCHAR2(30),
state_province_code VARCHAR2(2),
postal_code VARCHAR2(9),
cust_geo_location SDO_GEOMETRY);
HOW CAN I UPDATE THE FIELD:cust_geo_location,
WHICH TYPE IS: SDO_GEOMETRY;;;;;
I wrote a programm in java, which updates the FIELD CUSTOMER_ID.
( rset.absolute(3);
rset.updateInt("CUSTOMER_ID",2222 );
CUSTOMER_ID = rset.getInt("CUSTOMER_ID");
rset.next();
rset.updateRow(); ).
---------- THE FULL JAVA PROGRAMM
import java.sql.*;
import java.io.*;
import java.util.Date;
public class update{
public static void main (String args [])
throws SQLException, IOException
System.out.println ("Loading Oracle driver");
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
catch (ClassNotFoundException e)
System.out.println ("Could not load the driver");
e.printStackTrace ();
System.out.println ("Connecting to the local database");
try{
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE", "sp", "spgianna");
Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
// String LAST_NAME,FIRST_NAME ;
int CUSTOMER_ID ;
ResultSet rset = stmt.executeQuery("SELECT CUSTOMER_ID FROM CUSTOMERS");
/* while ( rset.next() ) {
CUSTOMER_ID = rset.getInt("CUSTOMER_ID");
LAST_NAME = rset.getString("LAST_NAME");
FIRST_NAME = rset.getString("FIRST_NAME");
System.out.println( CUSTOMER_ID+""+LAST_NAME + " " +FIRST_NAME);
rset.absolute(3);
rset.updateInt("CUSTOMER_ID",2222 );
CUSTOMER_ID = rset.getInt("CUSTOMER_ID");
rset.next();
rset.updateRow();
System.out.println(CUSTOMER_ID);
catch(SQLException sqle) {
System.out.println("SQL Exception encountered: " );
} catch(Exception e) {
System.out.println("Unexpected Exception: " );
HOW CAN I UPDATE THE FIELD:cust_geo_location,
WHICH TYPE IS: SDO_GEOMETRY;;;;;;;;;;;;;;Hi Guys,
Dont forget to close your stmt and connection after execution
Use this as a template if you like:
try{
/**make connection**/
ServerConnection sc = new ServerConnection();
Statement stmt = sc.conn.createStatement();
/**create statement & execute**/
String insertstmt = "insert into .......";
//execute
stmt.execute(insertstmt);
/**Close and catch exception**/
stmt.close();
sc.conn.close();
catch(SQLException sqlE){
sqlE.printStackTrace();
System.out.println(sqlE.getMessage());
As for the string "insertstmt" itself, this is where your standard SQL statement goes
So get it working using a standard SQL editor first, then copy and paste it in to this string variable. The string should be a series of concatenated strings and variables to recreate the SQL atatement in Java. For example
the SQL statement:
insert into Mytable(SESSIONID, TIME1) values ('300', '4.45pm' );
assuming the values are stored in variables called 'sessionnumber' and 'time'
will become
String stmt =
"insert into Mytable(SESSIONID, TIME1) values ('"+sessionnumber+"', '"+time+"')";
Hope this helps.
E
Ps. Do a system.out.println after you create the stmt. The statement printed out to the console should be a valid SQL statement that you can use in your editor. (minus the ;)
...keep working on the string until you can do this.
Maybe you are looking for
-
Hi, I have a MAC (version 10.10.2) and installed Creative Suite one year ago. Now I want to open the Illustrator, but it does not work. It says I should install old Java SE 6-Runtime-Version to open „Adobe Illustrator CS6". Where can I find it? Thank
-
Printing problems from acrobat with recieved pdf's
Hi everybody, We have a problem with printing PDF files on windows 7 32 bit. This only happens with files that have come through one persons emails. When you open the PDF file from outlook it works fine but when you print it it crashes the print spoo
-
How to file mask in sender seeburger SFTP adapter
Hello Gurus, Please help on How to perform a file mask in sender seeburger SFTP adapter? eg. I want to pick all the files but not *.tmp files. thanks Kishore
-
Mini Player Won't Stap Open In All Spaces
How do I keep itunes mini player open in all spaaces? Checking "keep player on top of all windows" doesn't seem to do it. Haven't found another way to do this since upgrading to Lion 7.2.
-
Problem in standard workflow of claims WS18900023 in ESS
Hi Experts, Can any one explain How agent's are getting fetched for this Work flow WS18900023 ? In my case it fetch the Higher level managers .. Regards Kalyan