4

I am creating a QgsRectangle like this:

llc = QgsPointXY(319660,4624088)       # lower left corner in UTM
urc = QgsPointXY(396425,4742843)       # upper right corner in UTM
aoi = QgsRectangle(llc,urc)

But how do I tell him the correct crs of these points? Can I pass the EPSG somehow?

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
PDistl
  • 95
  • 6
  • 1
    IMHO it is not possible. The QgsPointXY class creates a point either from another point or from x,y coordinates. If you need you can reproject as shown here: https://gis.stackexchange.com/questions/349585/reprojecting-qgspointxy or here: https://docs.qgis.org/3.22/en/docs/pyqgis_developer_cookbook/crs.html#crs-transformation – Taras Dec 07 '21 at 08:41
  • Thanks. Is there any other way to define the extent in the raster calculator by Xmin, Xmax, Ymin and Ymax? I use above defined aoi as extent: QgsRasterCalculator('ras@1', output, 'GTiff', aoi, 15353, 23751, entries) – PDistl Dec 07 '21 at 08:48
  • Thank you Ben, I opened a new question to give full context and full code since the problem seems to be in a different part. – PDistl Dec 07 '21 at 09:22

1 Answers1

3

No. You cannot pass an EPSG to QgsPointXY. None of the constructor methods of it allows to define a CRS. Also, you cannot set a CRS after creating a point.

In addition, a CRS cannot be defined for QgsGeometry and QgsFeature, too.

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389