Reading raster in Python to Clip USGS 3DEM?When a raster is clipped to a polygon with Python, why does it...

Broken patches on a road

What is the purpose of easy combat scenarios that don't need resource expenditure?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Placing an adverb between a verb and an object?

How to prevent cleaner from hanging my lock screen in Ubuntu 16.04

Why did other German political parties disband so fast when Hitler was appointed chancellor?

Compress command output by piping to bzip2

Why is "points exist" not an axiom in geometry?

Jumping Numbers

How do I say "Brexit" in Latin?

Why Normality assumption in linear regression

Contest math problem about crossing out numbers in the table

Checking for the existence of multiple directories

Am I a Rude Number?

Program that converts a number to a letter of the alphabet

Why are the books in the Game of Thrones citadel library shelved spine inwards?

Using only 1s, make 29 with the minimum number of digits

Why did this image turn out darker?

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Can a hotel cancel a confirmed reservation?

How to deal with an incendiary email that was recalled

Slow moving projectiles from a hand-held weapon - how do they reach the target?

Dilemma of explaining to interviewer that he is the reason for declining second interview

Every character has a name - does this lead to too many named characters?



Reading raster in Python to Clip USGS 3DEM?


When a raster is clipped to a polygon with Python, why does it still take on the extent of the entire shapefile?How to Clip a DEM and retain DEM format?Defining NoData values in ArcPy Clip raster tool?Raster images losing quality when clipped?Black image after clipping with ArcGIS for Desktop?How to clip MrSID Files in R and export to GeoTiff?Resampling a raster file with GDAL C#Clipping raster by mask layer polygon produces Nodata values in QGISMake raster layer arcpy error 000865Clipping a raster with several polygon features - saving output rasters according to a field name in the polygon layer













0















I want to clip the elevation data (3DEM) downloaded from USGS website. The raster-clip tool "Clip (data management)" in ArcGIS Pro works very well. However, I cannot clip it using the python function "arcpy.Clip_management()" .



The error report that the raster file is not exist or not support. I have tried different ways to read it, such as:



~grdn39w075.tif/Band_1 This is used by the Clip tool in Arcgis Pro
~grdn39w075.tif_Band_1
~grdn39w075/Band_1



None of them can read the 3DEM file successfully.



Python code:



in_raster= "~/Elevation/Tiles/grdn42w075.tif/Band_1"
for i in range(0,9):
buffer = shp_list[i]
out_id=num_buffer=re.findall('d+', shp_list[i])
out_path="C:/Users/zhangx24/Desktop/LUR_DM/GIS/Elevation/n42w75/"
arcpy.Clip_management(in_raster,buffer,"n42w75_"+ out_id[1],
"~/Documents/ArcGIS/Projects/LUR/LUR.gdb","99999","ClippingGeometry", "MAINTAIN_EXTENT")









share|improve this question
















bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • ~/ means nothing in Windows, try using the full path including the drive letter

    – mikewatt
    Jan 30 at 20:57













  • Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path.

    – Sara
    Jan 30 at 21:05











  • Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly

    – mikewatt
    Jan 30 at 21:46











  • I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers.

    – Paulo Raposo
    Jan 31 at 5:18


















0















I want to clip the elevation data (3DEM) downloaded from USGS website. The raster-clip tool "Clip (data management)" in ArcGIS Pro works very well. However, I cannot clip it using the python function "arcpy.Clip_management()" .



The error report that the raster file is not exist or not support. I have tried different ways to read it, such as:



~grdn39w075.tif/Band_1 This is used by the Clip tool in Arcgis Pro
~grdn39w075.tif_Band_1
~grdn39w075/Band_1



None of them can read the 3DEM file successfully.



Python code:



in_raster= "~/Elevation/Tiles/grdn42w075.tif/Band_1"
for i in range(0,9):
buffer = shp_list[i]
out_id=num_buffer=re.findall('d+', shp_list[i])
out_path="C:/Users/zhangx24/Desktop/LUR_DM/GIS/Elevation/n42w75/"
arcpy.Clip_management(in_raster,buffer,"n42w75_"+ out_id[1],
"~/Documents/ArcGIS/Projects/LUR/LUR.gdb","99999","ClippingGeometry", "MAINTAIN_EXTENT")









share|improve this question
















bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • ~/ means nothing in Windows, try using the full path including the drive letter

    – mikewatt
    Jan 30 at 20:57













  • Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path.

    – Sara
    Jan 30 at 21:05











  • Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly

    – mikewatt
    Jan 30 at 21:46











  • I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers.

    – Paulo Raposo
    Jan 31 at 5:18
















0












0








0








I want to clip the elevation data (3DEM) downloaded from USGS website. The raster-clip tool "Clip (data management)" in ArcGIS Pro works very well. However, I cannot clip it using the python function "arcpy.Clip_management()" .



The error report that the raster file is not exist or not support. I have tried different ways to read it, such as:



~grdn39w075.tif/Band_1 This is used by the Clip tool in Arcgis Pro
~grdn39w075.tif_Band_1
~grdn39w075/Band_1



None of them can read the 3DEM file successfully.



Python code:



in_raster= "~/Elevation/Tiles/grdn42w075.tif/Band_1"
for i in range(0,9):
buffer = shp_list[i]
out_id=num_buffer=re.findall('d+', shp_list[i])
out_path="C:/Users/zhangx24/Desktop/LUR_DM/GIS/Elevation/n42w75/"
arcpy.Clip_management(in_raster,buffer,"n42w75_"+ out_id[1],
"~/Documents/ArcGIS/Projects/LUR/LUR.gdb","99999","ClippingGeometry", "MAINTAIN_EXTENT")









