0

I have two datasets.

One is a csv file, which has a listing of Airbnb in New York. Is from that website: http://insideairbnb.com/get-the-data And NY Zipcodes from that website: https://data.cityofnewyork.us/Business/Zip-Code-Boundaries/i8iw-xf4u/data?no_mobile=true

ny <- read.csv("NY/listings.csv")
zc <-  st_read("ZIP_CODE_040114/ZIP_CODE_040114.shp")

Now I would like to find out which listings lie on which zipcodes. I did that with st_intersects, but I doens't function

nysf <- st_as_sf(ny)
nysf <- st_as_sf(nysf,'EPSG:2263')
zc <- st_transform(zc,2263)
st_intersects(nysf,zc)

But I got an error message

st_crs(x) == st_crs(y) is not TRUE

But they are both in the same crs?

1 Answer 1

1

Are they though? On a test data set, doing what you seem to be doing to set the CRS doesn't change anything:

> nysf = st_as_sf(nysf, 'epsg:2263')
> st_crs(nysf)
Coordinate Reference System: NA

If you name the argument it works:

> ny = data.frame(x=1:10, y=1:10)
> nysf = st_as_sf(ny, coords=1:2, crs="epsg:2263")
> st_crs(nysf)
Coordinate Reference System:
  User input: epsg:2263 
  wkt:

Or use st_crs(thing) = "epsg:1234" to override a current CRS or set a new one (without transforming the coordinate values, which you need st_transform to do)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.