Skip to content

Instantly share code, notes, and snippets.

@cesandoval
Created August 8, 2012 18:50
Show Gist options
  • Save cesandoval/3297492 to your computer and use it in GitHub Desktop.
Save cesandoval/3297492 to your computer and use it in GitHub Desktop.
get geom type gis
import shapefile
import zipfile
import os
def get_geometry_type(zip_file):
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"
}
zip_file = zipfile.ZipFile(zip_file)
contents = zip_file.namelist()
basename = os.path.splitext(contents[0])[0]
extract = zip_file.extractall()
shp = shapefile.Reader(basename).shapes()
geometry_type = shpTypeDict[str(shp[3].shapeType)]
print geometry_type
f = "C:/GISbayarea/2/2.zip"
get_geometry_type(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment