gdal - Obtaining Latitude and Longitude with from Spatial objects in R -


i want obtain latitude , longitude shapefile. until now, know how read shapefile.

library(rgdal) centroids.mp <- readogr(".","35dse250gc_sir") 

but how can extract latitude , longitude centroids.mp?

there's few levels question.

you ask longitude , latitude, may not coordinate system used object. can coordinates this

   coordinates(centroids.mp) 

note "centroids" of coordinates if spatialpointsdataframe, list of line coordinates if spatiallinesdataframe, , centroids if spatialpolygonsdataframe.

the coordinates may longitude , latitude, object may not know that. use

   proj4string(centroids.mp)  

if "na", object not know (a). if includes "+proj=longlat", object know , longitude/latitude (b). if includes "+proj=" , other name (not "longlat") object know , it's not longitude/latitude (c).

if (a) you'll have find out, or might obvious values.

if (b) done (though should check assumptions first, these metadata can incorrect).

if (c) can (pretty reliably though should check assumptions first) transform longitude latitude (on datum wgs84) this:

 coordinates(sptransform(centroids.mp, crs("+proj=longlat +datum=wgs84"))) 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -