您当前的方法存在两个问题。 1.) coordinates 任务不太正确。它应该是long / lat,但是你将它指定为lat / long。 2.)以当前方式直接设置CRS实际上不会以必要的方式改变点。您需要先分配一个合适的long / lat CRS,然后再执行一次 spTransform 行动。
coordinates
spTransform
#Open data on tin mines and define as spatial points tin.01 <- read.csv("random/Tin Mine Location_01.csv") coordinates(tin.01) <- c("Longitude","Latitude") ## Should be `9:8` if you wanted to stick with indexes, but using the names here is generally lower risk. proj4string(tin.01) <- CRS(proj4string(Kinta)) ## Setting the initial projection to the same one the polygons are using. You should change this if your original data source uses some other known long/lat projection. tin.km <- spTransform(tin.01,CRS(EPSG.3375)) ## Creating a transformed set of points for the distance calculation. #Find distance between district and mines gDistance(Kinta.km,tin.km,byid=TRUE) ## '0' distance means the mine is inside the district. 59 1 194384.372 2 223773.999 3 0.000 4 36649.914 5 102944.361 6 0.000 7 0.000 8 6246.066 9 0.000