1

I am working on a project to identify weeds. I used the grid to separate the area. Each cell is marked weed or no weed. I would like to get the GPS of the center of each cell with a weed in it. Does anyone have any idea how to do this? We ultimately hope to upload the coordinates to a drone and have it spray each marked grid. enter image description here

6
  • 2
    I used the grid to separate the area. How is the grid defined? I would like to get the GPS of the center of each cell I assume you mean coordinate?
    – nmtoken
    Oct 25 '19 at 17:45
  • Defined? Not sure. I just used the grid tool 1 X 1 meter. The spray area of the drone is 5 X 5 m so I will use that in the future. Coordinate yes. I almost got it. I used "extract feature by selection" on the grid with the weed points using NUMPINTS > 0. This selected all grids with weeds present. Then I added centroid to each of the selected grids. Then I used the "Add coordinates to points" tool. The cooridnates are in some weird format. Is there a way to change it to GPS? Thank you.
    – Dan Olson
    Oct 25 '19 at 17:52
  • 1
    By defined I meant ~ Do you know the geographic coordinates of the bounding box of the grid, was/is it based on some projection, how big are the cells (OK you answered that).~ You should edit the question to add the details
    – nmtoken
    Oct 25 '19 at 17:57
  • 1
    You mean you want to know the latitude and longitude of the points you have now created? If so, what software are you using?
    – GBG
    Oct 25 '19 at 18:03
  • Using QGIS. The point is right in the center of each cell with a weed in it. I would like to get latitude and longitude yeah. Thank you
    – Dan Olson
    Oct 25 '19 at 18:20
1

You have to use: QgsCoordinateTransform(src_crs,dest_crs, QgsProject.instance()) where src_crs is the QgsCoordinateReferenceSystem of you layer and dest_crs the QgsCoordinateReferenceSystem of WGS84.

1
  • Im new to QGIS. Can you give me simple step by step instructions? Is that a tool I should be looking for?
    – Dan Olson
    Oct 28 '19 at 13:01
0

Hope this helps:

prj = QgsProject.instance()
dest_crs= QgsCoordinateReferenceSystem("EPSG:4326")#WGS84
src_crs= prj.crs()
transformation = QgsCoordinateTransform(src_crs, dest_crs, prj)

yourPoint = QgsPoint(QgsPoint(994369,515288))#example coords
yourPoint.transform(transformation)
print(yourPoint.x(), "/", yourPoint.y())

will return 21.3538857925002 / 48.260682704154206

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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