share|improve this question
















I want to clip the elevation data (3DEM) downloaded from USGS website. The raster-clip tool "Clip (data management)" in ArcGIS Pro works very well. However, I cannot clip it using the python function "arcpy.Clip_management()" .



The error report that the raster file is not exist or not support. I have tried different ways to read it, such as:



~grdn39w075.tif/Band_1 This is used by the Clip tool in Arcgis Pro
~grdn39w075.tif_Band_1
~grdn39w075/Band_1



None of them can read the 3DEM file successfully.



Python code:



in_raster= "~/Elevation/Tiles/grdn42w075.tif/Band_1"
for i in range(0,9):
buffer = shp_list[i]
out_id=num_buffer=re.findall('d+', shp_list[i])
out_path="C:/Users/zhangx24/Desktop/LUR_DM/GIS/Elevation/n42w75/"
arcpy.Clip_management(in_raster,buffer,"n42w75_"+ out_id[1],
"~/Documents/ArcGIS/Projects/LUR/LUR.gdb","99999","ClippingGeometry", "MAINTAIN_EXTENT")






arcpy raster clip






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 30 at 21:38









PolyGeo

53.6k1780240




53.6k1780240










asked Jan 30 at 15:57









SaraSara

112




112





bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • ~/ means nothing in Windows, try using the full path including the drive letter

    – mikewatt
    Jan 30 at 20:57













  • Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path.

    – Sara
    Jan 30 at 21:05











  • Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly

    – mikewatt
    Jan 30 at 21:46











  • I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers.

    – Paulo Raposo
    Jan 31 at 5:18





















  • ~/ means nothing in Windows, try using the full path including the drive letter

    – mikewatt
    Jan 30 at 20:57













  • Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path.

    – Sara
    Jan 30 at 21:05











  • Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly

    – mikewatt
    Jan 30 at 21:46











  • I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers.

    – Paulo Raposo
    Jan 31 at 5:18



















~/ means nothing in Windows, try using the full path including the drive letter

– mikewatt
Jan 30 at 20:57







~/ means nothing in Windows, try using the full path including the drive letter

– mikewatt
Jan 30 at 20:57















Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path.

– Sara
Jan 30 at 21:05





Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path.

– Sara
Jan 30 at 21:05













Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly

– mikewatt
Jan 30 at 21:46





Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly

– mikewatt
Jan 30 at 21:46













I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers.

– Paulo Raposo
Jan 31 at 5:18







I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers.

– Paulo Raposo
Jan 31 at 5:18












1 Answer
1






active

oldest

votes


















0














I think the problem is here:



.../grdn42w075.tif/Band_1


A .tif file, on the OS, is the end of a path, so /Band_1 doesn't make sense when Python tries to look for that path. If you're just going for that .tif file, simply delete /Band_1. All existing bands in the GeoTiff should get clipped by default by the Arc tool.



If grdn42w075.tif is in fact a directory, you might need to supply the file extension for the file Band_1. I suggest not naming your directories that way, and please use 4 spaces when indenting in Python :)






share|improve this answer























    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%2f310487%2freading-raster-in-python-to-clip-usgs-3dem%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I think the problem is here:



    .../grdn42w075.tif/Band_1


    A .tif file, on the OS, is the end of a path, so /Band_1 doesn't make sense when Python tries to look for that path. If you're just going for that .tif file, simply delete /Band_1. All existing bands in the GeoTiff should get clipped by default by the Arc tool.



    If grdn42w075.tif is in fact a directory, you might need to supply the file extension for the file Band_1. I suggest not naming your directories that way, and please use 4 spaces when indenting in Python :)






    share|improve this answer




























      0














      I think the problem is here:



      .../grdn42w075.tif/Band_1


      A .tif file, on the OS, is the end of a path, so /Band_1 doesn't make sense when Python tries to look for that path. If you're just going for that .tif file, simply delete /Band_1. All existing bands in the GeoTiff should get clipped by default by the Arc tool.



      If grdn42w075.tif is in fact a directory, you might need to supply the file extension for the file Band_1. I suggest not naming your directories that way, and please use 4 spaces when indenting in Python :)






      share|improve this answer


























        0












        0








        0







        I think the problem is here:



        .../grdn42w075.tif/Band_1


        A .tif file, on the OS, is the end of a path, so /Band_1 doesn't make sense when Python tries to look for that path. If you're just going for that .tif file, simply delete /Band_1. All existing bands in the GeoTiff should get clipped by default by the Arc tool.



        If grdn42w075.tif is in fact a directory, you might need to supply the file extension for the file Band_1. I suggest not naming your directories that way, and please use 4 spaces when indenting in Python :)






        share|improve this answer













        I think the problem is here:



        .../grdn42w075.tif/Band_1


        A .tif file, on the OS, is the end of a path, so /Band_1 doesn't make sense when Python tries to look for that path. If you're just going for that .tif file, simply delete /Band_1. All existing bands in the GeoTiff should get clipped by default by the Arc tool.



        If grdn42w075.tif is in fact a directory, you might need to supply the file extension for the file Band_1. I suggest not naming your directories that way, and please use 4 spaces when indenting in Python :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 31 at 5:20









        Paulo RaposoPaulo Raposo

        1,603718




        1,603718






























            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%2f310487%2freading-raster-in-python-to-clip-usgs-3dem%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

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

            Meter-Bus Содержание Параметры шины | Стандартизация |...