Last active
December 20, 2015 06:28
-
-
Save dbuscombe-usgs/6085492 to your computer and use it in GitHub Desktop.
Craigslist part 2, load and plot using google-earth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addpath(genpath('~/googleearth')) | |
dat=importdata('myFile.csv'); | |
maps=dat.textdata(:,2); | |
prices=dat.data; | |
for i=1:size(maps,1) | |
address=char(maps(i,:)); | |
address=address(regexp(address,'loc')+3:end); | |
% strip address of unnneccessary stuff | |
tmp = strrep(address, '%', ' '); | |
tmp = strrep(tmp, '+', ' '); | |
tmp = strrep(tmp, '+', ' '); | |
tmp(isstrprop(tmp, 'digit'))=[]; | |
space=isspace(tmp); | |
letters=find(isletter(tmp)==1); | |
letters = letters(floor(gradient(letters))==1); | |
space(letters)=1; | |
% trim single letters but preserve location of spaces to make address | |
% readable | |
clean_address=strtrim(tmp(space)); | |
% geocode address to lat,long coordinate. Geocode generates and runs a | |
% python script to do the conversion | |
[g1,g2] = geocode(clean_address); | |
% if any empty or unconverted addresses, call them nans | |
if isempty(g1) | |
g1=NaN; g2=NaN; | |
end | |
lat(i)=g1; lon(i)=g2; | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment