2626 QgsProcessingParameterFeatureSource ,
2727 QgsProcessingParameterRasterLayer ,
2828 QgsProcessingParameterEnum ,
29- QgsProcessingParameterRasterLayer ,
30- QgsProcessingParameterEnum ,
3129 QgsProcessingParameterNumber ,
3230 QgsFields ,
33- QgsFields ,
3431 QgsField ,
3532 QgsFeature ,
3633 QgsGeometry ,
3734 QgsPointXY ,
3835 QgsVectorLayer ,
3936 QgsWkbTypes ,
40- QgsCoordinateReferenceSystem ,
41- QgsVectorLayer ,
42- QgsWkbTypes ,
4337 QgsCoordinateReferenceSystem
4438)
4539# Internal imports
@@ -167,17 +161,12 @@ def processAlgorithm(
167161 geology = qgsLayerToGeoDataFrame (geology )
168162 spatial_data_gdf = qgsLayerToGeoDataFrame (spatial_data )
169163 dtm_gdal = gdal .Open (dtm .source ()) if dtm is not None and dtm .isValid () else None
170- spatial_data_gdf = qgsLayerToGeoDataFrame (spatial_data )
171- dtm_gdal = gdal .Open (dtm .source ()) if dtm is not None and dtm .isValid () else None
172164
173165 if sampler_type == "Decimator" :
174166 feedback .pushInfo ("Sampling..." )
175167 sampler = SamplerDecimator (decimation = decimation , dtm_data = dtm_gdal , geology_data = geology )
176168 samples = sampler .sample (spatial_data_gdf )
177- sampler = SamplerDecimator (decimation = decimation , dtm_data = dtm_gdal , geology_data = geology )
178- samples = sampler .sample (spatial_data_gdf )
179169
180-
181170 if sampler_type == "Spacing" :
182171 feedback .pushInfo ("Sampling..." )
183172 sampler = SamplerSpacing (spacing = spacing , dtm_data = dtm_gdal , geology_data = geology )
@@ -203,33 +192,6 @@ def processAlgorithm(
203192 crs
204193 )
205194
206- if samples is not None and not samples .empty :
207- for _index , row in samples .iterrows ():
208- feature = QgsFeature (fields )
209-
210- # decimator has z values
211- if 'Z' in samples .columns and pd .notna (row .get ('Z' )):
212- wkt = f"POINT Z ({ row ['X' ]} { row ['Y' ]} { row ['Z' ]} )"
213- feature .setGeometry (QgsGeometry .fromWkt (wkt ))
214- else :
215- #spacing has no z values
216- feature .setGeometry (QgsGeometry .fromPointXY (QgsPointXY (row ['X' ], row ['Y' ])))
217-
218- feature .setAttributes ([
219- str (row .get ('ID' , '' )),
220- float (row .get ('X' , 0 )),
221- float (row .get ('Y' , 0 )),
222- float (row .get ('Z' , 0 )) if pd .notna (row .get ('Z' )) else 0.0 ,
223- str (row .get ('featureId' , '' ))
224- ])
225-
226- sink .addFeature (feature )
227-
228- fields ,
229- QgsWkbTypes .PointZ if 'Z' in (samples .columns if samples is not None else []) else QgsWkbTypes .Point ,
230- crs
231- )
232-
233195 if samples is not None and not samples .empty :
234196 for _index , row in samples .iterrows ():
235197 feature = QgsFeature (fields )
0 commit comments