I am trying to create a ppp object from a sf object in R.
I am using the population-weighted centroids in Minnesota from 2020 census data. You can find the data here: https://www2.census.gov/geo/docs/reference/cenpop2020/blkgrp/CenPop2020_Mean_BG27.txt
library(spatstat)
library(sp)
library(sf)
library(maptools)
library(dplyr)
# pathing
setwd("My folder location")
# read data
centroids <- read.csv("./block_group_weighted_centroids.txt")
# convert to sf object
sf_df <- centroids %>%
as.data.frame() %>%
select(LONGITUDE, LATITUDE) %>%
st_as_sf(coords=c("LONGITUDE","LATITUDE"), crs=4326) %>%
as_Spatial()
# create a ppp
sf_ppp <- as.ppp(sf_df) # This line results in an error
The error message: Error in as.ppp.SpatialPointsDataFrame(sf_df) : Only projected coordinates may be converted to spatstat class objects
How can I make sure I am using the planar projected coordinates?