How to get the map canvas CRS in EPSG code? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Why are xy coordinates displayed in my WGS84 project instead of lat/lon?Using GeoBrain WCS4DEM in QGIS?How to determine bounding box of current qgis 'map canvas extent' from the python consoleCRS of QGIS bounding boxesRemove QGIS watermark on QGIS Server tilesHow to load multiple vector layers into QGIS' map canvas using python scripting?Which EPGS code is the actual CRS in this GeoPDF?QGIS - Layers with CRS EPSG:3857 incompatible with Google street mapPrinting plugin data on QGIS map canvasHow to set project CRS with plugin (sqlite layer)?
How to run automated tests after each commit?
What does Turing mean by this statement?
Antipodal Land Area Calculation
What order were files/directories output in dir?
Where is the Data Import Wizard Error Log
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
Random body shuffle every night—can we still function?
C's equality operator on converted pointers
Should a wizard buy fine inks every time he want to copy spells into his spellbook?
How much damage would a cupful of neutron star matter do to the Earth?
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
How were pictures turned from film to a big picture in a picture frame before digital scanning?
What do you call the main part of a joke?
Putting class ranking in CV, but against dept guidelines
Is it possible to force a specific program to remain in memory after closing it?
In musical terms, what properties are varied by the human voice to produce different words / syllables?
Is it fair for a professor to grade us on the possession of past papers?
Co-worker has annoying ringtone
What is "gratricide"?
How many morphisms from 1 to 1+1 can there be?
How could we fake a moon landing now?
What is Adi Shankara referring to when he says "He has Vajra marks on his feet"?
How do I find out the mythology and history of my Fortress?
A letter with no particular backstory
How to get the map canvas CRS in EPSG code?
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Why are xy coordinates displayed in my WGS84 project instead of lat/lon?Using GeoBrain WCS4DEM in QGIS?How to determine bounding box of current qgis 'map canvas extent' from the python consoleCRS of QGIS bounding boxesRemove QGIS watermark on QGIS Server tilesHow to load multiple vector layers into QGIS' map canvas using python scripting?Which EPGS code is the actual CRS in this GeoPDF?QGIS - Layers with CRS EPSG:3857 incompatible with Google street mapPrinting plugin data on QGIS map canvasHow to set project CRS with plugin (sqlite layer)?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This is probably a simple request but I cannot find a way around it:
how can I read from python the map canvas CRS?
I know how to set it up:
canvas = self.iface.mapCanvas()
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(QgsCoordinateReferenceSystem(EPSG_CODE))
But I want to do that ONLY if I need it:
canvas = self.iface.mapCanvas()
canCRS = (????)
wgsCRS = QgsCoordinateReferenceSystem(4326)
bBox = canvas.extent()
if canCRS == wgsCRS:
# get get lat long of canvas extent
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
else:
# set map canvas CRS and get lat long of the extent
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(wgsCRS)
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
How do I get the map canvas CRS in EPSG code so I can compare it with QgsCoordinateReferenceSystem(4326)? Which method should I use?
qgis pyqgis
add a comment |
This is probably a simple request but I cannot find a way around it:
how can I read from python the map canvas CRS?
I know how to set it up:
canvas = self.iface.mapCanvas()
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(QgsCoordinateReferenceSystem(EPSG_CODE))
But I want to do that ONLY if I need it:
canvas = self.iface.mapCanvas()
canCRS = (????)
wgsCRS = QgsCoordinateReferenceSystem(4326)
bBox = canvas.extent()
if canCRS == wgsCRS:
# get get lat long of canvas extent
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
else:
# set map canvas CRS and get lat long of the extent
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(wgsCRS)
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
How do I get the map canvas CRS in EPSG code so I can compare it with QgsCoordinateReferenceSystem(4326)? Which method should I use?
qgis pyqgis
The first axis (x) of EPSG:4326 is lat not lon ~ epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326
– nmtoken
Mar 22 at 13:13
add a comment |
This is probably a simple request but I cannot find a way around it:
how can I read from python the map canvas CRS?
I know how to set it up:
canvas = self.iface.mapCanvas()
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(QgsCoordinateReferenceSystem(EPSG_CODE))
But I want to do that ONLY if I need it:
canvas = self.iface.mapCanvas()
canCRS = (????)
wgsCRS = QgsCoordinateReferenceSystem(4326)
bBox = canvas.extent()
if canCRS == wgsCRS:
# get get lat long of canvas extent
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
else:
# set map canvas CRS and get lat long of the extent
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(wgsCRS)
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
How do I get the map canvas CRS in EPSG code so I can compare it with QgsCoordinateReferenceSystem(4326)? Which method should I use?
qgis pyqgis
This is probably a simple request but I cannot find a way around it:
how can I read from python the map canvas CRS?
I know how to set it up:
canvas = self.iface.mapCanvas()
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(QgsCoordinateReferenceSystem(EPSG_CODE))
But I want to do that ONLY if I need it:
canvas = self.iface.mapCanvas()
canCRS = (????)
wgsCRS = QgsCoordinateReferenceSystem(4326)
bBox = canvas.extent()
if canCRS == wgsCRS:
# get get lat long of canvas extent
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
else:
# set map canvas CRS and get lat long of the extent
canvas.mapRenderer().setProjectionsEnabled(True)
canvas.mapRenderer().setDestinationCrs(wgsCRS)
lon = bBox.xMinimum()
lat = bBox.yMinimum()
lonMax = bBox.xMaximum()
latMax = bBox.yMaximum()
return lon, lat, lonMax, latMax
How do I get the map canvas CRS in EPSG code so I can compare it with QgsCoordinateReferenceSystem(4326)? Which method should I use?
qgis pyqgis
qgis pyqgis
edited May 20 '14 at 18:09
underdark♦
69.3k13178351
69.3k13178351
asked May 20 '14 at 12:20
micmic
889
889
The first axis (x) of EPSG:4326 is lat not lon ~ epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326
– nmtoken
Mar 22 at 13:13
add a comment |
The first axis (x) of EPSG:4326 is lat not lon ~ epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326
– nmtoken
Mar 22 at 13:13
The first axis (x) of EPSG:4326 is lat not lon ~ epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326
– nmtoken
Mar 22 at 13:13
The first axis (x) of EPSG:4326 is lat not lon ~ epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326
– nmtoken
Mar 22 at 13:13
add a comment |
2 Answers
2
active
oldest
votes
Try:
canvas.mapRenderer().destinationCrs().authid()
That will return the map canvases' current crs as an epsg code
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
add a comment |
In QGIS3 API changed:
iface.mapCanvas().mapSettings().destinationCrs().authid()
'EPSG:3045'
add a comment |
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
);
);
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%2f97484%2fhow-to-get-the-map-canvas-crs-in-epsg-code%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try:
canvas.mapRenderer().destinationCrs().authid()
That will return the map canvases' current crs as an epsg code
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
add a comment |
Try:
canvas.mapRenderer().destinationCrs().authid()
That will return the map canvases' current crs as an epsg code
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
add a comment |
Try:
canvas.mapRenderer().destinationCrs().authid()
That will return the map canvases' current crs as an epsg code
Try:
canvas.mapRenderer().destinationCrs().authid()
That will return the map canvases' current crs as an epsg code
answered May 20 '14 at 12:43
ndawsonndawson
20.2k22944
20.2k22944
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
add a comment |
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
Yes, thanks @ndawson, that did it! The only thing that needs to be change is the comparison in canCRS == wgsCRS..authid()
– mic
May 20 '14 at 13:39
add a comment |
In QGIS3 API changed:
iface.mapCanvas().mapSettings().destinationCrs().authid()
'EPSG:3045'
add a comment |
In QGIS3 API changed:
iface.mapCanvas().mapSettings().destinationCrs().authid()
'EPSG:3045'
add a comment |
In QGIS3 API changed:
iface.mapCanvas().mapSettings().destinationCrs().authid()
'EPSG:3045'
In QGIS3 API changed:
iface.mapCanvas().mapSettings().destinationCrs().authid()
'EPSG:3045'
answered Apr 11 at 13:49
PeterPeter
35136
35136
add a comment |
add a comment |
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%2f97484%2fhow-to-get-the-map-canvas-crs-in-epsg-code%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
The first axis (x) of EPSG:4326 is lat not lon ~ epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326
– nmtoken
Mar 22 at 13:13