<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extract by Mask invalid characters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233392#M66126</link>
    <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;line numbers would help&lt;/P&gt;&lt;P&gt;your in_raster =&amp;nbsp;&lt;/P&gt;&lt;P&gt;statements are both text strings and not variable names/file path references (eg they should be in double quotes)&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2022 20:40:37 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-11-18T20:40:37Z</dc:date>
    <item>
      <title>Extract by Mask invalid characters</title>
      <link>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233343#M66122</link>
      <description>&lt;P&gt;I am trying to extract a landsat8 image and SRTM terrain to a study area's extent. I first projected the data (which runs fine) and I have run this section of code before with no issues. Now it is saying that it is unable to execute the extract by mask because of invalid characters. I have double-checked the names and file paths but there are no spaces or other invalidating naming conventions (as far as I can tell).&lt;/P&gt;&lt;P&gt;Can anyone help point me to where I am wrong?&amp;nbsp; For clarification, projecting the study area polygon and the imagery layer works fine, but it fails on the first extract by mask&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Import modules
import arcpy
from arcpy.sa import *
from sys import argv
import os

#Set environment settings
arcpy.env.overwriteOutput = True
arcpy.env.workspace = 'Project_5.gdb'
arcpy.env.scratchWorkspace = 'Project_5_Scratch.gdb'

#Establish variables
imagery = arcpy.Raster("D:\\Documents\\School\\USC\\586\\586_Project_5\\DATA\\Landsat\\LC08_L2SP_015036_20221108_20221115_02_T1\\LC08_L2SP_015036_20221108_20221115_02_T1_MTL.txt")
terrain = arcpy.Raster("D:\\Documents\\School\\USC\\586\\586_Project_5\\Project_5\\Project_5.gdb\\STRM_VoidFilled")
studyextent = "onslow_county"
projection = arcpy.SpatialReference(32145)
classificationmodel = "LandCoverClassification.dlpk"

#Input data preperation. projects input data into specified coordinate system and clips rasters to study area. 
studyareaprj = "studyareaprj"
arcpy.management.Project(in_dataset = studyextent, out_dataset = studyareaprj, out_coor_system = projection)

terrainprj = "terrainprj"
arcpy.management.ProjectRaster(in_raster = terrain, out_raster = terrainprj, out_coor_system = projection)
terrainprj = arcpy.Raster(terrainprj)

terrainmskprj = "terrainmskprj"
outterrainmsk = arcpy.sa.ExtractByMask(in_raster = terrainprj, in_mask_data = studyareaprj, extraction_area="INSIDE")
outterrainmsk.save(terrainmskprj)

imageryprj = "imageryprj"
arcpy.management.ProjectRaster(in_raster = imagery, out_raster = imageryprj, out_coor_system = projection)
imageryprj = arcpy.Raster(imageryprj)

imagerymskprj = "imagerymskprj"
outimagemsk = arcpy.sa.ExtractByMask(in_raster = imageryprj, in_mask_data = studyareaprj, extraction_area="INSIDE")
outimagemsk.save(imagerymskprj)

prepmsg = "Input data has been projected to specified coordinates and clipped to study extent."
print(prepmsg)
arcpy.AddMessage(prepmsg)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "D:\Documents\School\USC\586\586_Project_5\Project_5\SiteSuitability.py", line 30, in &amp;lt;module&amp;gt;&lt;BR /&gt;outterrainmsk = arcpy.sa.ExtractByMask(in_raster = terrainprj, in_mask_data = studyareaprj, extraction_area="INSIDE")&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 4237, in ExtractByMask&lt;BR /&gt;return Wrapper(&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Utils.py", line 55, in swapper&lt;BR /&gt;result = wrapper(*args, **kwargs)&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 4230, in Wrapper&lt;BR /&gt;result = arcpy.gp.ExtractByMask_sa(&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in &amp;lt;lambda&amp;gt;&lt;BR /&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;BR /&gt;arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.&lt;BR /&gt;ERROR 000354: The name contains invalid characters&lt;BR /&gt;Failed to execute (ExtractByMask).&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 04:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233343#M66122</guid>
      <dc:creator>JacobSpear1</dc:creator>
      <dc:date>2022-11-19T04:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask invalid characters</title>
      <link>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233392#M66126</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;line numbers would help&lt;/P&gt;&lt;P&gt;your in_raster =&amp;nbsp;&lt;/P&gt;&lt;P&gt;statements are both text strings and not variable names/file path references (eg they should be in double quotes)&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 20:40:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233392#M66126</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-11-18T20:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask invalid characters</title>
      <link>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233507#M66132</link>
      <description>&lt;P&gt;Fixed it!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It was being really picky with how I specified the workspace. The errors were fixed when I included the entire file path for setting the env workspace.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 07:58:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-by-mask-invalid-characters/m-p/1233507#M66132</guid>
      <dc:creator>JacobSpear1</dc:creator>
      <dc:date>2022-11-19T07:58:28Z</dc:date>
    </item>
  </channel>
</rss>

