Get Geospatial Geometry Coords for City & State or Zipcode - geolocation

Does anyone know if there is somewhere on the internet that i can enter City & State or Zipcode so that i can get the Spatial Geometry Coords for that city and state.
Reason i need this is that i get several files that are imported to our site with City Names abbreviated. So i will have to make the abbreviated citys in the database manually but give the right coord information to our maps and distance calculations.
Here is an example of our database... Below it is Examples of city names that are abreviated.
ID CORDS CITY STATE ZIP CREATED UPDATED CS
69629;"0101000020E61000004A24D1CB28A055C097FDBAD39DCD4040";"moody";"al";"35004";"2012-05-31 11:00:34.133281";"2012-05-31 11:00:34.133281";"moody, al"
69630;"0101000020E610000016139B8F6BBD55C0D28C45D3D9CB4040";"adamsville";"al";"35005";"2012-05-31 11:00:34.187562";"2012-05-31 11:00:34.187562";"adamsville, al"
69631;"0101000020E610000093C6681D55CF55C09B92ACC3D1B94040";"adger";"al";"35006";"2012-05-31 11:00:34.1948";"2012-05-31 11:00:34.1948";"adger, al"
69632;"0101000020E6100000AF7C96E7C1B355C07A6F0C01C09D4040";"alabaster";"al";"35007";"2012-05-31 11:00:34.203153";"2012-05-31 11:00:34.203153";"alabaster, al"
69633;"0101000020E6100000EFE192E34E7B55C07714E7A8A3734040";"alexander city";"al";"35010";"2012-05-31 11:00:34.211388";"2012-05-31 11:00:34.211388";"alexander city, al"
69634;"0101000020E6100000E09C11A5BD9155C09357E71890AD4040";"alpine";"al";"35014";"2012-05-31 11:00:34.219605";"2012-05-31 11:00:34.219605";"alpine, al"
69635;"0101000020E6100000DD0720B5899F55C0C11C3D7E6F294140";"arab";"al";"35016";"2012-05-31 11:00:34.228182";"2012-05-31 11:00:34.228182";"arab, al"
69636;"0101000020E6100000CA54C1A8A4A855C0CC6262F371254140";"baileyton";"al";"35019";"2012-05-31 11:00:34.23646";"2012-05-31 11:00:34.23646";"baileyton, al"
69637;"0101000020E610000097C5C4E6E3BC55C09ACC785BE9B34040";"bessemer";"al";"35020";"2012-05-31 11:00:34.244822";"2012-05-31 11:00:34.244822";"bessemer, al"
Examples of what was searched that didnt show up in our database
"FT SASKATCHEWN, AB"
"Gulfport, MD"
"La Costa Apts, CA"
"Mccarley, NV"
"W Union, SC"
"SUNNY ISLES BEACH, FL"
"Middleton Nh, NH"
"ST ANTONIN, QC"
"ft leonard wood, MO"
"Russellville, OK"
"Pleasant Prairie, PA"
"Chickalah, AR"
"MONTGOMERY COUNTY AREA, PA"
"VERSA COLD, GA"
"Rock Glen, SK"
"Pine Groven Holland, PA"
"Bethelneffs, PA"
"La Folette, TN"
"TRACY, CH"
"Magnolia, MA"
"MONT LAURIER, QC"
"CHATEAUGAY, QC"
"Puebla, MX"
"LaFollette, TN"
"ft hunter ligget, CA"
"ST GENEVIEVE, MO"

Related

