Skip to content

Commit

Permalink
[FEATURE][processing] Add "random points on lines" algorithm
Browse files Browse the repository at this point in the history
The Random points on lines algorithm supplements the existing "Random points along line" algorithm, and will prove to be more useful to the majority of users than the "original".

Features:

The points are distributed randomly over the lines based on "along the line" distance, meaning that the distribution of the points will be flat over the length of the line (each place on the feature has the same probability of being "hit"). 

The Random points along line, on the other hand, uses a line segment based approach, meaning that the density will depend on the segment length (short segments will have a higher point density than longer ones).
  • Loading branch information
havatv authored Mar 30, 2020
1 parent 3a74358 commit c774ade
Show file tree
Hide file tree
Showing 11 changed files with 838 additions and 0 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<file>themes/default/algorithms/mAlgorithmNearestNeighbour.svg</file>
<file>themes/default/algorithms/mAlgorithmNetworkAnalysis.svg</file>
<file>themes/default/algorithms/mAlgorithmPolygonToLine.svg</file>
<file>themes/default/algorithms/mAlgorithmRandomPointsOnLines.svg</file>
<file>themes/default/algorithms/mAlgorithmRandomPointsWithinPolygon.svg</file>
<file>themes/default/algorithms/mAlgorithmRandomPointsWithinExtent.svg</file>
<file>themes/default/algorithms/mAlgorithmRegularPoints.svg</file>
Expand Down
120 changes: 120 additions & 0 deletions images/themes/default/algorithms/mAlgorithmRandomPointsOnLines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ randompointsonlines.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-0.6048972614132321</gml:X><gml:Y>-1</gml:Y></gml:coord>
<gml:coord><gml:X>5.5706404884031</gml:X><gml:Y>2.983529974375954</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.680375434309419,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>0</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.211234146361814,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>1</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.566198447517212,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>2</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.596880066952147,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>3</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.823294715873569,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>4</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.604897261413232,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>5</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.329554488570222,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>6</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.536459189623808,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>7</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.444450578393624,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>8</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.107939911590861,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>9</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.10">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.63030422879655,1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>10</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.11">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.02166180257582,2.26721545068545</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>11</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.12">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.24573385250727,1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>12</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.13">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.7532568994615,1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>13</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.14">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.00278822202651,1.16311098855098</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>14</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.15">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.00489146772082,1.28615086166781</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>15</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.16">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.02126252335406,2.24385761621232</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>16</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.17">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.01650061531363,1.96528599584743</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>17</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.18">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.48357073824498,1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>18</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.19">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.02294016604118,2.3419997134092</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>19</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.20">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.0,0.148289222714595</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>20</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.21">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.20958450135476,2.0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>21</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.22">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.0,1.24842025927014</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>22</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.23">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.79936109924074,2.98352997437595</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>23</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.24">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.0,1.42533776707812</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>24</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.25">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.0,2.64746304269474</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>25</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.26">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.0,1.1807269654443</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>26</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.27">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.0,0.989853181150094</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>27</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.28">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.5706404884031,2.94703455703008</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>28</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
<gml:featureMember>
<ogr:randompointsonlines fid="randompointsonlines.29">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.0,1.98552220048164</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:rand_point_id>29</ogr:rand_point_id>
</ogr:randompointsonlines>
</gml:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="randompointsonlines" type="ogr:randompointsonlines_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="randompointsonlines_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="rand_point_id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:long">
<xs:totalDigits value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Loading

0 comments on commit c774ade

Please sign in to comment.