Opening .lyr file via rgdal/OGR

Just an update on this question using the new GDAL OpenFileGDB Driver this is possible. As mentioned in this answer you'll first have to unzip the .lpk file which is actually a 7zip archive. With Homebrew

$ brew install p7zip

And to unzip

$ 7z x yourLayerPackage.lpk

Now that you have the uncompressed .gdb file you can use install GDAL/OGR to convert the desired feature class to a shapefile. With Homebrew install GDAL using the enable-unsupported option

$ brew install gdal --enable-unsupported

And to convert to shapefile

$ ogr2ogr -f "ESRI Shapefile" yourShapefileName yourFileGeodatabase.gdb yourFeatureClassName

I was looking to do something similar this is how I was able to accomplish it within R:

  1. Download .lpk file (Link to Zip code file I used)

  2. Download and install 7zip

  3. Unzip to chosen directory

  4. In the directory that I unzipped, there was a V10 subfolder that contained a zip_poly.gdb subfolder (C:\Users\Me\Desktop\v10\zip_poly.gdb)

  5. Then I used the rgdal R library with the following commands

     # install.packages("rgdal")
     library(rgdal)
    
     # Import US zipcode data
     USZips <- readOGR(dsn = "C:/Users/Me/Desktop/v10/zip_poly.gdb")
    

Tags:

R

Ogr