I am a user of ArcGIS Pro. I am trying to convert a polygon shapefile into a raster dataset, then export a raster dataset to a PNG format via arcpy.RasterToOtherFormat_conversion.
From .shp to .tif
arcpy.PolygonToRaster_conversion("SingleArea.shp", "NAME", r"C:\Users\Documents\ArcGIS\Projects\Image\SingleArea.tif", "MAXIMUM_AREA", cellsize = 0.25)
from .tif to .png
arcpy.RasterToOtherFormat_conversion(r"C:\Users\Documents\ArcGIS\Projects\Image\SingleArea.tif", r"C:\Users\Documents\ArcGIS\Projects\Image", "PNG")
This is the area corresponding to the raster
This is the exported .png file.
It is only including the boundary and no any map features displayed along with it.
How can I get the imagery from the raster like a clipping from the map?
I tried to use extract by mask and code as below:
outExtractByMask = ExtractByMask(r"C:\Users\Documents\ArcGIS\Projects\Image\SingleArea.tif", \ r"C:\Users\Documents\ArcGIS\Projects\Image\SingleArea.shp")
Then saved the outraster into a new .tif and then export the new .tif into .png
The output is still the black image. Looks like it didn't include the basemap when exporting.