Changing particular value of raster dataset to zero using ArcPy? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Python script using SAGA and arcpy for converting 'on the fly' LAS point cloud to shapefile?Saving raster dataset using ArcPy?Checking if domain contains particular coded value using ArcPy?Where clause problems when all parts are user input variablesHow to use the local macro to do ZonalStatisticsAsTable in batchRaster calculation in for loop returning exit code -1Running custom model via ArcPy with PyCharm fails with exit code -1073741819 (0xC0000005)?Entering date with arcpy.GetParameterAsText()?Extracting raster value to specific range using ArcPy?Adding compression variable to CopyRaster_management for TIFF Raster Dataset?

What does Turing mean by this statement?

What initially awakened the Balrog?

AppleTVs create a chatty alternate WiFi network

What does 丫 mean? 丫是什么意思?

How can a team of shapeshifters communicate?

Does silver oxide react with hydrogen sulfide?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Did any compiler fully use 80-bit floating point?

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

Understanding p-Values using an example

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

Asymptotics question

Universal covering space of the real projective line?

Relating to the President and obstruction, were Mueller's conclusions preordained?

How would a mousetrap for use in space work?

Tips to organize LaTeX presentations for a semester

My mentor says to set image to Fine instead of RAW — how is this different from JPG?

What are the main differences between Stargate SG-1 cuts?

RSA find public exponent

What to do with repeated rejections for phd position

Is there public access to the Meteor Crater in Arizona?

Why weren't discrete x86 CPUs ever used in game hardware?

What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?

What is the "studentd" process?



Changing particular value of raster dataset to zero using ArcPy?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Python script using SAGA and arcpy for converting 'on the fly' LAS point cloud to shapefile?Saving raster dataset using ArcPy?Checking if domain contains particular coded value using ArcPy?Where clause problems when all parts are user input variablesHow to use the local macro to do ZonalStatisticsAsTable in batchRaster calculation in for loop returning exit code -1Running custom model via ArcPy with PyCharm fails with exit code -1073741819 (0xC0000005)?Entering date with arcpy.GetParameterAsText()?Extracting raster value to specific range using ArcPy?Adding compression variable to CopyRaster_management for TIFF Raster Dataset?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I try to change a particular value of raster dataset to zero using python script.
When I deal with one raster, it works. Python scripts as follow:



import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
# Set environment settings
env.workspace = r'D:MATLABTEST'
# Set local variables
a="states1166.tif"
inRaster = Raster(a)
outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)
# Save the outputs
outCon.save("D:MATLABTESTprif11166.tif")


But when I deal with multiple raster, it failed. Python scripts as follow:



# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
import sys
import os
arcpy.CheckOutExtension("Spatial")

env.workspace = r'D:MATLABPriForest'

outdir = os.path.join(os.path.dirname(env.workspace),"Replace")
if not os.path.exists(outdir) : os.mkdir(outdir)
inRasters = arcpy.ListRasters("*")

print "Begin Replace"

for inRaster in inRasters:

outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)

filename = 'PriForest' + os.path.basename(inRaster)
outfile = os.path.join(outdir,filename)

outCon.save(outfile)

print('finished')[enter link description here][1]


Does anyone know the reason?










share|improve this question
























  • Show us the error message.

    – Mr. Che
    Apr 12 at 8:14












  • well, the raster was a global map of forest area and the missing value was filled with 1.000000020040877e+20 . When I deal with multiple raster, the value was only replaced in the region without land. While the land area still remained the original value.

    – Jianxing_Zhu
    Apr 12 at 8:24











  • So the script does not fail to work? Try to print output parameters (outfile) and check that files.

    – Mr. Che
    Apr 12 at 8:32












  • The script run fine. I just did not get the ideal results from the script and confused about the results. The results were totally different with the result obtained form the former script and the results I got from raster calculator in ArcMap.

    – Jianxing_Zhu
    Apr 12 at 8:45











  • arcpy.Raster(inRaster) might help.

    – FelixIP
    Apr 12 at 9:38

















