0

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.

  • 4
    Because your data is straddling the antimeridian and you are using a projection that is split at the antimeridian – Ian Turton Feb 18 at 11:27
  • 1
    Could it be as easy as adding in xlim=c() and ylim=c() values in plot()? – MortenSickel Feb 18 at 11:30
  • 1
    Thank you, I downloaded the NZ projection (NZGD2000 / New Zealand Transverse Mercator 2000) and it is working perfectly now. – Michelle Feb 18 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.