PyQGIS Creating Numpy Array from QByteArray (QgsRasterBlock.data()) and vice versa (QGIS3) ...
Why does Python start at index 1 when iterating an array backwards?
Why did the IBM 650 use bi-quinary?
Why is "Captain Marvel" translated as male in Portugal?
What does '1 unit of lemon juice' mean in a grandma's drink recipe?
How does cp -a work
Single word antonym of "flightless"
Check which numbers satisfy the condition [A*B*C = A! + B! + C!]
Is 1 ppb equal to 1 μg/kg?
IndentationError when pasting code in Python 3 interpreter mode
How can I fade player when goes inside or outside of the area?
How do I keep my slimes from escaping their pens?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
What are the pros and cons of Aerospike nosecones?
Antler Helmet: Can it work?
Should gear shift center itself while in neutral?
Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?
Bonus calculation: Am I making a mountain out of a molehill?
Why is black pepper both grey and black?
Does the Giant Rocktopus have a Swim Speed?
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
Is high blood pressure ever a symptom attributable solely to dehydration?
How widely used is the term Treppenwitz? Is it something that most Germans know?
List *all* the tuples!
What happens to sewage if there is no river near by?
PyQGIS Creating Numpy Array from QByteArray (QgsRasterBlock.data()) and vice versa (QGIS3)
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I read that handling the pixel values in the QgsRasterBlock object as QByteArrays and creating numpy arrays directly from the QByteArrays is possible and efficient (as compared to the method described below).
So my first question: Is this true?
My second question: What does the numpy function to create an array from QByteArray look like? And which function can I use to go back again?
Context:
I am looking for a way to convert the values contained in a QgsRasterLayer object to a numpy array and vice versa without using any GDAL methods.
To obtain the numpy array I go through QgsRasterDataProvider to QgsRasterBlock and then read the values into a numpy array through the QgsRasterBlock.value(i,j) method. This is not very elegant, but runs in an acceptable time.
Analogously - after working with the numpy array - I change the values in the QgsRasterBlock through the QgsRasterBlock.setValue(i, j, value) method, which takes forever and is not acceptable for my application... so I am looking for an alternative!
pyqgis numpy pyqgis-3
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I read that handling the pixel values in the QgsRasterBlock object as QByteArrays and creating numpy arrays directly from the QByteArrays is possible and efficient (as compared to the method described below).
So my first question: Is this true?
My second question: What does the numpy function to create an array from QByteArray look like? And which function can I use to go back again?
Context:
I am looking for a way to convert the values contained in a QgsRasterLayer object to a numpy array and vice versa without using any GDAL methods.
To obtain the numpy array I go through QgsRasterDataProvider to QgsRasterBlock and then read the values into a numpy array through the QgsRasterBlock.value(i,j) method. This is not very elegant, but runs in an acceptable time.
Analogously - after working with the numpy array - I change the values in the QgsRasterBlock through the QgsRasterBlock.setValue(i, j, value) method, which takes forever and is not acceptable for my application... so I am looking for an alternative!
pyqgis numpy pyqgis-3
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I read that handling the pixel values in the QgsRasterBlock object as QByteArrays and creating numpy arrays directly from the QByteArrays is possible and efficient (as compared to the method described below).
So my first question: Is this true?
My second question: What does the numpy function to create an array from QByteArray look like? And which function can I use to go back again?
Context:
I am looking for a way to convert the values contained in a QgsRasterLayer object to a numpy array and vice versa without using any GDAL methods.
To obtain the numpy array I go through QgsRasterDataProvider to QgsRasterBlock and then read the values into a numpy array through the QgsRasterBlock.value(i,j) method. This is not very elegant, but runs in an acceptable time.
Analogously - after working with the numpy array - I change the values in the QgsRasterBlock through the QgsRasterBlock.setValue(i, j, value) method, which takes forever and is not acceptable for my application... so I am looking for an alternative!
pyqgis numpy pyqgis-3
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I read that handling the pixel values in the QgsRasterBlock object as QByteArrays and creating numpy arrays directly from the QByteArrays is possible and efficient (as compared to the method described below).
So my first question: Is this true?
My second question: What does the numpy function to create an array from QByteArray look like? And which function can I use to go back again?
Context:
I am looking for a way to convert the values contained in a QgsRasterLayer object to a numpy array and vice versa without using any GDAL methods.
To obtain the numpy array I go through QgsRasterDataProvider to QgsRasterBlock and then read the values into a numpy array through the QgsRasterBlock.value(i,j) method. This is not very elegant, but runs in an acceptable time.
Analogously - after working with the numpy array - I change the values in the QgsRasterBlock through the QgsRasterBlock.setValue(i, j, value) method, which takes forever and is not acceptable for my application... so I am looking for an alternative!
pyqgis numpy pyqgis-3
pyqgis numpy pyqgis-3
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 mins ago
jo11hejo11he
11
11
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
jo11he is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
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
});
}
});
jo11he is a new contributor. Be nice, and check out our Code of Conduct.
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%2fgis.stackexchange.com%2fquestions%2f318914%2fpyqgis-creating-numpy-array-from-qbytearray-qgsrasterblock-data-and-vice-ver%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
jo11he is a new contributor. Be nice, and check out our Code of Conduct.
jo11he is a new contributor. Be nice, and check out our Code of Conduct.
jo11he is a new contributor. Be nice, and check out our Code of Conduct.
jo11he is a new contributor. Be nice, and check out our Code of Conduct.
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.
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%2fgis.stackexchange.com%2fquestions%2f318914%2fpyqgis-creating-numpy-array-from-qbytearray-qgsrasterblock-data-and-vice-ver%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