Why would this array element return nil when there is data in it? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am parsing rows in a CSV, and this is an example of how each row object looks:
pry(Program)> row
=> #<CSV::Row "Broadcast Name":"2020 FC Cincinnati vs Toronto FC | MLS" "Description":"Major League Soccer is a men's professional soccer league sanctioned by the United States Soccer Federation which represents the sport's highest level in the United States. The league comprises 26 teams—23 in the U.S. and 3 in Canada and constitutes one of the major professional sports leagues in both countries." "Category":"Sports,Soccer" "Sizzle Reel":"https://youtu.be/fM5aHIVBTIc" "Thumbnail Image":"Screen Shot 2020-01-14 at 5.27.31 PM.png (https://dl.airtable.com/.attachments/7d9273fef3fc1cf1a44c4f2c4db395e7/05f3cd4a/ScreenShot2020-01-14at5.27.31PM.png)" "Header Image":"Screen Shot 2020-01-14 at 5.27.31 PM.png (https://dl.airtable.com/.attachments/7d9273fef3fc1cf1a44c4f2c4db395e7/05f3cd4a/ScreenShot2020-01-14at5.27.31PM.png)" "Source":"Flosports" "Date":"3/21/2020" "Marketing":"https://www.mlssoccer.com/" "Total Available Impressions":"10.0MM" "Programming Type":"Live - VOD" "Demo":"P18-49" "Recommended":"YES" "Featured":"YES" nil:"10000000">
However, whenever I try to access the first element by the key name it returns nil:
> row["Broadcast Name"]
=> nil
When I try to access it via the Index in the array it returns the right result:
row[0]
=> "2020 FC Cincinnati vs Toronto FC | MLS"
When I access any other element by the key name it works:
> row["Description"]
=> "Major League Soccer is a men's professional soccer league sanctioned by the United States Soccer Federation which represents the sport's highest level in the United States. The league comprises 26 teams—23 in the U.S. and 3 in Canada and constitutes one of the major professional sports leagues in both countries."
[18] pry(Program)> row["Category"]
=> "Sports,Soccer"
[19] pry(Program)> row["Sizzle Reel"]
=> "https://youtu.be/fM5aHIVBTIc"
When I convert it to a hash it seems fine:
> row.to_h
=> {"Broadcast Name"=>"2020 FC Cincinnati vs Toronto FC | MLS",
"Description"=>
"Major League Soccer is a men's professional soccer league sanctioned by the United States Soccer Federation which represents the sport's highest level in the United States. The league comprises 26 teams—23 in the U.S. and 3 in Canada and constitutes one of the major professional sports leagues in both countries.",
"Category"=>"Sports,Soccer",
"Sizzle Reel"=>"https://youtu.be/fM5aHIVBTIc",
"Thumbnail Image"=>"Screen Shot 2020-01-14 at 5.27.31 PM.png (https://dl.airtable.com/.attachments/7d9273fef3fc1cf1a44c4f2c4db395e7/05f3cd4a/ScreenShot2020-01-14at5.27.31PM.png)",
"Header Image"=>"Screen Shot 2020-01-14 at 5.27.31 PM.png (https://dl.airtable.com/.attachments/7d9273fef3fc1cf1a44c4f2c4db395e7/05f3cd4a/ScreenShot2020-01-14at5.27.31PM.png)",
"Source"=>"Flosports",
"Date"=>"3/21/2020",
"Marketing"=>"https://www.mlssoccer.com/",
"Total Available Impressions"=>"10.0MM",
"Programming Type"=>"Live - VOD",
"Demo"=>"P18-49",
"Recommended"=>"YES",
"Featured"=>"YES",
nil=>"10000000"}
But the same issue appears:
[22] pry(Program)> row.to_h["Broadcast Name"]
=> nil
[23] pry(Program)> row.to_h["Category"]
=> "Sports,Soccer"
[24] pry(Program)> row.to_h["Sizzle Reel"]
=> "https://youtu.be/fM5aHIVBTIc"
The crazy thing is that when I do a list of all the keys, it shows up all of the keys correctly:
[21] pry(Program)> row.to_h.keys
=> ["Broadcast Name",
"Description",
"Category",
"Sizzle Reel",
"Thumbnail Image",
"Header Image",
"Source",
"Date",
"Marketing",
"Total Available Impressions",
"Programming Type",
"Demo",
"Recommended",
"Featured",
nil]
So what could be causing row["Broadcast Name"] to fail so consistently regardless of what I do?
It doesn't match because your key / header starts with an invisible character:
row.headers[0].codepoints
#=> [65279, 66, 114, 111, 97, 100, 99, 97, 115, 116, 32, 78, 97, 109, 101]
# ^^^^^
That's U+FEFF, or "ZERO WIDTH NO-BREAK SPACE" which is used as a byte order mark.
To fix the problem, strip the BOM. See How to avoid tripping over UTF-8 BOM when reading files.

