Convert shapefile to raster


PurposeThis developer sample shows how to convert a shapefile into a GRID raster.

How to use

If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Run the sample, providing the command line arguments outlined in the Additional requirements section.
  2. A GRID raster dataset will be created based on the input shapefile. The GRID raster dataset will be created in the directory containing the input shapefile.

Additional information

Command line arguments:
 
  • -s [full path to input shapefile] (e.g. -s "c:\path\to\shapefile.shp"), FULL_PATH_TO_SHAPEFILE in Makefile
  • -f [name of field in shapefile to use for cell values] (e.g. -f NAME), FIELD_NAME in Makefile
  • -r [name of output GRID] (e.g. -r outgrid), OUTPUT_GRID_NAME in Makefile
  • -c [cell size for output GRID] (e.g. -c 1.0), CELL_SIZE in Makefile


Shape2Raster.cpp Implementation file
Shape2Raster.h Header file
LicenseUtilities.cpp Implementation file
LicenseUtilities.h Header file
PathUtilities.cpp Implementation file
PathUtilities.h Header file
Makefile.Windows Windows Makefile
Makefile.Solaris Solaris Makefile
Makefile.Linux Linux Makefile
Download the CPP files

Download the files for all languages




Additional Requirements
  • an input shapefile dataset

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime: Spatial