I have a zipped shapefile saved on my disk. I want to extract it in memory and check the shape type. I'm using arcpy module and want to stick to only default modules comes with python installation. I tried something like
import cStringIO, zipfile, arcpy
stringIO = cStringIO.StringIO()
file_ = r"C:\Polyline.zip"
zipFile = zipfile.ZipFile(file_)
for name in zipFile.namelist():
if name.endswith(".shp"):
stringIO.writelines(zipFile.read(name))
print arcpy.Describe(stringIO).shapeType
But it is not working. I got the trace back:
Traceback (most recent call last):
File "", line 8, in
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy__init__.py", line 1190, in Describe
return gp.describe(value)
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing_base.py", line 374, in describe
self._gp.Describe(*gp_fixargs(args, True)))
RuntimeError: Object: Describe input value is not valid type
How can I unzip a shapefile in memory and finds its shape type?
ds=ogr.Open(r'/vsizip/C:\folder\some_zipfile.zip/some_shapefile.shp')
andprint ogr.GeometryTypeToName(ds.GetLayer().GetGeomType())