def upload_shapefile_to_services(client): # Upload to incore services and put under commresilience space # It assumes the shapefile is in the utils directory datasvc = DataService(client) dataset_prop = { "title": "Joplin Population Dislocation For Heatmap Plotting", "description": "Contains only dislocated numprec for Joplin playbook plotting usage", "contributors": [], "dataType": "incore:popdislocationShp", "storedUrl": "", "format": "shapefile" } response = datasvc.create_dataset(dataset_prop) dataset_id = response['id'] files = [ 'joplin-pop-disl-numprec.shp', 'joplin-pop-disl-numprec.dbf', 'joplin-pop-disl-numprec.shx', 'joplin-pop-disl-numprec.prj' ] datasvc.add_files_to_dataset(dataset_id, files) # add to space spacesvc = SpaceService(client) spacesvc.add_dataset_to_space("5f99ba8b0ace240b22a82e00", dataset_id=dataset_id) # commresilience print(dataset_id + " successfully uploaded and move to commresilience space!")
def create_result_dataset(datasvc: DataService, parentid: str, result_files: List[str], title: str, output_metadata: Dict[str, str]): # Result metadata properties = output_metadata properties["title"] = title properties["sourceDataset"] = parentid # Create child dataset with parent dataset as sourceDataset result_dataset = datasvc.create_dataset(properties) result_dataset_id = result_dataset["id"] # Attach files to result dataset datasvc.add_files_to_dataset(result_dataset_id, result_files) return result_dataset_id
if proceed=='y': print("\n Uploading dataset to incore") print("================================") client = IncoreClient() data_services = DataService(client) space_services = SpaceService(client) dataset_metadata = { "title":"MMSA All Building Inventory", "description": "Shelby building inventory containing strctid, longitude, latitude and block id", "dataType": "ergo:buildingInventoryVer5", "format": "shapefile" } created_dataset = data_services.create_dataset(dataset_metadata) dataset_id = created_dataset['id'] print('dataset is created with id ' + dataset_id) files = [shp_loc+'.shp', shp_loc+'.shx', shp_loc+'.prj', shp_loc+'.dbf'] full_dataset = data_services.add_files_to_dataset(dataset_id, files) print("Data upload complete - dataset summary \n") print(full_dataset) print("Checking to see if it worked by loading this from remote dataset... \n") buildings = Dataset.from_data_service(dataset_id, data_services) print(buildings)