This seems to be a very easy problem to solve, but about two hours of searching hasn't led me to the answer.
I have a GIS file that I downloaded in WSG84 ESPG:4326. I read in the file using readOGR
.
I can't get the file to plot()
correctly.
Code:
NZAreas <- readOGR("[FILEPATH]/area-unit-2013.shp")
proj4string(NZAreas)
[1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
When I plot(NZAreas)
, I get a very small New Zealand off to the far right of an otherwise-empty plot (apart from one small polygon to the very left) - I seem to be plotting the entire world WGS84 instead of just New Zealand
Thinking it might be to do with the apparently absent EPSG code, I also tried:
NZAreas <- spTransform(NZAreas, CRS("+init=epsg:4326"))
plot(NZAreas)
This gives me the same small New Zealand on the large empty world map.
Earlier today I had this working. Then after working on some later code, and coming back to this map to plot, the plot no longer limits the area to New Zealand. I can't pinpoint what I am doing wrong. For example, this blog post gives an example of using WGS84 with Brazil data, and having the map limited to only Brazil. To my eye, which is now tired, I am using the same code and getting a different result.
Can someone please point out what I am doing wrong, and how to fix it?
Is the map plot output controlled by something other than the coordinate information in the shapefile? I don't do GIS very often, and I recall this problem bit me the last time I was working in GIS. Looking at my files from back then, I can't see how I solved the problem. But I used all different data for that work.