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?

3
  • 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: gis.stackexchange.com/questions/349585/reprojecting-qgspointxy or here: docs.qgis.org/3.22/en/docs/pyqgis_developer_cookbook/…
    – Taras
    Commented Dec 7, 2021 at 8: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
    Commented Dec 7, 2021 at 8: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
    Commented Dec 7, 2021 at 9:22

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.