Workspace to RasterDataset doesn't work?

12-01-2017 12:38 AM
Occasional Contributor III


if I use the following python script to create a fgdb with a raster dataset this works, but the raster dataset remains empty. So the command arcpy.WorkspaceToRasterDataset_management doesn't do anything. There's no error message.

import arcpy
from arcpy import env

arcpy.env.overwriteOutput = True

# Local variables:
RasterCatalog_gdb = arcpy.GetParameterAsText(0) # FileGDB
PfadFGDB = arcpy.GetParameterAsText(1) # Pfad FGDB
Dataset = arcpy.GetParameterAsText(2)# Raster Catalog
PfadWorkspace = arcpy.GetParameterAsText(3) # Workspace mit Bildern

RasterGdb = PfadFGDB + "/" + RasterCatalog_gdb + ".gdb"

DatasetPfad = PfadFGDB + "/" + RasterCatalog_gdb + ".gdb" + "/" + Dataset


    # Process: File-Geodatabase erstellen
    arcpy.CreateFileGDB_management(PfadFGDB, RasterCatalog_gdb, "CURRENT")

    # Process: Raster-Dataset erstellen
    arcpy.CreateRasterDataset_management(RasterGdb, Dataset, "0,2", "8_BIT_UNSIGNED", "PROJCS['DHDN_3_Degree_Gauss_Zone_3',GEOGCS['GCS_Deutsches_Hauptdreiecksnetz',DATUM['D_Deutsches_Hauptdreiecksnetz',SPHEROID['Bessel_1841',6377397.155,299.1528128]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Gauss_Kruger'],PARAMETER['False_Easting',3500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',9.0],PARAMETER['Scale_Factor',1.0],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "3", "", "PYRAMIDS -1 NEAREST LZ77 75 NO_SKIP", "128 128", "LZ77", "")

    arcpy.env.pyramid = "PYRAMIDS 3 BILINEAR JPEG"
    arcpy.env.rasterStatistics = "STATISTICS 4 6 (0)"
    arcpy.BuildPyramidsAndStatistics_management(PfadWorkspace, "INCLUDE_SUBDIRECTORIES", "BUILD_PYRAMIDS", "CALCULATE_STATISTICS")

    # Process: Workspace in Raster-Dataset
    arcpy.WorkspaceToRasterDataset_management(PfadWorkspace, DatasetPfad, "NONE", "LAST", "MATCH", "", "", "NONE", "0", "HISTOGRAM_MATCHING", "NONE")

    print "failed"
    print arcpy.GetMessages()‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Could it be that the dataset definition don't fit with the type of raster source files?


Raster Source file (jpeg):

I don't find any differences.

Or is it something with the calculation of statistics?

If I use the toolbox tools to load the data manually into the dataset, there's as well no error message and there's afterwards the same empty dataset although the tool message ends with a sucessful loading of the data.

0 Kudos
3 Replies
MVP Legendary Contributor


the input location is a folder?  I can't tell from your input parameters which if any is a folder.

Merges all of the raster datasets in a folder into one raster dataset.

And the output already exists and/or was created by your code?

The target raster dataset must already exist for the tool to run.
0 Kudos
Occasional Contributor III

The input location is a folder with jpeg images and the raster dataset is created by the code.

0 Kudos
Occasional Contributor III

Update 10.4.1 was the solution.

0 Kudos