1

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.

1

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

  • This worked great, thanks so much! I feel like a bit of a dummy asking this follow up, but I've been reading up on the difference between graphical and projected CRS, and am not sure if I understand how to use it here — I was working off dev.cityofchicago.org/open%20data/data%20portal/2016/03/03/…. – cschwab98 Jun 8 at 15:31
  • @cschwab98 I added information about the portal, that only Original uses projected XY coordinates, while others use latlong. Isn't their explanation confusing? When I clicked on Shapefile I expected to see it on State Plane - Illinois East, but turned out it was on geographic coordinates. – Kazuhito Jun 8 at 23:29
  • this is so helpful and awesome thank you so much – cschwab98 Jun 10 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.