Created
August 8, 2012 18:50
-
-
Save cesandoval/3297492 to your computer and use it in GitHub Desktop.
get geom type gis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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