How to parse geo coordinates in different formats - c#

Does anyone know of a C# library that can parse geo coordinates from one string without having to specify the format upfront. The goal is to enable "google like" data entry and interpretation.
Some formats that should be supported:
"12 34.56'N 123 45.55'E"
"12°N 34°W"
"12.345°N 123.456°E"
...

I've been working on a simple geospatial library which can parse coordinate strings. It is called Geo, and is licensed under the LGPL.
The Coordinate class has a static Parse method, and a couple of static TryParse methods.

Related

How do I convert SRID 3857 to decimal degrees?

How do I convert SRID 3857 formatted geometery coordinates into to decimal degrees?
My current stack is SQL Server 2014 and C#.
You cannot convert them directly in SQL Server. Quite simply it wasn't built to reinvent the Reprojection of spatial data in one datum to another. When using SqlGeography, you can of course swap between SRIDs when both sets of coordinates use the same coordinate-type (decimal-degrees or grid-based), however when using SqlGeometry, they are simply planar coordinates based on the scale set by the bounds of the data you have and setting the SRID merely "groups" like-SRID spatial objects.
You'll need a Third-Party library or tool to do this for you. Geographika notes some options at the following SO Link:
Know of any C# spatial data libraries?
See Convert coordinate systems using SQLGeometery
SRID 4326 seems to work well enough.
http://spatialreference.org/ref/epsg/4326/

Conversion to data format for crfsharp ...

I have a a review data set of about 250000 reviews of hotels, I'm planing to extract aspects from it using crfsharp dll, however the data that I have is in normal text paragraph form and I need to convert it into the format of crfsharp so I can train and test data to extract aspects. Well can someone tell me what will be the best way to do that, I was thinking of writing a small program for data format conversion.
Another thing I was wondering whether can CRF sharp do aspect extraction using crf models it has? I'm using c#.
What's features and tags will you use in your task ?
There is a simplest example. For a sentence "! Tokyo and New York are major financial centers." If you want to extract location name from it and your only feature is token string, you can generate training corpus as belows:
! NOR
Tokyo LOCATION
and NOR
New LOCATION
York LOCATION
are NOR
major NOR
financial NOR
centers NOR
. NOR
The first column is the term of the sentence, the second column is the corresponding tags. NOR means normal term, LOCATION means location name. You can generate training corpus as above format and use CRFSharp to train a model.
For more complex example, such as more features, template, adding word position in tags, you can refer another example in CRFSharp home page(http://crfsharp.codeplex.com).

Unable to map coordinates on Google Maps

I have a list of coordinates that I want to plot on Google Maps, but I can't figure out how to do that. The coordinates, depending on how I plot them, appear to be all around the globe, while they should be placed in Trondheim, Norway. (And the application I have extracted them from successfully places them in Trondheim, so I know they are correct.)
A normal Google Maps coordinate from Trondheim looks like this:
63.4304, 10.395069
My coordinates, however, look like this:
long, lat
1154262, 9182277
1143762, 9184473
1157168, 9194133
1157375, 9200167
1164505, 9209786
I believe that these are in some kind of WGS84 format, but as I am a complete novice on this field, I am not completely sure. I think so because of the headers in the XML I have extracted them from:
<rss version="2.0"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"
xmlns:mappoint="http://virtualearth.msn.com/apis/annotate#">
When I try to use this coordinate converter, it returns coordinates in Kazakhstan. I am utterly confused. All other converters I have tried either returns locations in strange countries or in the middle of the oceans, or they fail to convert my data at all.
Does anybody here know what kind of coordinates I have, and how I can convert them to normal latitude and longitude degrees?
A formula is enough, but if there exists any libraries for this, I am using C# as development language. Any other languages would suffice, however, as I am probably able to convert them to my own anyway.
WGS-84 is Spherical Mercator, the projection system used by Google, so the coordinates you have provided are obviously not. Unfortunately for any formula to work you will need to find out the projection that your points are in.
Some more detailed information on projection is available here: http://courses.washington.edu/gis250/lessons/projection/
And a library to convert between common coordinate systems in .net is available at: http://www.doogal.co.uk/dotnetcoords.php.
Would it be possible for you to open the map layer in an GIS program such as: http://www.qgis.org/en/site/ and use the options available to determine the projection of the layer?
Some tips for identifying the coordinate system (written for ARCGIS but the programs are similar): http://resources.arcgis.com/en/help/main/10.1/index.html#//003r00000004000000 https://gis.stackexchange.com/questions/7839/best-practices-for-identifying-the-unknown-coordinate-system-of-a-shapefile

Convert UTM to decimal degrees with Esri's ArcGis with C#

I need to convert a user's UTM input (WGS 1984) into Decimal Degrees, preferably using ESRI's ArcGis. I've already got the code to retrieve the zone (formatted like 14N, 22S, etc.) and the easting and northing factors. What do I do from here?
Edit: we expect the input as a string like: 14N 423113mE 4192417mN. I can easily extract the numbers (and a character) 14, N, 423113, and 4192417 from the string above. I just need to somehow translate that to Decimal Degrees.
There is no specific information about input data.
Here is some general info to start from:
The easiest way is to use Geoprocessing engine to reproject the whole feature class. Use C# class for Project tool from Data Management toolbox.
Another way is to use Project method of IGeometry is you want project only several features.
EDIT: for your input data use solution 2.
One more easier way is to use .NET port of open-source library Proj.4 - Proj4Net. For such simple task it is much more easier to use than ArcObjects classes.

Format Financial Data like "2,000" as "2M" using a custom Format String with C# .NET WinForms and WPF Applications

We'd like to know if there is a way to format financial data such as "2,000" and "2,000,000" as "2M" and "2MM" respectively - essentially replacing the 1000's with M's.
Ideally there would be a format string we could use, such that 2000.0.ToString("X") would give us "2M" back and vice versa. Does such a formatstring exist? If not - is it possible to create one?
Note that these format strings work:
#,#,M – this will convert 2,000 to 2M (and back)
#,#,,MM – this will convert 2,000,00 to 2MM (and back)
#,#,,,B – this will convert 2,000,000,000 to 2B (and back)
However we need something more dynamic - something that can detect if it's any of these values and can apply the appropriate format string, if possible.
I don't know of a format to achieve what you want. You can, however, implement your own with the interfaces IFormatProvider and ICustomFormatter and pass this into the Format() and ToString() calls.

Categories

Resources