新しい「sf」パッケージを使用して、R でブラジルの国勢調査データを操作しようとしています。データをインポートできますが、元のポリゴンの重心を作成しようとするとエラーが発生します
library(sf)
#Donwload data
filepath <- 'ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_de_setores_censitarios__divisoes_intramunicipais/censo_2010/setores_censitarios_shp/ac/ac_setores_censitarios.zip'
download.file(filepath,'ac_setores_censitarios.zip')
unzip('ac_setores_censitarios.zip')
d <- st_read('12SEE250GC_SIR.shp',stringsAsFactors = F)
ここで、列「ジオメトリ」の重心を含む新しいジオメトリ列を作成しようとしましたが、エラーが発生しました:
d$centroid <- st_centroid(d$geometry)
Warning message:
In st_centroid.sfc(d$geometry) :
st_centroid does not give correct centroids for longitude/latitude data
どうすればこれを解決できますか?