0















I try to change a particular value of raster dataset to zero using python script.
When I deal with one raster, it works. Python scripts as follow:



import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
# Set environment settings
env.workspace = r'D:MATLABTEST'
# Set local variables
a="states1166.tif"
inRaster = Raster(a)
outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)
# Save the outputs
outCon.save("D:MATLABTESTprif11166.tif")


But when I deal with multiple raster, it failed. Python scripts as follow:



# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
import sys
import os
arcpy.CheckOutExtension("Spatial")

env.workspace = r'D:MATLABPriForest'

outdir = os.path.join(os.path.dirname(env.workspace),"Replace")
if not os.path.exists(outdir) : os.mkdir(outdir)
inRasters = arcpy.ListRasters("*")

print "Begin Replace"

for inRaster in inRasters:

outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)

filename = 'PriForest' + os.path.basename(inRaster)
outfile = os.path.join(outdir,filename)

outCon.save(outfile)

print('finished')[enter link description here][1]


Does anyone know the reason?










share|improve this question
























  • Show us the error message.

    – Mr. Che
    Apr 12 at 8:14












  • well, the raster was a global map of forest area and the missing value was filled with 1.000000020040877e+20 . When I deal with multiple raster, the value was only replaced in the region without land. While the land area still remained the original value.

    – Jianxing_Zhu
    Apr 12 at 8:24











  • So the script does not fail to work? Try to print output parameters (outfile) and check that files.

    – Mr. Che
    Apr 12 at 8:32












  • The script run fine. I just did not get the ideal results from the script and confused about the results. The results were totally different with the result obtained form the former script and the results I got from raster calculator in ArcMap.

    – Jianxing_Zhu
    Apr 12 at 8:45











  • arcpy.Raster(inRaster) might help.

    – FelixIP
    Apr 12 at 9:38













0












0








0








I try to change a particular value of raster dataset to zero using python script.
When I deal with one raster, it works. Python scripts as follow:



import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
# Set environment settings
env.workspace = r'D:MATLABTEST'
# Set local variables
a="states1166.tif"
inRaster = Raster(a)
outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)
# Save the outputs
outCon.save("D:MATLABTESTprif11166.tif")


But when I deal with multiple raster, it failed. Python scripts as follow:



# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
import sys
import os
arcpy.CheckOutExtension("Spatial")

env.workspace = r'D:MATLABPriForest'

outdir = os.path.join(os.path.dirname(env.workspace),"Replace")
if not os.path.exists(outdir) : os.mkdir(outdir)
inRasters = arcpy.ListRasters("*")

print "Begin Replace"

for inRaster in inRasters:

outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)

filename = 'PriForest' + os.path.basename(inRaster)
outfile = os.path.join(outdir,filename)

outCon.save(outfile)

print('finished')[enter link description here][1]


Does anyone know the reason?










share|improve this question
















I try to change a particular value of raster dataset to zero using python script.
When I deal with one raster, it works. Python scripts as follow:



import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
# Set environment settings
env.workspace = r'D:MATLABTEST'
# Set local variables
a="states1166.tif"
inRaster = Raster(a)
outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)
# Save the outputs
outCon.save("D:MATLABTESTprif11166.tif")


But when I deal with multiple raster, it failed. Python scripts as follow:



# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
import sys
import os
arcpy.CheckOutExtension("Spatial")

env.workspace = r'D:MATLABPriForest'

outdir = os.path.join(os.path.dirname(env.workspace),"Replace")
if not os.path.exists(outdir) : os.mkdir(outdir)
inRasters = arcpy.ListRasters("*")

print "Begin Replace"

for inRaster in inRasters:

outCon = Con(inRaster == 1.000000020040877e+20, 0, inRaster)

filename = 'PriForest' + os.path.basename(inRaster)
outfile = os.path.join(outdir,filename)

outCon.save(outfile)

print('finished')[enter link description here][1]


Does anyone know the reason?