Neo4j - To compare two nodes properties with apoc.text.phonetic

Within a Graph of Persons some of the nodes are connected with a SAME_AS relationship.
(p1:{name:'m.Verena von Habsburg-Laufenburg'})-[SAME_AS]-(p1:{name:'2m: 9.2.1354 Verena von Habsburg-Laufenburg'})
In the first example these persons are really the same but we have other example as:
(p1:{name:'m.Gf Antal Pejácsevich de Verõcze (+1838)'})-[SAME_AS]-(p2: {name:'2m: Budapest 5.7.1880 Gf Arthur Pejácsevich de Verõcze'})
Is there a chance to find a decision with apoc.text.phonetic ?
You can judge by yourself.
Your first example
WITH [
"m.Verena von Habsburg-Laufenburg",
"2m: 9.2.1354 Verena von Habsburg-Laufenburg"
] AS texts
UNWIND texts AS text
CALL apoc.text.phonetic(text) YIELD value
RETURN text, value
Results are the same :
text value
"m.Verena von Habsburg-Laufenburg" "M000V650V500H121L151"
"2m: 9.2.1354 Verena von Habsburg-Laufenburg" "M000V650V500H121L151"
Your second example
WITH [
"m.Gf Antal Pejácsevich de Verõcze (+1838)",
"2m: Budapest 5.7.1880 Gf Arthur Pejácsevich de Verõcze"
] AS texts
UNWIND texts AS text
CALL apoc.text.phonetic(text) YIELD value
RETURN text, value
Results are not the same :
text value
"m.Gf Antal Pejácsevich de Verõcze (+1838)" "M000G100A534P200C120D000V600C000"
"2m: Budapest 5.7.1880 Gf Arthur Pejácsevich de Verõcze" "M000B312G100A636P200C120D000V600C000"
Conclusion
It works for this example, but I'm not sure you can put it as a generic rule. Data lineage is complexe to achieve and you don't have any guaranty to be sure at 100%.
But definitively, apoc.text.phonetic can helps you to achieve your goal.
Update
Your query should be like this :
MATCH (n1:Person)-[r:SAME_AS]->(n2:Person)
CALL apoc.text.phonetic(n1.name) YIELD value AS n1Phonetic
CALL apoc.text.phonetic(n2.name) YIELD value AS n2Phonetic
WHERE n1Phonetic = n2Phonetic
WITH r
SET r.samePhonetic=true
Here I set the property samePhonetic to true if the phonetics are the same.
Moreover, there is an other procedure called apoc.text.phoneticDelta that can helps you to do this. With it you can defined a threshold, or directly store the delta as a property of your relationship like that :
MATCH (n1:Person)-[r:SAME_AS]->(n2:Person)
CALL apoc.text.phoneticDelta(n1.name, n2.name) YIELD delta
WITH r, delta
SET r.phoneticDelta=delta
A score of 4 means that your two strings are very similar.
A score of 0 means that your two strings are very different.

Rails Form Field for Selecting a State

I'm creating a Payment Form where users have to enter their state
In my users model, I have a state attribute
I have a states array as follows
states = %w(AL AK AZ AR CA CO CT DC DE FL GA HI ID IL IN IA KS KY LA ME MA MI MN MO MS
MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY)
I want to create a drop-down menu where users can select a state
I read the documentation, but am confused on how to implement it.
Would something like this work?
<%= select_tag(:state, options_for_select(states)) %>
The output should look like this
AL
AK
...
WY
And you can select each of the options.
While I am not always a fan of just grabbing and installing gems, I have found the Better State Select gem to be handy in these scenarios. Mostly because I can't be bothered to keep arrays of states in multiple apps :)!
Better State Select
I ran your code just fine in one of my apps so I can't see an issue with what you have but wanted to offer the Better State Select gem suggestion simply because I've found it an easier way to manage things like states (and as we expand into Canadia, it already has their provinces, etc.).
Anyway, your code seems fine/workable to me as is!

