Coordinate System – How to Use tmap for Points in R

coordinate systemrsf

I'm having a problem using tmaps to map out points in R. The data is taken from the Chicago data portal, and I was able to turn it into a sf object using the code below. However, when I try to use tmaps, it just returns one point in Missouri(?). I've checked the coordinates for each point online and they are correct (or at least in Chicago), and this same problem is happening for another similar sf object I created from affordable housing projects in Chicago. I've played around with a number of different tmap options, and plot() seems to work fine.

here is the code I used:

tif_data <- read.csv("~/Documents/code/ChicagoPackage/data/TifProjects.csv")
tif_data <- tif_data[!is.na(tif_data$LATITUDE), ]
tif_sf <- st_as_sf(tif_data, coords = c("LONGITUDE", "LATITUDE"), crs = 102671)
tif_sf <- st_transform(tif_sf, crs = 4326)
tm_shape(tif_sf) + tm_dots()

Here is the website where I got the data, and below is a screenshot of where the point is.

Best Answer

The data has coordinates in both geographical and projected CRS.

  • EPSG:4326 / LONGITUDE, LATITUDE
  • ESRI:102671 EPSG:3435 / X COORDINATE, Y COORDINATE

You have chosen LONGITUDE and LATITUDE as input, then just select EPSG:4326.

Try;

tif_data <- read.csv("~/Documents/code/ChicagoPackage/data/TifProjects.csv")
tif_data <- tif_data[!is.na(tif_data$LATITUDE), ]
tif_sf <- st_as_sf(tif_data, coords = c("LONGITUDE", "LATITUDE"), crs = 4326)
tm_shape(tif_sf) + tm_dots()  

If you had a chance to zoom into "one point in Missouri(?)" it was amalgamated 500+ points, squeezed into tiny space.

[EDIT] -------- following your link ------- City of Chicago portal

The Coordinate Reference System (CRS) of the dataset, when we click on the "Export" is like below:

enter image description here

Related Question