Conversion lambert to WGS84 (Geocoding + Oracle Locator) - oracle

I'm currently tying to geocode addresses in Austria. From a given postal code and street etc. I want to automatically find latitude and longitude in WGS84 format. My first approach was to use a webservice like OpenStreetMaps Nominatim. Actually this gives decent results.
Still it is mandatory to use a disk with addresses (PAC) and their respective geolocation as a ground truth. Only if I'm not able to match the address within this data I can use the web service approach as a backup solution.
So much for context, now the problem:
On this disk the gelocation is given as X_LAMBERT and Y_LAMBERT and I can't quite figure out how to convert into latitude+longitude.
The diks's data is loaded into an Oracle 11g database with Locator and I'm doing the following:
Step 1:
Creation of spatial geometry object: MDSYS.SDO_GEOMETRY(2003,31287,NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1), MDSYS.SDO_ORDINATE_ARRAY(X_LAMBERT,Y_LAMBERT))
Step 2: Projection from WGS84 to LatLng:
SDO_CS.TRANSFORM( GEOMETRY, 4326) in my Java client I obtain latitude, longitude from the geometry via oracle.spatial.geometry.JGeometry.
Note:
I suspect 31287 to be SRID of the lambert format, I tried 8307 and 3416, but latter give even worse results.Step 2 works fine with other geometry objects, where I know the correct SRID for sure... so I guess the error is somewhere in Step 1.
Do I have to set something in USER_SDO_GEOM_METADATA ? Wrong usage of SDO_GEOMETRY constructor ? Am I still mixing up datum and projection? Maybe you can enlighten me there aswell...
The result of my action and example for input are:
Input: X_LAMBERT 602823, Y_LAMBERT 464397
Resulting Output: WGS84 (48.0469757028535, 16.0542604612583)
Expected Output: WGS84 (48.546363, 16.085735)
Its like almost correct, but still some 100 kilometers off ;-)

Related

Figuring out coordinate format contained in SDO_ORDINATE_ARRAY attribute

