I currently have a Python script to process some vegetation data, while using some specific shapefiles.

The first step is to build a geo lookup table which needs to convert the shapefile from polygon to raster and then from raster to ascii. And the extent of the converted file must match the raw data file.

Even though I set up the environment variables based on the raw data file, the result still show a different extent with the raw data file. Normally they should match since it did work when I tested it with ArcMap manually. However, it just did not work with ArcPy and Python code. Any opinions?

Below is the snippet of the code:

env.workspace = workingdir
env.overwriteOutput = True
arcpy.env.extent = rawdatafile
arcpy.env.cellSize = rawdatafile

arcpy.PolygonToRaster_conversion(in_features=shapefile, value_field="FIPS", out_rasterdataset=shpraster, cell_assignment="CELL_CENTER",cellsize=rawdatafile)
arcpy.RasterToASCII_conversion(in_raster=shpraster, out_ascii_file=shpascii)`


However, the dataAscii and shpascii have different numbers of columns and rows.

  • 1
    At the moment the code snippet that you are presenting does not set the rawdata variable. It would be useful for us to see its value.
    – PolyGeo
    Commented Feb 23, 2016 at 5:30

1 Answer 1


Seeing the error you get when running the code would make answering much easier.

A few general hints:

  • Try using r"C:Path\Pathexample" for defining paths.
  • Don't use in_features=... in your tool variables, but just the variable name. For some tools you have to use the whole path name including extention (i.e. .shp) as input. In others it's just the name with extention of the feature / raster data. Check the ArcGIS Desktop Help for the tools you're using.

I will update this answer when you provide some further information, in case this doesn't help yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.