Firstly, my shapefile has an undefined projection:
library(raster)
x <- shapefile('file.shp')
Warning message:
In .local(x, ...) : .prj file is missing
crs(x)
CRS arguments: NA
I know that my coordinates needed to be in latitude/longitude or have a distance unit in meters. For now, I still went ahead and applied my area calculation:
x$area <- area(x)/1000000
But when I calculated the total area, I got a concerning result:
sum(x$area)
[1] 3236.118
The reason for my concern is that I know for a fact that my shapefile has a total area of approximately 300 km^2
I therefore decided to define a projection using a recommended espg for where my shapefile is located (espg = 2314).
crs(x) <- CRS("+init=epsg:2314")
crs(x)
CRS arguments:
+init=epsg:2314 +proj=cass +lat_0=10.44166666666667
+lon_0=-61.33333333333334 +x_0=86501.46392052001
+y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838
+towgs84=-61.702,284.488,472.052,0,0,0,0 +to_meter=0.3047972654
+no_defs
However, when I reapplied my area calculation I am getting the same result as before. What am I missing?
Edit: I'm sorry for the lack of details in the question. When I run the function print(x) I get the following properties for the shapefile (note I removed the min values and max values):
print(x)
class : SpatialPolygonsDataFrame
features : 67
extent : 66065.81, 183871.1, 74657.79, 151865.5 (xmin, xmax, ymin,
ymax)
crs : NA
variables : 16
names : ORDER, AREA, PERIMETER, TGOLOC_, TGOLOC_ID, NAME,
COMM_NAME, NO_HH, MALES, FEMALES, TOTPOP, NO_BLG, NO_DWELL, NO_BUS,
NO_INSTIT, ...
One of the attributes was indeed labelled AREA, as shown, but all values for this attribute was NA, hence the reason why I decided to try to calculate the areas myself.
print(x)
? What's the extent? That will tell us if you have coordinates in lat-long or a projected system in metres. As it is we've got nothing.