Automating citation of Data Source in Map?
up vote
4
down vote
favorite
I have 20 thematic maps with different sources like CITY PLANNING OFFICE, ENVIRONMENT OFFICE, AGRICULTURE OFFICE etc.
Since I have many maps, I want to automate the data source citation of my thematic maps by simply having a code or process. I want that each map layout, the data source will change based on the map that is being viewed. This will lessen the burden because I am not having to manually type the data source for each map layout.
I saw someone discussed about variables and it got my hopes high but it didn't work for me because the layer variables cannot be used in text label in map layout. Only the Global and project variables were working.
qgis print-composer layouts expression
New contributor
add a comment |
up vote
4
down vote
favorite
I have 20 thematic maps with different sources like CITY PLANNING OFFICE, ENVIRONMENT OFFICE, AGRICULTURE OFFICE etc.
Since I have many maps, I want to automate the data source citation of my thematic maps by simply having a code or process. I want that each map layout, the data source will change based on the map that is being viewed. This will lessen the burden because I am not having to manually type the data source for each map layout.
I saw someone discussed about variables and it got my hopes high but it didn't work for me because the layer variables cannot be used in text label in map layout. Only the Global and project variables were working.
qgis print-composer layouts expression
New contributor
1
This screenshot looks like QGIS print composer to me, not ArcGIS desktop as your tag suggests. Confirm?
– Jochen Schwarze
yesterday
retagged this accordingly.
– Jochen Schwarze
yesterday
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I have 20 thematic maps with different sources like CITY PLANNING OFFICE, ENVIRONMENT OFFICE, AGRICULTURE OFFICE etc.
Since I have many maps, I want to automate the data source citation of my thematic maps by simply having a code or process. I want that each map layout, the data source will change based on the map that is being viewed. This will lessen the burden because I am not having to manually type the data source for each map layout.
I saw someone discussed about variables and it got my hopes high but it didn't work for me because the layer variables cannot be used in text label in map layout. Only the Global and project variables were working.
qgis print-composer layouts expression
New contributor
I have 20 thematic maps with different sources like CITY PLANNING OFFICE, ENVIRONMENT OFFICE, AGRICULTURE OFFICE etc.
Since I have many maps, I want to automate the data source citation of my thematic maps by simply having a code or process. I want that each map layout, the data source will change based on the map that is being viewed. This will lessen the burden because I am not having to manually type the data source for each map layout.
I saw someone discussed about variables and it got my hopes high but it didn't work for me because the layer variables cannot be used in text label in map layout. Only the Global and project variables were working.
qgis print-composer layouts expression
qgis print-composer layouts expression
New contributor
New contributor
edited yesterday
Jochen Schwarze
6,06331354
6,06331354
New contributor
asked yesterday
kalaw23
211
211
New contributor
New contributor
1
This screenshot looks like QGIS print composer to me, not ArcGIS desktop as your tag suggests. Confirm?
– Jochen Schwarze
yesterday
retagged this accordingly.
– Jochen Schwarze
yesterday
add a comment |
1
This screenshot looks like QGIS print composer to me, not ArcGIS desktop as your tag suggests. Confirm?
– Jochen Schwarze
yesterday
retagged this accordingly.
– Jochen Schwarze
yesterday
1
1
This screenshot looks like QGIS print composer to me, not ArcGIS desktop as your tag suggests. Confirm?
– Jochen Schwarze
yesterday
This screenshot looks like QGIS print composer to me, not ArcGIS desktop as your tag suggests. Confirm?
– Jochen Schwarze
yesterday
retagged this accordingly.
– Jochen Schwarze
yesterday
retagged this accordingly.
– Jochen Schwarze
yesterday
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well):
Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties
function on the right, you may access layer name, feature count and many more, no need for custom functions):
layer_properties(layer_id, 'attribution')
The layer_id
must be in single quotes, you may obtain it either from the layers variables (but you cannot copy and paste it from there) or via the python console (with the desired layer selected):
iface.activeLayer().id()
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
add a comment |
up vote
2
down vote
If the source is the layer name you could define your own custom function and use it as an expression in the label content dialog.
Click "Insert an Expression..." in the Main Properties of the label. Select the function editor tab and paste the following. Click "Save and Load Functions".
# Be sure to import iface from qgis.utils
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
@qgsfunction(args='auto', group='Custom')
def get_layer_name(feature, parent):
return qgis.utils.iface.activeLayer().name()
Then back on the Expression tab of the "Insert an Expression..." dialog double click the get_layer_name
function (under Custom) to add it to your expression.
After clicking OK, the name of active layer in your main QGIS window will appear in your label. You will have to refresh the Layout Manager to update the name after a different layer is selected.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well):
Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties
function on the right, you may access layer name, feature count and many more, no need for custom functions):
layer_properties(layer_id, 'attribution')
The layer_id
must be in single quotes, you may obtain it either from the layers variables (but you cannot copy and paste it from there) or via the python console (with the desired layer selected):
iface.activeLayer().id()
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
add a comment |
up vote
3
down vote
You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well):
Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties
function on the right, you may access layer name, feature count and many more, no need for custom functions):
layer_properties(layer_id, 'attribution')
The layer_id
must be in single quotes, you may obtain it either from the layers variables (but you cannot copy and paste it from there) or via the python console (with the desired layer selected):
iface.activeLayer().id()
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
add a comment |
up vote
3
down vote
up vote
3
down vote
You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well):
Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties
function on the right, you may access layer name, feature count and many more, no need for custom functions):
layer_properties(layer_id, 'attribution')
The layer_id
must be in single quotes, you may obtain it either from the layers variables (but you cannot copy and paste it from there) or via the python console (with the desired layer selected):
iface.activeLayer().id()
You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well):
Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties
function on the right, you may access layer name, feature count and many more, no need for custom functions):
layer_properties(layer_id, 'attribution')
The layer_id
must be in single quotes, you may obtain it either from the layers variables (but you cannot copy and paste it from there) or via the python console (with the desired layer selected):
iface.activeLayer().id()
edited yesterday
answered yesterday
Jochen Schwarze
6,06331354
6,06331354
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
add a comment |
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
Thanks for this, Jochen. Very useful! I wasn't aware of this when I wrote my answer. Just to let you know, you can copy the layer_id from the variables by selecting it and using Ctrl + C (right-click does not work).
– Matt Needle
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
thx, we all keep on learning! ;-)
– Jochen Schwarze
yesterday
add a comment |
up vote
2
down vote
If the source is the layer name you could define your own custom function and use it as an expression in the label content dialog.
Click "Insert an Expression..." in the Main Properties of the label. Select the function editor tab and paste the following. Click "Save and Load Functions".
# Be sure to import iface from qgis.utils
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
@qgsfunction(args='auto', group='Custom')
def get_layer_name(feature, parent):
return qgis.utils.iface.activeLayer().name()
Then back on the Expression tab of the "Insert an Expression..." dialog double click the get_layer_name
function (under Custom) to add it to your expression.
After clicking OK, the name of active layer in your main QGIS window will appear in your label. You will have to refresh the Layout Manager to update the name after a different layer is selected.
add a comment |
up vote
2
down vote
If the source is the layer name you could define your own custom function and use it as an expression in the label content dialog.
Click "Insert an Expression..." in the Main Properties of the label. Select the function editor tab and paste the following. Click "Save and Load Functions".
# Be sure to import iface from qgis.utils
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
@qgsfunction(args='auto', group='Custom')
def get_layer_name(feature, parent):
return qgis.utils.iface.activeLayer().name()
Then back on the Expression tab of the "Insert an Expression..." dialog double click the get_layer_name
function (under Custom) to add it to your expression.
After clicking OK, the name of active layer in your main QGIS window will appear in your label. You will have to refresh the Layout Manager to update the name after a different layer is selected.
add a comment |
up vote
2
down vote
up vote
2
down vote
If the source is the layer name you could define your own custom function and use it as an expression in the label content dialog.
Click "Insert an Expression..." in the Main Properties of the label. Select the function editor tab and paste the following. Click "Save and Load Functions".
# Be sure to import iface from qgis.utils
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
@qgsfunction(args='auto', group='Custom')
def get_layer_name(feature, parent):
return qgis.utils.iface.activeLayer().name()
Then back on the Expression tab of the "Insert an Expression..." dialog double click the get_layer_name
function (under Custom) to add it to your expression.
After clicking OK, the name of active layer in your main QGIS window will appear in your label. You will have to refresh the Layout Manager to update the name after a different layer is selected.
If the source is the layer name you could define your own custom function and use it as an expression in the label content dialog.
Click "Insert an Expression..." in the Main Properties of the label. Select the function editor tab and paste the following. Click "Save and Load Functions".
# Be sure to import iface from qgis.utils
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
@qgsfunction(args='auto', group='Custom')
def get_layer_name(feature, parent):
return qgis.utils.iface.activeLayer().name()
Then back on the Expression tab of the "Insert an Expression..." dialog double click the get_layer_name
function (under Custom) to add it to your expression.
After clicking OK, the name of active layer in your main QGIS window will appear in your label. You will have to refresh the Layout Manager to update the name after a different layer is selected.
edited yesterday
answered yesterday
Matt Needle
17913
17913
add a comment |
add a comment |
kalaw23 is a new contributor. Be nice, and check out our Code of Conduct.
kalaw23 is a new contributor. Be nice, and check out our Code of Conduct.
kalaw23 is a new contributor. Be nice, and check out our Code of Conduct.
kalaw23 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f304822%2fautomating-citation-of-data-source-in-map%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
This screenshot looks like QGIS print composer to me, not ArcGIS desktop as your tag suggests. Confirm?
– Jochen Schwarze
yesterday
retagged this accordingly.
– Jochen Schwarze
yesterday