getting the error “The truth value of an array with more than one element is ambiguous”?
I am trying to plot a raster image using Rasterio, Matplotlib, and Numpy. Although what I am doing is probably irrelevant and general to the actual python code and error.
Here is the code:
import rasterio
import matplotlib.pyplot as plt
import numpy as np
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
band4 = rasterio.open(r"LC08_L1TP_015033_20170822_20170912_01_T1_B4.TIF")
#rasterio.windows.Window(col_off, row_off, width, height)
window = rasterio.windows.Window(1024, 1024, 1280, 2560)
with rasterio.open(band5) as src:
subset = src.read(1, window=window)
plt.figure(figsize=(6,8.5))
plt.imshow(subset)
plt.colorbar(shrink=0.5)
plt.title(f'Band 5 Subsetn{window}')
plt.xlabel('Column #')
plt.ylabel('Row #')
Complete error message with traceback:
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
Traceback (most recent call last):
File "<ipython-input-131-5d04fa0ce75f>", line 1, in <module>
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/new/Desktop/RasterSubsetNDVI.py", line 12, in <module>
with rasterio.open(band5) as src:
File "C:UsersnewMiniconda3libcontextlib.py", line 81, in __enter__
return next(self.gen)
File "C:UsersnewMiniconda3libsite-packagesrasterio__init__.py", line 177, in fp_reader
memfile = MemoryFile(fp.read())
File "C:UsersnewMiniconda3libsite-packagesrasterioio.py", line 105, in __init__
file_or_bytes=file_or_bytes, filename=filename, ext=ext)
File "rasterio/_io.pyx", line 745, in rasterio._io.MemoryFileBase.__init__
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I am using code found here and trying to reproduce it on my machine with my own TIF files. Where it says "Pull an image subset at full resolution". LINK:
https://github.com/geohackweek/tutorial_contents/blob/ba5e9443137a9aca87cdcdcd70e9e6a237cc64ba/raster/notebooks/rasterio-landsat-aws.ipynb
I am running on the IDE Sypder and using Python 3.6
Please, any help is appreciated.
Thank you
python numpy matplotlib rasterio
|
show 1 more comment
I am trying to plot a raster image using Rasterio, Matplotlib, and Numpy. Although what I am doing is probably irrelevant and general to the actual python code and error.
Here is the code:
import rasterio
import matplotlib.pyplot as plt
import numpy as np
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
band4 = rasterio.open(r"LC08_L1TP_015033_20170822_20170912_01_T1_B4.TIF")
#rasterio.windows.Window(col_off, row_off, width, height)
window = rasterio.windows.Window(1024, 1024, 1280, 2560)
with rasterio.open(band5) as src:
subset = src.read(1, window=window)
plt.figure(figsize=(6,8.5))
plt.imshow(subset)
plt.colorbar(shrink=0.5)
plt.title(f'Band 5 Subsetn{window}')
plt.xlabel('Column #')
plt.ylabel('Row #')
Complete error message with traceback:
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
Traceback (most recent call last):
File "<ipython-input-131-5d04fa0ce75f>", line 1, in <module>
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/new/Desktop/RasterSubsetNDVI.py", line 12, in <module>
with rasterio.open(band5) as src:
File "C:UsersnewMiniconda3libcontextlib.py", line 81, in __enter__
return next(self.gen)
File "C:UsersnewMiniconda3libsite-packagesrasterio__init__.py", line 177, in fp_reader
memfile = MemoryFile(fp.read())
File "C:UsersnewMiniconda3libsite-packagesrasterioio.py", line 105, in __init__
file_or_bytes=file_or_bytes, filename=filename, ext=ext)
File "rasterio/_io.pyx", line 745, in rasterio._io.MemoryFileBase.__init__
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I am using code found here and trying to reproduce it on my machine with my own TIF files. Where it says "Pull an image subset at full resolution". LINK:
https://github.com/geohackweek/tutorial_contents/blob/ba5e9443137a9aca87cdcdcd70e9e6a237cc64ba/raster/notebooks/rasterio-landsat-aws.ipynb
I am running on the IDE Sypder and using Python 3.6
Please, any help is appreciated.
Thank you
python numpy matplotlib rasterio
1
See Minimal, Complete, and Verifiable example or Short, Self Contained, Correct, Example.
– ImportanceOfBeingErnest
Nov 18 '18 at 19:59
@ImportanceOfBeingErnest Thank you, I should have produced a code that everyone could run on their own machines. It was kind of hard because I don't know how to give people access to my TIF files. I thought maybe it might be something in my computation.
– yuen2
Nov 18 '18 at 20:05
@ImportanceOfBeingErnest I am trying to produce this code with my raster TIF files. Here is the link to the GitHub code where the title states "Pull an image subset at full resolution", LINK: github.com/geohackweek/tutorial_contents/blob/…
– yuen2
Nov 18 '18 at 20:10
Whenever you report a Python error, include the complete error message (i.e. the complete traceback) in the question. There is useful information in there.
– Warren Weckesser
Nov 18 '18 at 20:14
@WarrenWeckesser Got it. I posted the complete traceback with the error message at the end.
– yuen2
Nov 18 '18 at 20:17
|
show 1 more comment
I am trying to plot a raster image using Rasterio, Matplotlib, and Numpy. Although what I am doing is probably irrelevant and general to the actual python code and error.
Here is the code:
import rasterio
import matplotlib.pyplot as plt
import numpy as np
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
band4 = rasterio.open(r"LC08_L1TP_015033_20170822_20170912_01_T1_B4.TIF")
#rasterio.windows.Window(col_off, row_off, width, height)
window = rasterio.windows.Window(1024, 1024, 1280, 2560)
with rasterio.open(band5) as src:
subset = src.read(1, window=window)
plt.figure(figsize=(6,8.5))
plt.imshow(subset)
plt.colorbar(shrink=0.5)
plt.title(f'Band 5 Subsetn{window}')
plt.xlabel('Column #')
plt.ylabel('Row #')
Complete error message with traceback:
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
Traceback (most recent call last):
File "<ipython-input-131-5d04fa0ce75f>", line 1, in <module>
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/new/Desktop/RasterSubsetNDVI.py", line 12, in <module>
with rasterio.open(band5) as src:
File "C:UsersnewMiniconda3libcontextlib.py", line 81, in __enter__
return next(self.gen)
File "C:UsersnewMiniconda3libsite-packagesrasterio__init__.py", line 177, in fp_reader
memfile = MemoryFile(fp.read())
File "C:UsersnewMiniconda3libsite-packagesrasterioio.py", line 105, in __init__
file_or_bytes=file_or_bytes, filename=filename, ext=ext)
File "rasterio/_io.pyx", line 745, in rasterio._io.MemoryFileBase.__init__
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I am using code found here and trying to reproduce it on my machine with my own TIF files. Where it says "Pull an image subset at full resolution". LINK:
https://github.com/geohackweek/tutorial_contents/blob/ba5e9443137a9aca87cdcdcd70e9e6a237cc64ba/raster/notebooks/rasterio-landsat-aws.ipynb
I am running on the IDE Sypder and using Python 3.6
Please, any help is appreciated.
Thank you
python numpy matplotlib rasterio
I am trying to plot a raster image using Rasterio, Matplotlib, and Numpy. Although what I am doing is probably irrelevant and general to the actual python code and error.
Here is the code:
import rasterio
import matplotlib.pyplot as plt
import numpy as np
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
band4 = rasterio.open(r"LC08_L1TP_015033_20170822_20170912_01_T1_B4.TIF")
#rasterio.windows.Window(col_off, row_off, width, height)
window = rasterio.windows.Window(1024, 1024, 1280, 2560)
with rasterio.open(band5) as src:
subset = src.read(1, window=window)
plt.figure(figsize=(6,8.5))
plt.imshow(subset)
plt.colorbar(shrink=0.5)
plt.title(f'Band 5 Subsetn{window}')
plt.xlabel('Column #')
plt.ylabel('Row #')
Complete error message with traceback:
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
Traceback (most recent call last):
File "<ipython-input-131-5d04fa0ce75f>", line 1, in <module>
runfile('C:/Users/new/Desktop/RasterSubsetNDVI.py', wdir='C:/Users/new/Desktop')
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:UsersnewMiniconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/new/Desktop/RasterSubsetNDVI.py", line 12, in <module>
with rasterio.open(band5) as src:
File "C:UsersnewMiniconda3libcontextlib.py", line 81, in __enter__
return next(self.gen)
File "C:UsersnewMiniconda3libsite-packagesrasterio__init__.py", line 177, in fp_reader
memfile = MemoryFile(fp.read())
File "C:UsersnewMiniconda3libsite-packagesrasterioio.py", line 105, in __init__
file_or_bytes=file_or_bytes, filename=filename, ext=ext)
File "rasterio/_io.pyx", line 745, in rasterio._io.MemoryFileBase.__init__
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I am using code found here and trying to reproduce it on my machine with my own TIF files. Where it says "Pull an image subset at full resolution". LINK:
https://github.com/geohackweek/tutorial_contents/blob/ba5e9443137a9aca87cdcdcd70e9e6a237cc64ba/raster/notebooks/rasterio-landsat-aws.ipynb
I am running on the IDE Sypder and using Python 3.6
Please, any help is appreciated.
Thank you
python numpy matplotlib rasterio
python numpy matplotlib rasterio
edited Nov 18 '18 at 20:17
yuen2
asked Nov 18 '18 at 19:54
yuen2yuen2
194
194
1
See Minimal, Complete, and Verifiable example or Short, Self Contained, Correct, Example.
– ImportanceOfBeingErnest
Nov 18 '18 at 19:59
@ImportanceOfBeingErnest Thank you, I should have produced a code that everyone could run on their own machines. It was kind of hard because I don't know how to give people access to my TIF files. I thought maybe it might be something in my computation.
– yuen2
Nov 18 '18 at 20:05
@ImportanceOfBeingErnest I am trying to produce this code with my raster TIF files. Here is the link to the GitHub code where the title states "Pull an image subset at full resolution", LINK: github.com/geohackweek/tutorial_contents/blob/…
– yuen2
Nov 18 '18 at 20:10
Whenever you report a Python error, include the complete error message (i.e. the complete traceback) in the question. There is useful information in there.
– Warren Weckesser
Nov 18 '18 at 20:14
@WarrenWeckesser Got it. I posted the complete traceback with the error message at the end.
– yuen2
Nov 18 '18 at 20:17
|
show 1 more comment
1
See Minimal, Complete, and Verifiable example or Short, Self Contained, Correct, Example.
– ImportanceOfBeingErnest
Nov 18 '18 at 19:59
@ImportanceOfBeingErnest Thank you, I should have produced a code that everyone could run on their own machines. It was kind of hard because I don't know how to give people access to my TIF files. I thought maybe it might be something in my computation.
– yuen2
Nov 18 '18 at 20:05
@ImportanceOfBeingErnest I am trying to produce this code with my raster TIF files. Here is the link to the GitHub code where the title states "Pull an image subset at full resolution", LINK: github.com/geohackweek/tutorial_contents/blob/…
– yuen2
Nov 18 '18 at 20:10
Whenever you report a Python error, include the complete error message (i.e. the complete traceback) in the question. There is useful information in there.
– Warren Weckesser
Nov 18 '18 at 20:14
@WarrenWeckesser Got it. I posted the complete traceback with the error message at the end.
– yuen2
Nov 18 '18 at 20:17
1
1
See Minimal, Complete, and Verifiable example or Short, Self Contained, Correct, Example.
– ImportanceOfBeingErnest
Nov 18 '18 at 19:59
See Minimal, Complete, and Verifiable example or Short, Self Contained, Correct, Example.
– ImportanceOfBeingErnest
Nov 18 '18 at 19:59
@ImportanceOfBeingErnest Thank you, I should have produced a code that everyone could run on their own machines. It was kind of hard because I don't know how to give people access to my TIF files. I thought maybe it might be something in my computation.
– yuen2
Nov 18 '18 at 20:05
@ImportanceOfBeingErnest Thank you, I should have produced a code that everyone could run on their own machines. It was kind of hard because I don't know how to give people access to my TIF files. I thought maybe it might be something in my computation.
– yuen2
Nov 18 '18 at 20:05
@ImportanceOfBeingErnest I am trying to produce this code with my raster TIF files. Here is the link to the GitHub code where the title states "Pull an image subset at full resolution", LINK: github.com/geohackweek/tutorial_contents/blob/…
– yuen2
Nov 18 '18 at 20:10
@ImportanceOfBeingErnest I am trying to produce this code with my raster TIF files. Here is the link to the GitHub code where the title states "Pull an image subset at full resolution", LINK: github.com/geohackweek/tutorial_contents/blob/…
– yuen2
Nov 18 '18 at 20:10
Whenever you report a Python error, include the complete error message (i.e. the complete traceback) in the question. There is useful information in there.
– Warren Weckesser
Nov 18 '18 at 20:14
Whenever you report a Python error, include the complete error message (i.e. the complete traceback) in the question. There is useful information in there.
– Warren Weckesser
Nov 18 '18 at 20:14
@WarrenWeckesser Got it. I posted the complete traceback with the error message at the end.
– yuen2
Nov 18 '18 at 20:17
@WarrenWeckesser Got it. I posted the complete traceback with the error message at the end.
– yuen2
Nov 18 '18 at 20:17
|
show 1 more comment
1 Answer
1
active
oldest
votes
Take a careful look at the following lines of your code (others omitted):
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
# ...
with rasterio.open(band5) as src:
# ...
From the Rasterio documentation:
Rasterio’s
rasterio.open()
takes a path and returns a dataset object.
In the second line above, you're passing a dataset to rasterio.open()
instead of a path. Perhaps you wanted to pass the same path you used to create band5
from?
It would have been nice if rasterio.open()
checked the type of the argument you gave it and gave you an exception that said 'file path is not a string' or suchlike, but sadly it appears not to do this.
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
@yuen2: to be honest I don't know. I've never usedrasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.
– Luke Woodward
Nov 18 '18 at 20:52
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364858%2fgetting-the-error-the-truth-value-of-an-array-with-more-than-one-element-is-amb%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
Take a careful look at the following lines of your code (others omitted):
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
# ...
with rasterio.open(band5) as src:
# ...
From the Rasterio documentation:
Rasterio’s
rasterio.open()
takes a path and returns a dataset object.
In the second line above, you're passing a dataset to rasterio.open()
instead of a path. Perhaps you wanted to pass the same path you used to create band5
from?
It would have been nice if rasterio.open()
checked the type of the argument you gave it and gave you an exception that said 'file path is not a string' or suchlike, but sadly it appears not to do this.
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
@yuen2: to be honest I don't know. I've never usedrasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.
– Luke Woodward
Nov 18 '18 at 20:52
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
add a comment |
Take a careful look at the following lines of your code (others omitted):
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
# ...
with rasterio.open(band5) as src:
# ...
From the Rasterio documentation:
Rasterio’s
rasterio.open()
takes a path and returns a dataset object.
In the second line above, you're passing a dataset to rasterio.open()
instead of a path. Perhaps you wanted to pass the same path you used to create band5
from?
It would have been nice if rasterio.open()
checked the type of the argument you gave it and gave you an exception that said 'file path is not a string' or suchlike, but sadly it appears not to do this.
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
@yuen2: to be honest I don't know. I've never usedrasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.
– Luke Woodward
Nov 18 '18 at 20:52
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
add a comment |
Take a careful look at the following lines of your code (others omitted):
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
# ...
with rasterio.open(band5) as src:
# ...
From the Rasterio documentation:
Rasterio’s
rasterio.open()
takes a path and returns a dataset object.
In the second line above, you're passing a dataset to rasterio.open()
instead of a path. Perhaps you wanted to pass the same path you used to create band5
from?
It would have been nice if rasterio.open()
checked the type of the argument you gave it and gave you an exception that said 'file path is not a string' or suchlike, but sadly it appears not to do this.
Take a careful look at the following lines of your code (others omitted):
band5 = rasterio.open(r"C:UsersnewDesktopLC08_L1TP_015033_20170822_20170912_01_T1_B5.TIF")
# ...
with rasterio.open(band5) as src:
# ...
From the Rasterio documentation:
Rasterio’s
rasterio.open()
takes a path and returns a dataset object.
In the second line above, you're passing a dataset to rasterio.open()
instead of a path. Perhaps you wanted to pass the same path you used to create band5
from?
It would have been nice if rasterio.open()
checked the type of the argument you gave it and gave you an exception that said 'file path is not a string' or suchlike, but sadly it appears not to do this.
answered Nov 18 '18 at 20:35
Luke WoodwardLuke Woodward
45.1k126688
45.1k126688
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
@yuen2: to be honest I don't know. I've never usedrasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.
– Luke Woodward
Nov 18 '18 at 20:52
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
add a comment |
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
@yuen2: to be honest I don't know. I've never usedrasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.
– Luke Woodward
Nov 18 '18 at 20:52
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
Thank you! @Luke Woodward yes that was it. I was calling rasterio.open twice. I am trying to create an 800x600 subset. Do you think this would be correct for that? Code: window = rasterio.windows.Window(1024, 1024, 800, 600)….Not exactly sure what the 1024, 1024, I know that the 800, 600 is essentially saying 800x600, but why would setting the col_off and col_row to 0 make everything purple? Also the original TIF image I had was just black and white but now when I plot it it's purple and blue. Why is this?
– yuen2
Nov 18 '18 at 20:41
@yuen2: to be honest I don't know. I've never used
rasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.– Luke Woodward
Nov 18 '18 at 20:52
@yuen2: to be honest I don't know. I've never used
rasterio
before. It sounds to me like you have a separate question to ask, which isn't related to the error in your question. If so, please ask a separate question.– Luke Woodward
Nov 18 '18 at 20:52
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
Luke Wooward Thank you. I am getting an IndexError: list index out of range. This is Geographic Information Systems problem. I posted the code for that error there. If you could take a look it would be much appreciated: gis.stackexchange.com/questions/303119/…
– yuen2
Nov 18 '18 at 21:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364858%2fgetting-the-error-the-truth-value-of-an-array-with-more-than-one-element-is-amb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
See Minimal, Complete, and Verifiable example or Short, Self Contained, Correct, Example.
– ImportanceOfBeingErnest
Nov 18 '18 at 19:59
@ImportanceOfBeingErnest Thank you, I should have produced a code that everyone could run on their own machines. It was kind of hard because I don't know how to give people access to my TIF files. I thought maybe it might be something in my computation.
– yuen2
Nov 18 '18 at 20:05
@ImportanceOfBeingErnest I am trying to produce this code with my raster TIF files. Here is the link to the GitHub code where the title states "Pull an image subset at full resolution", LINK: github.com/geohackweek/tutorial_contents/blob/…
– yuen2
Nov 18 '18 at 20:10
Whenever you report a Python error, include the complete error message (i.e. the complete traceback) in the question. There is useful information in there.
– Warren Weckesser
Nov 18 '18 at 20:14
@WarrenWeckesser Got it. I posted the complete traceback with the error message at the end.
– yuen2
Nov 18 '18 at 20:17