I have downloaded a shapefile "NT_SurfaceWater_Area.shp" from the UK Ordnance Survey and I have loaded it into R and can plot it. But, unlike other examples of shapefile which I've seen people cite on the net it doesn't have vectors $latitude or $longitiude. It has $ID which gives a huge table of symbols whose significance I have no idea about, and $FEATCODE which is repetitions by the thousand of the same number (here 25609).

Can anyone a) explain why it doesn't have the latitude and longitude vectors and or b) what the ID and FEATCODES mean?

  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Sep 12 at 10:48
  • 2
    dataset is likely to be Eastings and Northings (British National Grid), not latitude and longitude
    – nmtoken
    Sep 12 at 11:22
  • Assuming, each feature mapped in the OS Vector map product, will have a unique identifier (ID) and be classified according to some schema of codes (FEATCODES). Assuming that 25609 is feature code for surface water
    – nmtoken
    Sep 12 at 11:45
  • What code are you using to read the shapefile into R? Please edit your question and show us. There are two possible systems you might be using: the newer sf and the old sp packages.
    – Spacedman
    Sep 12 at 11:51
  • shapefiles can contain different types of vectors. It seems that you previously used points geometry, but in this case you are opening a polygon geometry (my guess based on the "_area" mentionned. Therefor the geometry is not a single pair of latitude and longitude. So the question is: do you want the latitude/longitude of the center of your polygon or the latitude/longitude od all the vertices ?
    – radouxju
    Sep 12 at 12:17

1 Answer 1


If you have read a shapefile into R using the sf package (eg using st_read) and the data are points, then you can get the coordinates using st_coordinates to return a two-column matrix.

> head(st_coordinates(pts))
          X        Y
1 -81.49823 36.43140
2 -81.12513 36.49111
3 -80.68573 36.41252
4 -76.02719 36.40714
5 -77.41046 36.42236

These are in whatever coordinate system the points are being stored in, and if you have the .prj part of the shapefile, then R knows what this is and can transform to another coordinate system if you need it. EG to convert to the common "Web Mercator" system which has code 3857:

> head(st_coordinates(st_transform(pts, 3857)))
         X       Y
1 -9072322 4360161
2 -9030787 4368427
3 -8981871 4357552
4 -8463269 4356810

If you are using the sp or rgdal package to read the shapefile then my advice is use sf instead.

  • Thanks I have managed to download the co-ordinates by the route you've suggested. There's five columns x,y,z L1 and L2 IZ's are all zeroes and I assume that the L1 and L2 are layers? The points are in Projected CRS: OSGB 1936 / British National Grid I'm not expert enough to know whether this is the right projection to tie in with my other data, which is osg eastings and northings of streamflow gauging stations through the "rnrfa" package. I have the .prj file (same name as the .shp file but it won't open with st_read()...
    – Nick Wray
    Sep 12 at 12:31
  • You need to read a basic intro to geospatial in R. geocompr.robinlovelace.net is the best I know. You should also edit your Q with your updated knowledge rather than comments.
    – Spacedman
    Sep 12 at 12:54
  • Already working through Lovelace thanks
    – Nick Wray
    Sep 12 at 13:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.