1

I want to clip a polygon layer to an extent of another polyline layer. I want to use extract layer by extent processing tool, I want to automatically fetch the extent of my polyline layer along with EPSG, but somehow the extent values are not matching with the degree decimal values I want.

enter image description here

As you can see the xmin, xmax values start with 525.. something, but when I use this code to fetch my polyline layer extent the values come as -

enter image description here

layer = QgsVectorLayer(polyline, 'polyline', 'ogr')
ext = layer.extent()
xmin = ext.xMinimum()
xmax = ext.xMaximum()
ymin = ext.yMinimum()
ymax = ext.yMaximum()
coords = "%f,%f,%f,%f" % (xmin, xmax, ymin, ymax)
print("coords - " + str(coords))

What am I missing here how to get the same 525.. values as in processing tool.

My project has a defined Projection system which is same as the layer's coordinate system. epsg - 2157 enter image description here

3
  • 1
    Your data is probably using a projected coordinate reference system versus the geographic coordinate reference system you want. Does the layer have a defined CRS? If not, where's the data located?
    – mkennedy
    Commented Jan 29, 2022 at 20:43
  • @mkennedy yes it has a defined coordinate system it has epsg - 2157 - IRENET95/ Irish Tranaverse Mercator Commented Jan 31, 2022 at 4:53
  • Oh, I see. I don't know why you're getting a bad string. I would try copying just one value into the string and see if that works.
    – mkennedy
    Commented Jan 31, 2022 at 17:01

0

Your Answer

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