Skip to content

Instantly share code, notes, and snippets.

@cesandoval
Created August 8, 2012 00:59
Show Gist options
  • Save cesandoval/3291083 to your computer and use it in GitHub Desktop.
Save cesandoval/3291083 to your computer and use it in GitHub Desktop.
get geom type
import shapefile
import zipfile
import os
shpTypeDict = {
"0":"Null Shape",
"1":"Point",
"3":"Polyline",
"5":"Polygon",
"8":"MultiPoint",
"11":"PointZ",
"13":"PolylineZ",
"15":"PolygonZ",
"18":"MultiPointZ",
"21":"PointM",
"23":"PolylineM",
"25":"PolygonM",
"28":"MultiPointM",
"31":"MultiPatch"
}
data = {}
f = "C:/GISbayarea/2/2.zip"
zip_file = zipfile.ZipFile(f)
contents = zip_file.namelist()
basename = os.path.splitext(contents[0])[0]
proj_text = zip_file.open(basename).read()
print proj_text
print basename
#proj = [for i in zip_file]
#proj_text = zip_file.open( proj[0] )
shp = shapefile.Reader("C:/GISbayarea/2/parcels")
shp_type = shp.shapes()
print shpTypeDict[str(shp_type[3].shapeType)]
@cesandoval
Copy link
Author

import shapefile
import zipfile
import os

shpTypeDict = {
"0":"Null Shape",
"1":"Point",
"3":"Polyline",
"5":"Polygon",
"8":"MultiPoint",
"11":"PointZ",
"13":"PolylineZ",
"15":"PolygonZ",
"18":"MultiPointZ",
"21":"PointM",
"23":"PolylineM",
"25":"PolygonM",
"28":"MultiPointM",
"31":"MultiPatch"
}

f = "/Users/carlos/Desktop/2.zip"
zip_file = zipfile.ZipFile(f)
contents = zip_file.namelist()
basename = os.path.splitext(contents[0])[0]
extract = zip_file.extractall()

shp = shapefile.Reader(basename).shapes()
print shpTypeDict[str(shp[3].shapeType)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment