3

I need to define a regular grid of points in QGIS, which later I'll edit further based on its interaction with some data. Up until now, I was using the "Vector Grid" of the same Vector Research Tools, because by using "Regular Points" I had some complications. Then, I simply took the data of the polygons and computed their center later in Excel.

A few days ago, I managed to get the desired interaction with Regular Points, which I'd prefer to work with. The only problem is that, for some reason, QGIS won't let me select a distance low enough for my needs. I'm attaching a screenshot of the tool: enter image description here

The CRS I'm using is WGS84 (EPSG: 4326, WGS 84). I would need a distance in degrees of 0,000010, which is what I was using before with the polygons, but the value in the screenshot is the lowest it will go. The points should be closer than 1.5 meters, but exact distance is not required (i.e. both 0.5 meters and 1 meter are fine).

Any ideas as to how to lower the value? I don't get why this tool has a lower limit, while the polygon one doesn't. Sorry if this is trivial, I searched for a similar question but found none.

1 Answer 1

2

One of the beauties of open-source software is that we can edit the source :)

So if we find the algorithm's file, we can edit it to change the limits. It should be located in your QGIS directory, for example:

C:/Program Files/QGIS 2.18/apps/qgis/python/plugins/processing/algs/qgis/RegularPoints.py

If we examine this, we can see that in line 66, the limits are set (minimum, maximum, default):

RegularPoints script

So let's change it to what we need:

RegularPoints script amended

Then save the changes. (Note that if you do not have permission, you can create a copy of the file with the changes, delete the original and move the copied file over.)

Restart QGIS and hopefully you should be able to set it to the value you desire:

Result

5
  • Thank you for the answer! Unfortunately, I have some problems when doing this. Firstly, my RegularPoints.py file doesn't have a line where the limits are set, half of the code in your image is missing (even though I have 2.18 Las Palmas installed). Secondly, I just thought I'd add id myself, but, alas, I don't have the necessary administrator rights to paste it. Now I have two questions: - If I get the IT admin. to allow me to do this, will it work, even though the file is missing a lot of the code you're showing? - Is there any other fix that doesn't require editing source code? Thanks again!
    – Haekoth
    Jun 13, 2017 at 11:24
  • @Haekoth - Yes, the images do not contain the entire code, it was only to highlight which part was needed to change. Are you sure your RegularPoints.py file does not have the def defineCharacteristics(self): function? Secondly, you should not need to get IT admin involved. Simply copy the file over to Desktop, edit and save the copy, delete the original then move the copy in its place. Thirdly, you can use some python code to run the tool from the Python Console or from a script :)
    – Joseph
    Jun 13, 2017 at 11:34
  • Sorry, I must have expressed myself badly. I meant that MY file is missing half the code on your image. It does have the defineCharacteristics(self) function, but it is not nearly as long as yours. About the permits issue, I tried doing as you suggested (just copy the file, modify it, and then replace it), but Windows requests an authorization from me, which I cannot provide (i.e. the good ol' "The requested operation requires elevation"). I'll try to do the Python option, although I never used it, but I think it's similar to Matlab. I'll update you. Thanks again!
    – Haekoth
    Jun 13, 2017 at 12:01
  • 1
    Well, some higher priority task popped up and I have to focus on that for the moment, however, I think these are about all the solutions possible for this problem, so I'll accept the answer. Thanks for your help!
    – Haekoth
    Jun 14, 2017 at 8:49
  • @Haekoth - Most welcome, hopefully this problem will be resolved if you come back to it :)
    – Joseph
    Jun 14, 2017 at 9:31

Your Answer

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

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