I am working with some data which specifies an installation path, in another data source I have the location of events based on their lat/long location.
The installation location contained in the oracle attribute SDO_ORDINATE_ARRAY does not match any X/Y geographic coordinate system I am familiar with (Lat/Long or UTM). Is there a way to figure out what the data type is that is stored in the SDO_ORDINATE_ARRAY?
Here is an example of the data for a path with 3 (x,y) points:
MDSYS.SDO_GEOMETRY(2002,1026911,NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),
MDSYS.SDO_ORDINATE_ARRAY(
1352633.64991299994289875030517578125,
12347411.6615570001304149627685546875,
1352638.02988700009882450103759765625,
12347479.02890899963676929473876953125,
1352904.06293900008313357830047607421875,
12347470.76137300021946430206298828125,
))
The above should be roughly within the proximity to 33.9845° N, 117.5159° W, and I went through various conversions but could not find anything that led me anywhere close to the above.
I read through the documentation on SDO_GEOMETRY from the oracle page and did not find any help in figuring out what the data type is.
https://docs.oracle.com/database/121/SPATL/sdo_geometry-object-type.htm#SPATL494
Alternatively, if there is a way I can type in the lat/long somewhere to see all of the different coordinate types which are equivalent, I might also be able to figure out which format this is.
Looks like there is a typo inside MDSYS.SDO_GEOMETRY(2002,1026911,NULL,
1026911 is supposed to be a SRS - Spatial Reference System.
If we remove the first 1 we have 102691, and that is a very well known SRS code.
ESRI:102691 for NAD 1983 for StatePlane Minnesota North FIPS 2201 Feet
The corresponding WKT gives you all the necessary information to perform any coordinate conversion:
PROJCS["NAD_1983_StatePlane_Minnesota_North_FIPS_2201_Feet",
GEOGCS["GCS_North_American_1983",
DATUM["North_American_Datum_1983",
SPHEROID["GRS_1980",6378137,298.257222101]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["False_Easting",2624666.666666666],
PARAMETER["False_Northing",328083.3333333333],
PARAMETER["Central_Meridian",-93.09999999999999],
PARAMETER["Standard_Parallel_1",47.03333333333333],
PARAMETER["Standard_Parallel_2",48.63333333333333],
PARAMETER["Latitude_Of_Origin",46.5],
UNIT["Foot_US",0.30480060960121924],
AUTHORITY["EPSG","102691"]]

Units of an elasticsearch query to get distance from arbitrary point to Geopoint

I have a django project which uses elasticsearch 6.5.3 to index products in a store with locations as GeoPoints. I am trying to query this index and also calculate distance between an arbitrary point, say user's location to each oh these results.
I am using elasticsearch_dsl and my code looks something like this:
search_query = search_query.script_fields(distance={
'script':{
'inline':"doc['location'].arcDistance(params.lat, params.lon)",
'params': {
'lat':user_loc.lat,
'lon':user_loc.lon
}
}
})
for result in search_query.execute():
print(result.distance)
Which gives me values that looks like:
[123456.456879123]
But I'm not sure about its units.
By using and online distance calculator in https://www.nhc.noaa.gov/gccalc.shtml,
which gives me the distance as ~123km,
It looks like value is in meters.
So:
1. Where can I find some definitive answers about its units?
Please point me to the relevant documentation for these methods.
I am also interested to know if there is a way to specify the units expected for the results in the method call.
2. Is there a better way to do this in python?
The units are those returned by the arcDistance method providing the value in your script.
The arc distance (in meters) of this geo point field from the provided lat/lon
The painless docs leave a lot to be desired (there appears to be no docs on this method in 6.5). The quote above was obtained from here: https://www.elastic.co/guide/en/elasticsearch/reference/2.3/modules-scripting.html
Additionally, they mention arcDistance caluclates meters here: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_scripting.html
I'm not sure about the exact python API, but elasticsearch have Geo Distance Query:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
In: https://github.com/elastic/elasticsearch-dsl-py/issues/398 there's an example of python usage of ES API:
MyDocType.search().filter(
'geo_distance', distance='1000m', location={"lat": "40", "lon": "-74"}
)
The 'geo_distance' query is the easiest way to get a distance between two geo points indexed to elasticsearch. I thinking that you don't need to use scripting in order to achieve that.
Regarding the distance unit, as you suspected the default is meters. from:
https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#distance-units
Wherever distances need to be specified, such as the distance parameter in the Geo Distance Query), the default unit if none is specified is the meter.

Projection of a SpatialPixelsDataFrame objects

I have created SpatialPixelsDataFrame objects from Raster files. But I cannot work it along with my SpatialPintsDataFrame object. I got this error message:
Error in count.points(GPSLocs, Grass) : different proj4string in w and xy
which means the SpatialPixelsDataFrame objects do not have a projection defined.
GPSLocs= SpatialPointsDataFrame object
Grass= SpatialPixelsDataFrame object
Any suggestions of how to fix this issue?
The message "different proj4string in w and xy" suggest that the coordinate reference systems are different (it may be that one of them is undefined). For others to be able to help you, should always show some code or data. For example what you get when you do:
library(raster)
w
xy
# or
crs(w)
crs(xy)

Google driving API returns no results for valid geo coordinates

I am trying to geo-route 2 Australian (victorian) addresses, if I use the string version of the address I get the results I am expecting, however if I use geo coordinates I get no results.
The url i generated is this...
http://maps.googleapis.com/maps/api/directions/json?origin=145.159293,-37.810449&destination=144.970388,-37.799827&mode=driving
The structure appears correct to me, as this Url with UK addresess in the same structure does return results.
http://maps.googleapis.com/maps/api/directions/json?origin=53.21742417,-2.603484875&destination=53.0,-2.603484875&mode=driving
Edit:
Note the geo codes that are not returning results are equivalent to the following string based address which is returning results...
http://maps.googleapis.com/maps/api/directions/json?origin=2%20heatherlea%20court%2C%20blackburn%20north%2C%20vic%2C%203130&destination=29%20Rathdown%20street%2C%20carlton%2C%20vic&mode=driving
OK, dammit.
I Have the lattitude and longitude around the wrong way.

How to get the 'current observation data' from the NDFD (NOAA, NWS) REST service?

I'm trying to use the NDFD (National Digital Forecast Database) to get current temperature and relative humidity given a Lat and Long using their REST based service.
The issue at hand:
I can't match the 'current observation data' WITH the 'results' I get back from the REST-service.
The setup:
Location:
* Apple (1-infinite loop, Cupertino, California)
* Lat = 37.33; Lon = -122.03
If I issue the following REST-call:
http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?lat=37.33&lon=-122.03&product=time-series&begin=2009-06-21T17:12:35&end=2009-06-21T17:12:35&appt=appt&rh=rh&temp_r=temp_r&temp=temp
Note 1: I'm passing the begin and end time in UTC. They're the same because I'm
looking for just a single-point-in-time: the latest observed
temp and relative humidity.
AND, then compare it to what is the closet reporting stations (San Jose International Airport, CA - KSJC - 37.37N 121.93W) # http://www.weather.gov/xml/current_obs/KSJC.xml
** I can never get them to MATCH. **
Note 2: The nearest reporting station is return back from the REST call
as well, so I know I'm comparing Location apples to Location apples.
I've had two ideas:
1: I'm doing something wrong with how I'm passing in the begin/end times into the REST call...
2: You can't get 'current observed data' the way I'm trying to...
Lastly:
I've found a solution using outoftime's NOAA ruby lib , [it parses an observation stations YAML file to find the nearest one given Lat/Lng then goes directly to that station via its identifier i.e. http://www.weather.gov/xml/current_obs/KSJC.xml].... but it just feels like I may be missing something obvious here and would like to use the REST-based interface ;)
Any help or pointers would be appreciated!
Thanks!
It looks like the service you are calling isn't for current data. Judging by the URL and the XML results it seems to be for forecasts. You can also put in future dates to get future forecast data. It expects the dates to be in the -0700 time zone according to the response. I'm not sure which service you should be calling to get the data you want though.
I know that this is an old question, but this is what I'm using to get current weather conditions: http://forecast.weather.gov/MapClick.php?lat=43.09110&lon=-79.0162&unit=0&lg=english&FcstType=dwml
Found this api/link yesterday. Its still developmental (operation-mode="developmental"):
http://forecast.weather.gov/MapClick.php?lat=37.33&lon=-122.03&FcstType=dwml
If you want the "current" observation, you use the XML here:
http://w1.weather.gov/xml/current_obs/seek.php?state=or&Find=Find
e.g.,:
http://w1.weather.gov/xml/current_obs/KAST.xml
If you click on the link you'll get a rendered page. However, if you pull from it using normal rest methods or just wget, it delivers an xml file.

Resources