def UploadShapefile(service, project_id, shapefile_prefix):
 suffixes = ['shp', 'dbf', 'prj', 'shx']
 files = []
 for suffix in suffixes:
  files.append({'filename': ('%s.%s' % (shapefile_prefix, suffix))})
 metadata = {'projectId': project_id, 'name': shapefile_prefix, 'description': 'polygons that were uploaded by a script', 'files': files, 'draftAccessList': 'Map Editors', 'tags': [shapefile_prefix, 'auto_upload', 'kittens']}
 logging.info('Uploading metadata for %s', shapefile_prefix)
 response = service.tables().upload(body=metadata).execute()
 table_id = response['id']
 for suffix in suffixes:
  shapefile = ('%s.%s' % (shapefile_prefix, suffix))
  media_body = MediaFileUpload(shapefile, mimetype='application/octet-stream')
  logging.info('uploading %s', shapefile)
  response = service.tables().files().insert(id=table_id, filename=shapefile, media_body=media_body).execute()
 CheckAssetStatus(service, 'tables', table_id)
 return table_id

def UploadShapefile ( service , project_id , shapefile_prefix ) : suffixes = [ 'shp' , 'dbf' , 'prj' , 'shx' ] files = [ ] for suffix in suffixes : files . append ( { 'filename' : ( '%s.%s' % ( shapefile_prefix , suffix ) ) } ) metadata = { 'projectId' : project_id , 'name' : shapefile_prefix , 'description' : 'polygons that were uploaded by a script' , 'files' : files , 'draftAccessList' : 'Map Editors' , 'tags' : [ shapefile_prefix , 'auto_upload' , 'kittens' ] } logging . info ( 'Uploading metadata for %s' , shapefile_prefix ) response = service . tables ( ) . upload ( body = metadata ) . execute ( ) table_id = response [ 'id' ] for suffix in suffixes : shapefile = ( '%s.%s' % ( shapefile_prefix , suffix ) ) media_body = MediaFileUpload ( shapefile , mimetype = 'application/octet-stream' ) logging . info ( 'uploading %s' , shapefile ) response = service . tables ( ) . files ( ) . insert ( id = table_id , filename = shapefile , media_body = media_body ) . execute ( ) CheckAssetStatus ( service , 'tables' , table_id ) return table_id
upload a shapefile to a given project .