2

According to this answer I can read in a .lyr file via OGR as long as it was made with ArcGIS version 10.

I have such a file (from the ArcGIS Maps & Data page) but I can't quite make R's readOGR function work with it.

Directory contents after decompressing the .lpk file:

[1] "ESRI_Zip_Codes_Dec2011.lpk" "iteminfo.xml" "item.pkinfo" "thumbnail.png" [5] "USA_Zip_Codes.lyr" "zip_poly.prj" "zip_poly.sdc" "zip_poly.sdc.prj" [9] "zip_poly.sdc.xml" "zip_poly.sdi"

And then trying to open the various components:

ogrInfo( dsn=mypath, layer="zip_poly" )

Error in ogrInfo(dsn = file.path(shapedir, "zipcodes", "ESRI_Zipcodes"), : Cannot open file

ogrInfo( dsn=mypath, layer="USA_Zip_Codes" )

Error in ogrInfo(dsn = file.path(shapedir, "zipcodes", "ESRI_Zipcodes"), : Cannot open file

How do I open these things? I would normally take the easy way out and convert to Shapefile it via ArcGIS, but my annual license expired and my new one hasn't arrived yet.

3

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
2

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 rdal r library with the following commands

    require(rdal)
    
    # Import US zipcode data
    USZips <- readOGR(dsn = "C:/Users/Me/Desktop/v10/zip_poly.gdb")
    
1

Unfortunately there is no way to convert an LPK file (packaged with a file geodatabase inside) to a shapefile or file geodatabase using open source software. If you rename the LPK to ZIP, you can open the zip archive and see a large SDC file. This is basically the file geodatabase in ESRI's proprietary 'Spatial Data Compression' format.

OGR can work with a file geodatabase but is unable to work with an LPK or an SDC file.

Perhaps you could get to the data if the LPK file was created from one or more shapefiles.

  • Ok, I guess I'll have to trek over to the GIS lab and do it on one of their copies of Arc then. Thanks for the clarification. – Ari B. Friedman Sep 27 '12 at 12:54

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.