Shipping and Billing Address normalization

I am currently normalizing the shipping and billing addresses on our software. So basically we have some areas where when orders are made, our system will check if the billing and shipping addresses match or not. If not then it is automatically adds to the fraud queues. The system works fine but the problem arises when users enters their address differently on shipping and billing... for example:
Shipping Address = "1209 9th Avenue Circle"
Billing Address = "1209 9th Ave. Circle"
So I used regular expression to replace Avenue to Ave on the addresses using full words so it is working in all of my test cases. I have done the similar things to following words.
'avenue' : 'ave',
'street' : 'st',
'boulevard': 'blvd',
'parkway': 'pkwy',
'highway': 'hwy',
'drive': 'dr',
'place': 'pl',
'expressway': 'expy',
'heights': 'hts',
'junction' : 'jct',
'center': 'ctr',
'circle' : 'cir',
'cove' : 'cv',
'lane' : 'ln',
'road' : 'rd',
'court' : 'ct',
'square' : 'sq',
'loop' : 'lp'
So I was wondering if I am missing any of the key words that are used in addresses or if someone could direct me to a link where I can find the list of Abbreviated words used in US addresses.
Thanks in advance.
http://pe.usps.gov/text/pub28/28apc_002.htm seems to have a pretty extensive list and is the official US Postal Services website

In the UK, how do I find an address given the GPS coordinates?

