Converting coordinates to congressional districts

Viewed 59

please help me with an issue.

Here is my data: https://www.dropbox.com/s/1v2bslhddb2er27/Codes.csv?dl=0

This data file includes the location (longitude and latitude) of participants in the US. I need to convert the coordinates to states and congressional districts, in order to extract the population density of the place they are living.

You know, in the US, each state has a number of congressional districts as shown here: https://www2.census.gov/geo/relfiles/cdsld16/natl/natl_landarea_cd_delim.txt)

Particularly, I just want to add two more columns to my current data file: States (e.g., 1, 2, 3...) and Districts (e.g., 1, 2, 3,...). Then I can extract the population density later.

I tried the code from here: Converting coordinates to congressional districts using DSTK's API in R

However, I got an error as below when it came to the step of using proj4string. I don't know how to fix it. I loaded all the required packages, even tried to load the package "sf" but no hope :(

proj4string(geos)<-proj4string(districts) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘proj4string’ for signature ‘"sf"’

Your help is greatly appreciated!

0 Answers
Related