1

I have a Raster image like this enter image description here

as you can see the road are not connected between 2 raster (up and down) its because the scanned raster use different projection (dgn utm 50s) than my data frame (utm 50s) when I'm doing Georeferencing. Somebody in here (Michael Mils) help me with some python code to create batch raster convertion without change raster name (I modified it a little to match the original raster projection "dgn utm 50 s"). Code :
Code are Fixed by Michael Mills, Problem Solved, Here's the Complete Code

import arcpy, sys, os

InFolder = r"d:\00_Start"
OutFolder = r"d:\01_End"
OutSR = arcpy.SpatialReference(23880) # "DGN_1995_UTM_Zone_50S"

arcpy.env.workspace = InFolder

for Ras in arcpy.ListRasters():
    Name,Ext = os.path.splitext(Ras)
    OutRas = Name + ".tif"
    arcpy.AddMessage("Sementara Proses " + Ras + " Coy")
    arcpy.ProjectRaster_management (InFolder + "\\" + Ras , OutFolder + "\\" + OutRas,OutSR)
    arcpy.SetRasterProperties_management(OutFolder + "\\" + OutRas,"GENERIC","", "", "3 0;2 0;1 0")
    arcpy.AddMessage("So Klar")

and the result is like this : enter image description here

as you can see the road are connected now and everything's are perfect in place but there are still anoying black border in each raster (all the raster I converted result black border, there are 170 raster I need to process). How to convert using that python script without getting that black border?

3

When you project a raster it gets a fine rotation which has to be filled with something, usually 0. After projecting use SetRasterProperites in your script to set the null value for the raster.

After setting the nodata value it might be a good idea to build the pyramids and recalculate statistics, but first check to see whether the tool does it automatically; most tools that affect rasters will rebuild the pyramids and statistics dependant on arcpy.env.rasterStatistics and arcpy.env.pyramid settings.

Like this, don't forget to import os:

for Ras in arcpy.ListRasters():
    Name,Ext = os.path.splitext(Ras)
    OutRas = Name + ".tif"
    arcpy.AddMessage("Sementara Proses " + Ras + " Coy")
    arcpy.ProjectRaster_management (InFolder + "\\" + Ras , OutFolder + "\\" + OutRas,OutSR)
    arcpy.SetRasterProperties_management(OutFolder + "\\" + OutRas,"GENERIC","", "", "3 0;2 0;1 0")
  • Hi Michael, Thanks for the code above, how to apply those setrasterproperties on python? – Rikudo Pain Jun 16 '14 at 4:00
  • Follow the link, there are examples there. Optional parameters use "#", for the NoData value there is no example but from the documentation it should be [[1,0],[2,0],[3,0]] – Michael Stimson Jun 16 '14 at 4:04
  • Updated python code in question, but how do i define the statistic? is it already correct? is it okay if i just want to add NoData Value without other atribut setting? – Rikudo Pain Jun 16 '14 at 4:14
  • Statistics can be viewed by looking at the properties in ArcCatalog, on the bottom most of the form. Statistics should only need to be updated if you're actually using them - classifed and stretched renderers. If you are using stretch = none then there's no point having them. – Michael Stimson Jun 16 '14 at 4:16
  • I use minimum - maximum for stretch. Actualy i just want to remove the blackborder and set every other setting in default. Is okay just set only nodata value attribute? – Rikudo Pain Jun 16 '14 at 4:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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