How do I get census data of a particular zip code? - api

https://api.census.gov/data/2013/acs/acs5?get=NAME,B01001_001E&for=place:51000&in=state:36&key=key123
That is the query I attempted to use. I only get the data for New York City population, but I want the population of that zip code, and if possible query further onto the data of that zip code. I obtained the "place" using ZTCA5 to place chart they provided.
thanks.

Related

What is the industry standard way to store country / state / city in a database of web APP?

For country and state, there are ISO numbers. With City, there is not.
Method 1:
Store in one column:
[Country ISO]-[State ISO]-[City Name]
Method 2:
Store in 3 separate columns.
Also, how to handle city names if there is no unique identifier?
First and foremost, three separate columns to keep your data. If you want to create a unique identifier, the easiest way would be giving a random 3-10 digit code depending on the size of your data set. However, I would suggest concatenating [country-code]-[state-code]-[code] if you have a small data set and if you want human readability to a certain point. code can be several things. Here are some ideas:
of course a random id or even a database row id
licence plate number/code if there is for a city
phone area code of the city or the code of the center
same logic may apply to zip codes
combination of latitude and longitude of the city center up to certain degree
Here are also more references that can be used:
ISO 3166 is a country codes. In there you can find codes for states or cities depending on the country.
As mentioned IATA has both Airport and City codes list but they are hard to obtain.
UN Location list is a good mention but it can be difficult to gather the levels of differentiation, like the airport code or city code or a borough code can be on the same list, but eventually the UN/LOCODE must be unique. (Airport codes are used for ICAO, similar to IATA but not the same)
there are several data sets out there like OpenTravelData or GeoNames that can be used for start but may require digging and converting. They provide unique codes for locations. And many others can be found.
Bonus:
I would suggest checking Schema.org's City Schema and other Place Schemas for a conscious setup.

How to get the weatherbox from a wikipedia page using the API?

Most of the larger cities have a table with climate data. I think Wikipedia calls them weatherbox.
Is there a way to retrieve these tables via the API?
For instance, to get the climate section for NYC I do:
https://en.wikipedia.org/w/api.php?action=parse&prop=wikitext&pageid=645042&section=18&format=json
I get the text but not the actual table which is referred to as {{New York City weatherbox}}.
There seems to be another way to retrieve some weatherboxes but this isn't working for many cities.
This one works:
https://en.wikipedia.org/wiki/Template:New_York_City_weatherbox
but this one doesn't:
https://en.wikipedia.org/wiki/Template:Turin_weatherbox

How to fetch the country name based on latitude and longitude in codename one..?

I am trying to retrieve the country name using Lat and Long I fetched using locationmanager in codename one... How to get country, state, city, zip based on these parameters..??
You need to use a webservice that will translate location data to location meta data e.g. this one https://www.codenameone.com/blog/dynamic-autocomplete.html
Notice that the sample above uses a different feature of that webservice but the same concept applies.

Bad Address Data

I am working on a project where I get information from an outside vender in an Excel report and I need to process it through a series of transformations but the below data needs to be split out so that I can have the City and State and dump the rest of the data.
Here is an example of the bad data
[PlantName]
|ATLANTA,GA AIRPORT ONSITE|
|BETHLEHEM, PA|
|ANCHORAGE, AK No Ship HazMat|
|FOREST PARK, GA|
|HUNTINGTON,WV No Ship|
Here is an example of the clean data I need
[PlantName], [City], [State]
|ATLANTA|ATLANTA|GA|
|BETHLEHEM|BETHLEHEM|PA|
|ANCHORAGE|ANCHORAGE|AK|
|FOREST PARK|FOREST PARK|GA|
|HUNTINGTON|HUNTINGTON|WV|
I will need to have the City Name in the Plant Name so that I can use it in a naming convention, a concatenation with another field to create an actual plant name.
I want to use an SSIS expression but I am open to T-SQL if it is quicker and more reliable.
I used a series of Derived Columns to separate the Data followed up by a Derived Column with a Token Expression to pull the State Abbrev out of the final row and disregard any useless characters.

Searching by Zip Code proximity - MySql

I'm having some trouble getting a search by zip code proximity query working. I've search and searched google but everything I find is either way too slow or I can't get working. Here's the issue:
I have a database with a table with all the US Zip Codes (~70,500 of them), and I have a table of several thousand stores (~10,000+), which includes their zip code. I need to be able to provide a zip code and return a list of the closest stores to that zip code, sorted by distance.
Can anyone point me to a good resource for this that they have used and can handle this much load, or share a query they've used that works and is fairly quick about it? It would be MUCH appreciated. Thanks!
You should build a table that has each zip code with an associated latitude and longitude. When someone enters a zip and a distance, you calculate the range of latitudes and longitudes that fall within it, and then select all the zip codes that fall within that bounding box. Then you select any stores that have zip codes within that set, and calculate their distance from the provided zip and sort by it. (Use the haversine formula for calculating the distance between points on a globe)
If speed is your main concern, you might want to precompute all the distances. Have a table that contains a store zip code column, the other zip code, and a distance column. You can restrict the other zip codes to zip codes within a certain distance (say 100 miles, or what have you) if you need to cut down on rows. If you don't restrict the links based on distance, you'll have a table with > 700 million rows, but you could certainly do fast lookups.