Sorry this is not a very well defined question, I am thinking about an idea for a product, so need to know what is possible...
Say I am standing at the fount door of a house, given the GSP coordinates from a smart phone, how can I find the address I am standing at?
Is GPS good enough for this?
How much does the data/service I need to use cost?
What other questions should I be asking about this?
GPS is limited to returning the latitude and longitude coordinates of your position.
To resolve these coordinates to an address, you would need to use an external data source. The act of converting a geographical coordinate to an address is often referred to as reverse geocoding.
There are some free reverse geocoding services such as that offered within the Google Maps API. However make sure you read and understand the Terms of Use before using such a service.
As an example, you can do reverse geocoding with the Google Maps API using the following HTTP request:
Simple CSV:
http://maps.google.com/maps/geo?q=40.756041,-73.986939&output=csv&sensor=false
Returns:
200,8,"601-699 7th Ave, New York, NY 10036, USA"
More Complex XML:
http://maps.google.com/maps/geo?q=40.756041,-73.986939&output=xml&sensor=false
Returns:
<kml xmlns="http://earth.google.com/kml/2.0"><Response>
<name>40.756041,-73.986939</name>
<Status>
<code>200</code>
<request>geocode</request>
</Status>
<Placemark id="p1">
<address>601-699 7th Ave, New York, NY 10036, USA</address>
<AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>US</CountryNameCode><CountryName>USA</CountryName><AdministrativeArea><AdministrativeAreaName>NY</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>New York</SubAdministrativeAreaName><Locality><LocalityName>New York</LocalityName><DependentLocality><DependentLocalityName>Manhattan</DependentLocalityName><Thoroughfare><ThoroughfareName>601-699 7th Ave</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>10036</PostalCodeNumber></PostalCode></DependentLocality></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7595131" south="40.7532178" east="-73.9835667" west="-73.9898620" />
</ExtendedData>
<Point><coordinates>-73.9869192,40.7560331,0</coordinates></Point>
</Placemark>
<Placemark id="p2">
<address>Times Sq - 42nd St Station, New York, NY 10116, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>Times Sq - 42nd St Station</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7591946" south="40.7528994" east="-73.9838014" west="-73.9900966" />
</ExtendedData>
<Point><coordinates>-73.9869490,40.7560470,0</coordinates></Point>
</Placemark>
<Placemark id="p3">
<address>Times Square - 42nd Street</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>Times Square - 42nd Street</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7591476" south="40.7528524" east="-73.9838524" west="-73.9901476" />
</ExtendedData>
<Point><coordinates>-73.9870000,40.7560000,0</coordinates></Point>
</Placemark>
<Placemark id="p4">
<address>W 42 St - 7 Av, New York, NY 10116, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>W 42 St - 7 Av</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7591446" south="40.7528494" east="-73.9839964" west="-73.9902916" />
</ExtendedData>
<Point><coordinates>-73.9871440,40.7559970,0</coordinates></Point>
</Placemark>
<Placemark id="p5">
<address>New Amsterdam Theatre, New York, NY 10036, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>US</CountryNameCode><CountryName>USA</CountryName><AdministrativeArea><AdministrativeAreaName>NY</AdministrativeAreaName><Locality><LocalityName>New York</LocalityName><PostalCode><PostalCodeNumber>10036</PostalCodeNumber></PostalCode><AddressLine>New Amsterdam Theatre</AddressLine></Locality></AdministrativeArea></Country></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7593416" south="40.7530464" east="-73.9842484" west="-73.9905436" />
</ExtendedData>
<Point><coordinates>-73.9873960,40.7561940,0</coordinates></Point>
</Placemark>
<Placemark id="p6">
<address>W 42 St - 7 Av, New York, NY 10116, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>W 42 St - 7 Av</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7594606" south="40.7531654" east="-73.9842484" west="-73.9905436" />
</ExtendedData>
<Point><coordinates>-73.9873960,40.7563130,0</coordinates></Point>
</Placemark>
<Placemark id="p7">
<address>Times Sq - 42nd St Station, New York, NY 10116, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>Times Sq - 42nd St Station</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7589406" south="40.7526454" east="-73.9832194" west="-73.9895146" />
</ExtendedData>
<Point><coordinates>-73.9863670,40.7557930,0</coordinates></Point>
</Placemark>
<Placemark id="p8">
<address>W 42 St - Broadway, New York, NY 10116, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>W 42 St - Broadway</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7588236" south="40.7525284" east="-73.9831654" west="-73.9894606" />
</ExtendedData>
<Point><coordinates>-73.9863130,40.7556760,0</coordinates></Point>
</Placemark>
<Placemark id="p9">
<address>7 Av - W 41 St, New York, NY 10116, USA</address>
<AddressDetails Accuracy="9" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><AddressLine>7 Av - W 41 St</AddressLine></AddressDetails>
<ExtendedData>
<LatLonBox north="40.7586296" south="40.7523344" east="-73.9843024" west="-73.9905976" />
</ExtendedData>
<Point><coordinates>-73.9874500,40.7554820,0</coordinates></Point>
</Placemark>
</Response></kml>
Simply change the q parameter with your latitude,longitude.
Note that the free version of the Google Maps API has a limit of 15,000 request per IP address per day. (Google Maps API FAQ)
If you are planning to heavily use Google's reverse geocoding services, you may want to consider using the Premier edition of the Google Maps API.
The Premier API automatically comes with "advanced geocoding capabilities with greater volume and speed", so the limitations of the standard API should be superseded by new quotas.
As an additional side-note, according to one unofficial source (dated April 2008), the cost for the Premier API starts at USD 10,000 per year.
You can use various free services, such as those provided by Google to reverse-geocode (the technical term) an address from some GPS coordinates. I strongly suggest having a play with their API, full documentation is available here:
http://code.google.com/apis/maps/documentation/services.html
Google's Geolocation Network Protocol might help; I think it worked for UK locations when I last tried it.
Btw, the Ordinance Survey just released their data under really loose licensing and I think they have a web service as well. You might want to give that a look.
OpenStreetMap (the free open-source map of the world created by volunteers) uses Nominatim, which seems to be very good. See
http://wiki.openstreetmap.org/wiki/Nominatim#Reverse_Geocoding_.2F_Address_lookup

Resources