Skip to content

Commit

Permalink
Fixed missing neighborhoods
Browse files Browse the repository at this point in the history
Using 1-NN classifier to assign neighborhood labels
  • Loading branch information
Daniel Berry authored and Daniel Berry committed Nov 17, 2016
1 parent beb6b51 commit 4c6acc5
Show file tree
Hide file tree
Showing 6 changed files with 46,385 additions and 47,301 deletions.
11 changes: 11 additions & 0 deletions ETL.r
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ t <- over(sp_block_data, data.shape)

block_data$Neighborhood <- t$PRI_NEIGH
block_data$desert <- block_data$store_counts == 0

## fix missed point in polygon

missing <- which(is.na(block_data$Neighborhood))
t1 <- as.matrix(block_data[which(!is.na(block_data$Neighborhood)),c('Longitude','Latitude')])
for (miss_ID in missing) {
d1 <- as.matrix(block_data[miss_ID,c('Longitude', 'Latitude')])
dist_mat <- spDists(d1,t1)
block_data$Neighborhood[miss_ID] <- block_data[!is.na(block_data$Neighborhood),'Neighborhood'][which.min(dist_mat)]
}

save(block_data, file = 'block_data')
write.csv(block_data, file = 'block_data.csv')

Expand Down
Binary file modified all_data
Binary file not shown.
93,467 changes: 46,270 additions & 47,197 deletions all_data.csv

Large diffs are not rendered by default.

Binary file modified block_data
Binary file not shown.
Loading

0 comments on commit 4c6acc5

Please sign in to comment.