arcpy spatial-analyst con






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 12 at 8:11









PolyGeo

54.1k1782246




54.1k1782246










asked Apr 12 at 8:06









Jianxing_ZhuJianxing_Zhu

1




1












  • Show us the error message.

    – Mr. Che
    Apr 12 at 8:14












  • well, the raster was a global map of forest area and the missing value was filled with 1.000000020040877e+20 . When I deal with multiple raster, the value was only replaced in the region without land. While the land area still remained the original value.

    – Jianxing_Zhu
    Apr 12 at 8:24











  • So the script does not fail to work? Try to print output parameters (outfile) and check that files.

    – Mr. Che
    Apr 12 at 8:32












  • The script run fine. I just did not get the ideal results from the script and confused about the results. The results were totally different with the result obtained form the former script and the results I got from raster calculator in ArcMap.

    – Jianxing_Zhu
    Apr 12 at 8:45











  • arcpy.Raster(inRaster) might help.

    – FelixIP
    Apr 12 at 9:38

















  • Show us the error message.

    – Mr. Che
    Apr 12 at 8:14












  • well, the raster was a global map of forest area and the missing value was filled with 1.000000020040877e+20 . When I deal with multiple raster, the value was only replaced in the region without land. While the land area still remained the original value.

    – Jianxing_Zhu
    Apr 12 at 8:24











  • So the script does not fail to work? Try to print output parameters (outfile) and check that files.

    – Mr. Che
    Apr 12 at 8:32












  • The script run fine. I just did not get the ideal results from the script and confused about the results. The results were totally different with the result obtained form the former script and the results I got from raster calculator in ArcMap.

    – Jianxing_Zhu
    Apr 12 at 8:45











  • arcpy.Raster(inRaster) might help.

    – FelixIP
    Apr 12 at 9:38
















Show us the error message.

– Mr. Che
Apr 12 at 8:14






Show us the error message.

– Mr. Che
Apr 12 at 8:14














well, the raster was a global map of forest area and the missing value was filled with 1.000000020040877e+20 . When I deal with multiple raster, the value was only replaced in the region without land. While the land area still remained the original value.

– Jianxing_Zhu
Apr 12 at 8:24





well, the raster was a global map of forest area and the missing value was filled with 1.000000020040877e+20 . When I deal with multiple raster, the value was only replaced in the region without land. While the land area still remained the original value.

– Jianxing_Zhu
Apr 12 at 8:24













So the script does not fail to work? Try to print output parameters (outfile) and check that files.

– Mr. Che
Apr 12 at 8:32






So the script does not fail to work? Try to print output parameters (outfile) and check that files.

– Mr. Che
Apr 12 at 8:32














The script run fine. I just did not get the ideal results from the script and confused about the results. The results were totally different with the result obtained form the former script and the results I got from raster calculator in ArcMap.

– Jianxing_Zhu
Apr 12 at 8:45





The script run fine. I just did not get the ideal results from the script and confused about the results. The results were totally different with the result obtained form the former script and the results I got from raster calculator in ArcMap.

– Jianxing_Zhu
Apr 12 at 8:45













arcpy.Raster(inRaster) might help.

– FelixIP
Apr 12 at 9:38





arcpy.Raster(inRaster) might help.

– FelixIP
Apr 12 at 9:38










0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318567%2fchanging-particular-value-of-raster-dataset-to-zero-using-arcpy%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318567%2fchanging-particular-value-of-raster-dataset-to-zero-using-arcpy%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

QGIS export composer to PDF scale the map [closed] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Print Composer QGIS 2.6, how to export image?QGIS 2.8.1 print composer won't export all OpenCycleMap base layer tilesSave Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?Export QGIS Print Composer PDF with searchable text labelsQGIS Print Composer does not change from landscape to portrait orientation?How can I avoid map size and scale changes in print composer?Fuzzy PDF export in QGIS running on macSierra OSExport the legend into its 100% size using Print ComposerScale-dependent rendering in QGIS PDF output