Converting Lat/Long to UTM or MGRS
Has anyone written a Labview application that converts from Lat/Long to UTM or MGRS
Solved!
Go to Solution.
If you know the conversions from Lat/Long, lay down the algorithm for that conversion and we can try to help you get it into LabVIEW format. If you don't know an algorithm, you can always try looking for examples at http://www.ni.com/community. Good Luck!
National Instruments
Applications Engineer
Similar Messages
-
Convert LAT/LONG to X/Y
Hello all,
i've searched this forum to see how I can convert LAT/LONG values to XY coordinates.
I've found this:
SELECT
sdo_geometry(2001, 8307, null, sdo_elem_info_array(1, 1003, 1),
sdo_ordinate_array(52.849497, 5.723975, 52.883151, 5.999025))
FROM DUAL
I thought that when i executed this query, i'd see 2 values. But i was wrong.
Is there a function that will return the XY when I give the LAT/LONG values ???You geometry does not validate (sdo_geom.validate_geometry(...) ,gtype and etype don't match!). You used a gtype 2001 (point) but in your elem_info_array (etype 1003) is an exterior polygonal ring. You need to fix your geometry first.
When you said you want to converting lat/long to X/Y did you mean to convert a lat/long to a point (x,Y) in a projected coordinate system? If so, you can convert the geodetic geometry to a projected geometry(sdo_cs.transform), then use the SDO_UTIL.GETVERTICES function to retrieve all points in their order.
From oracle spatial manual :
SDO_CS.TRANSFORM(
geom IN MDSYS.SDO_GEOMETRY,
to_srid IN NUMBER
) RETURN MDSYS.SDO_GEOMETRY;
SDO_UTIL.GETVERTICES
Format
SDO_UTIL.GETVERTICES(
geometry IN SDO_GEOMETRY
) RETURN VERTEX_SET_TYPE;
Description
Returns the coordinates of the vertices of the input geometry.
Parameters
geometry
Geometry for which to return the coordinates of the vertices.
Usage Notes
This function returns an object of VERTEX_SET_TYPE, which consists of a table of objects of VERTEX_TYPE. Oracle Spatial defines the type VERTEX_SET_TYPE as:
CREATE TYPE vertex_set_type as TABLE OF vertex_type;
Oracle Spatial defines the object type VERTEX_TYPE as:
CREATE TYPE vertex_type AS OBJECT
(x NUMBER,
y NUMBER,
z NUMBER,
w NUMBER,
id NUMBER);
This function can be useful in finding a vertex that is causing a geometry to be invalid. For example, if you have identified a geometry as invalid by using the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function or the SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT procedure (both of which are documented in Chapter 15), you can use the GETVERTICES function to view the vertices in tabular format.
Examples
The following example returns the X and Y coordinates and ID values of the vertices of the geometries in the SHAPE column of the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.)
SELECT c.mkt_id, c.name, t.X, t.Y, t.id
FROM cola_markets c,
TABLE(SDO_UTIL.GETVERTICES(c.shape)) t
ORDER BY c.mkt_id, t.id;
MKT_ID NAME X Y ID
1 cola_a 1 1 1
1 cola_a 5 7 2
2 cola_b 5 1 1
2 cola_b 8 1 2
2 cola_b 8 6 3
2 cola_b 5 7 4
2 cola_b 5 1 5
3 cola_c 3 3 1
3 cola_c 6 3 2
3 cola_c 6 5 3
3 cola_c 4 5 4
3 cola_c 3 3 5
4 cola_d 8 7 1
4 cola_d 10 9 2
4 cola_d 8 11 3
15 rows selected. -
Oracle Spatial function to find nearest line string based on lat/long
Hi,
Here is my scenario. I have a table that contains geometries of type line strings (the roadway network). The line geomteries are of type Ohio state plane south (SRID 41104).
I have a requirement - given a lat/long, find the line string that snaps to that lat/long or the nearest set of line strings within a distance of 0.02 miles.
This is a typical example of trying to identify a crash location on our roadway network. The crashes being reported to us in lat/long thru the GPS system.
How can i acheive this through any spatial functions?
Thanks for the help in advance.
thanx,
L.Hi L,
That is not the way I would do it. I would convert my road segments to LRS data, then you can do all queries on the same data.
Or, if you do not want to modify your original data, create a copy of your road segments with the same ID's and convert the copy into LRS data. If you keep the ID's identical, you can easily use geometry from one and LRS data from the other - as long as you are sure the ID is the same.
Which will make the workflow a bit easier:
1. Use SDO_NN to get the closest segments
2. Use SDO_LRS.PROJECT_PT to get the projected point
3. Use SDO_LRS.GET_MEASURE to get the measure
And most of these you can incorporate into one single query. Now I am writing this of the top of my head (It's been a while since I played with LRS). so this has not been tested, but something like this should work (but could probably be greatly improved - it's getting late for me :-) ):
SELECT
SDO_LRS.FIND_MEASURE --//find_measure needs an LRS segment and a point
SELECT --//here we select the LRS segment
r.geometry
FROM
roadsegments r
WHERE SDO_NN(r.geometry, --//based on the given GPS point
sdo_geometry(2001, 41104, sdo_point_type(lat,lon,NULL), NULL, NULL),
'sdo_num_res=2 distance=0.02 unit=mile') = 'TRUE'
SDO_LRS.PROJECT_PT --//We project the point on the LRS segment
SELECT --//here we select the LRS segment (again, which could probably be improved!!)
r.geometry
FROM
roadsegments r
WHERE SDO_NN(r.geometry,
sdo_geometry(2001, 41104, sdo_point_type(lat,lon,NULL), NULL, NULL),
'sdo_num_res=2 distance=0.02 unit=mile') = 'TRUE'
sdo_geometry(2001, 41104, sdo_point_type(lat,lon,NULL), NULL, NULL) --//The GPS point again
AS milemarker from dual;So it is not as complicated as you think, it can easily be done with just one query (SQL can do a lot more than you think ;-) ).
Good luck,
Stefan -
Accurate distance between points, lat/long to miles?
Hi,
I have a bunch of points as lat/long data in SRID 8307 format. From reading this forum, I understand than in Oracle 8.1.7 to get accurate distances I need to transform these points into a cartesian coordinate system.
My data is US-based, so I am using SRID 32775 in a command like the following:
EXECUTE SDO_CS.TRANSFORM_LAYER('restaurant_locations', 'location', 'restaurant_locations_32775', 32775);
This creates a new table with new point geometries and a rowid that I assume points back to the original 8307 table.
I've tried creating an index on the new table with cartesian coordinates, but I get this error:
CREATE INDEX restaurant_csp_idx
ON restaurant_locations_32775(geometry)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
PARAMETERS('SDO_LEVEL=9 sdo_commit_interval=1000 layer_gtype=POINT' );
2 3 4 CREATE INDEX restaurant_csp_idx
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-13200: internal error [POINT] in spatial indexing.
ORA-29400: data cartridge error
ORA-13003: the specified range for a dimension is invalid
ORA-06512: at "MDSYS.MD", line 1673
ORA-06512: at line 1
ORA-13003: the specified range for a dimension is invalid
ORA-06512: at "MDSYS.MD", line 1673
ORA-06512: at line 1
ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 8
ORA-06512: at line 1
Here's the entry for the 32775-transformed points in the metadata table:
INSERT INTO USER_SDO_GEOM_METADATA
VALUES (
'restaurant_locations_32775',
'geometry',
MDSYS.SDO_DIM_ARRAY( -- 20X20 grid, virtually zero tolerance
MDSYS.SDO_DIM_ELEMENT('X', 1951908.05, 16230214.8, 0.005),
MDSYS.SDO_DIM_ELEMENT('Y', -6858801, 13168375.5, 0.005)
32775 -- SRID (reserved for future Spatial releases)
My questions are;
Do I need to build a new spatial index? It seems like once I transform the lat/long data to cartesian I need to build a new index as well ( on the 32775-transformed table ).
Is this the best way to approach distance queries with lat/long data? It seems like a lot of work, plus the second index and table really add to the overhead if a location changes.
Any ideas on why I can't build an index on the output table from my SDO_CS.TRANSFORM_LAYER() call? I used SDO_TUNE.ESTIMATE_TILING_LEVEL() and SDO_GEOM.VALIDATE_GEOMETRY() and got no complaints. I'm at a loss.
I also can't seem to get set autotrace to work. It works fine for any non-spatial query, but if I try to trace a spatial query, I get this error:
SQL> SELECT /*+ INDEX(restaurant_locations restaurant_sp_idx) */ r_a.restaurant_id
FROM restaurant_locations r_a, restaurant_locations r_b, user_sdo_geom_metadata m
WHERE r_b.restaurant_id != r_a.restaurant_id
AND SDO_GEOM.WITHIN_DISTANCE(r_a.location, m.diminfo, 1, r_b.location, m.diminfo) = 'TRUE'
AND r_b.restaurant_id = '5999';
2 3 4 5
RESTAURANT_ID
456999
456999
Execution Plan
ERROR:
ORA-01031: insufficient privileges
SP2-0612: Error generating AUTOTRACE EXPLAIN report
Statistics
49 recursive calls
28 db block gets
83 consistent gets
0 physical reads
0 redo size
415 bytes sent via SQL*Net to client
425 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
11 sorts (memory)
0 sorts (disk)
2 rows processed
I've looked at the arraysize, and I've made sure to run the trace-enabling sql and granted plustrace to my DB user.
Thanks for any help,
_jasonHi Jason,
The error on the index create is likely due to data being outside the bounds of the coordinate system as specified in user_sdo_geom_metadata.
If the data is stored in the point field then you can check the bounds by doing queries like the following, altering them for your table/column name (my table is cities_test, the geometry column name is location):
SQL> select min(a.location.sdo_point.x) from cities_test a;
MIN(A.LOCATION.SDO_POINT.X)
-157.80423
SQL> select max(a.location.sdo_point.x) from cities_test a;
MAX(A.LOCATION.SDO_POINT.X)
-71.017892
SQL> select max(a.location.sdo_point.y) from cities_test a;
MAX(A.LOCATION.SDO_POINT.Y)
61.178368
SQL> select min(a.location.sdo_point.y) from cities_test a;
MIN(A.LOCATION.SDO_POINT.Y)
21.31725
Do you need to build a spatial index?
Only if you are going to use spatial operators such as sdo_filter, sdo_relate, sdo_within_distance, and sdo_nn. If you have no requirements for these operators, then there is no reason to build a spatial index. From the trace query at the end of the posting, I suspect that you will need to have a spatial index.
Is this the best approach? Maybe, it depends on what your requirements are. If the data is static and performance is your highest priority, then maybe it is. If you have a requirement for a spatial index, then certainly it is. If you are only getting the distance between a few few known geometries, and you don't care about the time it takes to convert data on the fly, then you can use the sdo_cs.transform function within the sdo_geom.sdo_distance function to convert both geometries to the equal area projection.
The validation routines should have caught this - I checked and they do not for 8.1.7, and they do for 9i.
Regarding the set autotrace command, I'm not sure why it isn't working for you. It works for my generic scott/tiger account from a typical install.
hope some of this is useful.
dan
null -
Need to convert a long into a string, please
hi there
i need to convert a long into a string. can i just cast it like this:
(String)longNumber = some function that returns a long;Why not just use Long.toString()? If you start with a long value, you can create a Long object and get it's value as a String.
-
Is there an easy way to convert a long string into an array?
I can convert a long string into a 1-d array by parsing and using build array, but I would like to know if there is a function to make this easier.
For example:
from/ aaaaaaaabbbbbbbbccccccccdddddddd (string of ascii)
to/ an array that is 1-d with each element having eight characters
aaaaaaaa
bbbbbbbb
cccccccc
dddddddd
Thank you.
Solved!
Go to Solution.Try something like this:
(If you can guarantee that the string length is an integer multiple of 8, you an drop the two triangular modes in the upper left. )
Message Edited by altenbach on 03-14-2010 06:40 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ChopString.png 9 KB -
How to create a polygon with the Lat/Long Coordinates
I have set of Lat/Long coordinates and I need to create a polygon geofence. Can any of you know how to do this please share your thoughts with me
I have the following coordinates
-84.3087, 39.3465; -84.3118904, 39.3306296; -84.3265158, 39.3372422; -84.2866, 39.3371; -84.2958, 39.3284; -84.2888, 39.3241
ThanksAssuming these are long/lat values, the polygon can be defined as:
sdo_geometry(2003, 8307, null, sdo_elem_info_array(1, 1003, 1),
sdo_ordinate_array(-84.3087, 39.3465, -84.3118904, 39.3306296, -84.3265158, 39.3372422, -84.2866, 39.3371,
-84.2958, 39.3284, -84.2888, 39.3241, -84.3087, 39.3465))
siva -
This is an information request from a complete coordinate systems newbie:
1. Does Oracle Spatial in 9.0.1 have an entry in MDSYS.CS_SRS that
corresponds to the coordinate system commonly known as "Earth Centered, Earth
Fixed" - where would I look (besides the table itself - I already tried that
with the 8.1.7 EE to no avail - it may be because I don't know enough about how
coordinate systems are referenced (the common nomenclature used) and just
didn't recognize it when I saw it.)
2. Are there any existing pl/sql snippets of code that can handle coordinate
conversions between ECEF-Lat/Long, geodetic degrees-decimal degrees? (If yes,
where should I go to look for them? By the way, please, please say yes, there
are many such packages just like there are for unit conversions (like binary to
hex).)
3. Where should I look to get information on a product called Map Viewer which
was mentioned in the latest edition of Oracle Magazine (May/June 2002, p.25 -
it was said to be a part of the 9iAS suite of products - I looked all over the
documentation but didn't find any mention of it.)
Thank you very much for your time and attention!
JulienThis is an information request from a complete coordinate systems newbie:
1. Does Oracle Spatial in 9.0.1 have an entry in MDSYS.CS_SRS that
corresponds to the coordinate system commonly known as "Earth Centered, Earth
Fixed" - where would I look (besides the table itself - I already tried that
with the 8.1.7 EE to no avail - it may be because I don't know enough about how
coordinate systems are referenced (the common nomenclature used) and just
didn't recognize it when I saw it.)
2. Are there any existing pl/sql snippets of code that can handle coordinate
conversions between ECEF-Lat/Long, geodetic degrees-decimal degrees? (If yes,
where should I go to look for them? By the way, please, please say yes, there
are many such packages just like there are for unit conversions (like binary to
hex).)You can get the proper params from the EPSG <http://www.epsg.org>,
I recall seeing some coord conversion samples in the tutorials/sample code - look in the OTN library
MArk -
How to create a circle object with center(lat/long) and radius(kilo)?
Hi
I want to create a circle in my table, the data I have are the coordinate of center(lat/long) and the radius of the circle. The srid of the table is lat/long.
Did I have to use some fomula to compute the coordinate of three points on the circle? If it's true, is there any example procedure you can show me?
Thanks
LannieWhen a circle is created using SDO_BUFFER in geodetic space,
the result is a circle with stroked arcs (as in arc_densify function).
So the result from SDO_BUFFER will be a valid polygon without arcs,
but approximate circle with straight lines.
For example, in the example given by Dan, this is what you get:
SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(-120, 42.09003, -120.03128, 42.086958, -120.06042, 42.0779524, -120.08543, 42.0636292, -120.1046, 42.0449675, -120.11663, 42.0232424, -120.1207, 41.9999365,
-120.11654, 41.9766391, -120.10445, 41.9549369, -120.08526, 41.9363067, -120.06028, 41.9220148, -120.0312, 41.9130321, -120, 41.9099686, -119.9688, 41.9130321,
-119.93972, 41.9220148, -119.91474, 41.9363067, -119.89555, 41.9549369, -119.88346, 41.9766391, -119.8793, 41.9999365, -119.88337, 42.0232424, -119.8954, 42.0449675, -119.91457, 42.0636292, -119.93958, 42.0779524, -119.96872, 42.086958, -120, 42.09003))
siva -
Calculating distance between Lat Long points
I'm wondering if anyone out there has done this before in LabVIEW. Does anyone have a model of the "Great Circle" calculation? I have a file of lat/long points that I need to calculate the distance between. Any help??
V/r,
ChrisI haven't done it in LV, but if you go to Wikipedia and search for Great Circle Distance you'll find the formual and an example.
-
How to get GML data in LAT/LONG format rather than LONG/LAT format
I want to generate GML from my spatial data but sdo_util.to_Gmlgeometry extracts data in LONG/LAT format where as I need it in LAT/LONG format.
Is there an easy way to extract data in LAT/LONG format otehr than parsing the gml and then switching the Lat and long.Hi,
I think it would have to do how you store your geometries, you might need a transformation before, notice the srsName from the resulting query:
SELECT TO_CHAR(SDO_UTIL.TO_GMLGEOMETRY(MDSYS.SDO_GEOMETRY(2001, 8307, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1), MDSYS.SDO_ORDINATE_ARRAY(170.5,-43.5))))
from dual
-- Result:
<gml:Point srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="." cs="," ts=" ">170.5,-43.5 </gml:coordinates></gml:Point>
So without a transformation I would say it would be hard to get:
http://trac.osgeo.org/gdal/wiki/rfc20_srs_axes
If I come across a simple solution (without some fancy manipulation of the ordinates on a custom function/package) I will post it.
Cheers -
Calculating distance between lat long coordinates best possible way?
Hi,
Am proposing to have a table A with latitude and longitude values along with some other info for that lat lon in it. The number of rows of data will be more and it will be growing day by day. i am having one application which will provide a latitude and longitude value and this i have to compare with all the lat lon of the table A and fetch the nearest (distance wise) information from other columns corresponding to that lat long in table A.
what is the best method available to implement this so as to reduce the time required to compare lat lon supplied with all rows of data in table A.
Thanks in advance.Have a look at the spatial option from oracle. Also there is a forum dedicated to this type of questions.
http://www.oracle.com/technetwork/database/options/spatial/index.html
especially: http://download.oracle.com/otndocs/products/spatial/pdf/locator11g_feature_overview.pdf
Edited by: Sven W. on Nov 30, 2010 5:53 PM -
Find driving distance between two points without using API by use of Lat & Long?
Using Google geocode API : http://maps.googleapis.com/maps/api/geocode/xml?address=thane&sensor=true
We performed get distance between search criteria entered by user and all related clubs by lat & long stored at db.
2. Two different points such as
(origin: Lat1 & Long1) and (destination: Lat2 & Long2)
We tried for to get distance between these two points,
(Lat2 & Long2) to (Lat1 & Long1)
But distance which we get by calculation is simple straight line distance
Origin Destination
(Lat1 & Long1) (Lat2 & Long2)
3. This is not driving distance as google shows in exact Km
4. For that Google provide another API (distancematrix API)
http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Thane&sensor=true&destinations=khopat&mode=driving&language=en%20-%20EN
5. But there is limit for DistanceMatrix-Service without ClientID and client key
100 elements per query.
100 elements per 10 seconds.
2 500 elements per 24 hour period.
But as element request exceeds it shows : OVER_QUERY_LIMIT error
6. In case of Client ID and Client key
In Distance Matrix 100 000 elements per 24 hour period,a maximum of 625 elements per query and a maximum of 1 000 elements per 10 seconds.
As per this one there is option to get purchase these API but basic question is remain same for us if we are requesting single origin and multiple destination then how element calculation done by google?
But in document google says :
Elements
The information about each origin-destination pairing is returned in an element entry. An element contains the following fields:
Status: See Status Codes for a list of possible status codes.
Duration: The duration of this route, expressed in seconds (the value field) and as text. The textual representation is localized according to
the query's language parameter.
Distance: The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the
unit parameter of the original request, or the origin's region.Any information that you see in a google map webpage can be retrieved using the API. The best way of finding the tags on the webpage is to manually perform the query using an IE webpage. Then capture the source and save to a file so you
can use a text editor to look at results. I often on a webpage use the menu : View - Source and then copy the source to a text file.
jdweng -
I took pictures for work. I downloaded them to iPhoto, is there anyway to add the lats/longs now? Can it be done automatically?
are you sure the lats/longs aren't there? if not, i don't know how to add them now, but you can click on the 'i' in the picture and zoom in on the map as close as possible. to get the lat/long on there beforehand you have to turn on the camera's location in the settings app. or did you accidentally post this in the iphone forum?
-
Text fields being converted to Long in Data Integrator v 11.7
I am a new user to BODI, and I recently experienced an issue with source "TEXT" fields being converted to "LONG" in the Query and Target datastores respectively. I am using Data Integrator v 11.7 and my question is does anyone know whether or not this issue has been resolved in Data Services XI 3..x? if so, can you also provide documentation on this exact issue? Thanks in advance.
LonnieYes, we did some changes in DI 12.0. But what is the problem? A SQL Server TEXT datatype is a text with unlimited length whereas a varchar(maxsize) is limited. In Oracle a CLOB is the same thing. And in DI we call a text of unlimited size a LONG datatype.
Maybe you are looking for
-
Error in report builder wizard user interface
I am getting error 'REP-31954: Error in the Report Builder Chart Wizard user interface'. The help subsystem states that I should make sure that the Chart Builder Wizard libraries are properly installed. I am sure they are because all other wizards wo
-
I received specific menu choices for Color Settings from a commercial printer I use. I went to Edit<Color Settings and saved them as a .csf file in User/Library/Applications Support/Adobe/Color/Settings. I named the .csf file after the printer. When
-
Where does Folder Redirect show up on VM?
I don't see where the redirected folders are supposed to show up on my VM? Please help. Screenshot below shows no redirected folders:
-
De-noise edit mode not saving.
My photos do not seem to be saving in their edited form. The de-noise and touch up changes appear while in the editing mode but not in the normal library while other changes do. What's up?
-
IOS 7.0.4 x iphone 4 x headphone and no speakers sound
Hi, I´ve just upgraded my iphone 4 to the new ios 7.0.4 and now it keeps thinking it has a headphone pluged in. No sound at the speakers. The volume buttons show the volume of the headphone, although it has no headphone there. It seems to be a softwa