Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: insheetjson: trouble parsing json data


From   Lucas Ferreira Mation <[email protected]>
To   statalist <[email protected]>
Subject   st: insheetjson: trouble parsing json data
Date   Tue, 25 Mar 2014 17:07:37 -0300

I need to o geocode a long list of addresses (>1000k obs.). Because of
googleMaps API limits (2500 queries per day), I´m  trying to use the
API from Mapquest. I´m having trouble parsing the json data I get from
the API, to extract the (lat,lon) coordinates.
I don´t know anything about json. The code bellow shows the structure
of the data, and my attempt of an insheetjson syntax:

*mapquest:
clear
set obs 30
gen str240 Y=""
gen str240 X =""
local url http://www.mapquestapi.com/geocoding/v1/address?&key=Fmjtd|luur2l0rnl%2Cax%3Do5-9a7s06&inFormat=json&json={%22location%22:{%22street%22:%20%22RUA%20BENJAMIN%20CONSTANT%202211%22,%22city%22:%22Blumenau%22,%22state%22:%22SC%22,%22postalCode%22:%2289035-100%22}}
insheetjson using "`url'", showresponse
insheetjson Y X using  "`url'", table(results)
col("locations:latLng:lat" "locations:latLng:lng") offset(1) replace


As a comparisson, I got the equivalent code to parse the googlemaps
json data from inside the geocode3 command, which works:

*googlemaps:
clear
set obs 30
gen str240 g_lat=""
gen str240 g_lon =""
local url http://maps.googleapis.com/maps/api/geocode/json?address=RUA+BENJAMIN+CONSTANT+2211+Blumenau+89035-100&sensor=false
insheetjson using "`url'", showresponse
insheetjson g_lat g_lon using "`url'" , table("results")
col("geometry:location:lat" "geometry:location:lng") limit(1)
offset(1) replace


any suggestions on this or other suggestions to geocode from other
sources is appreciated
regards
Lucas

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index