Skip to content
Permalink
Browse files

fixing indentation?

  • Loading branch information
ghtmtt committed Jul 11, 2018
1 parent 5507c34 commit 22d7b6c5d0535d0c0241dc2175fce83dd661357c
@@ -76,7 +76,6 @@ def initAlgorithm(self, config=None):
)
)


self.addParameter(
QgsProcessingParameterMultipleLayers(
self.RASTERCOPY,
@@ -116,15 +115,12 @@ def processAlgorithm(self, parameters, context, feedback):
for i in sampled_rasters:
for b in range(i.bandCount()):
raster_fields.append(QgsField(
i.name() + str('_{}'.format(b+1)),
QVariant.Double)
i.name() + str('_{}'.format(b + 1)), QVariant.Double)
)


# combine all the vector fields
out_fields = QgsProcessingUtils.combineFields(source_fields, raster_fields)


(sink, dest_id) = self.parameterAsSink(
parameters,
self.OUTPUT,
@@ -134,7 +130,6 @@ def processAlgorithm(self, parameters, context, feedback):
source.sourceCrs()
)


if sink is None:
raise QgsProcessingException(self.invalidSinkError(parameters, self.OUTPUT))

@@ -147,25 +142,22 @@ def processAlgorithm(self, parameters, context, feedback):

attrs = i.attributes()

if rr.bandCount() >1:
if rr.bandCount() > 1:

for b in range(rr.bandCount()):
attrs.append(
rr.dataProvider().identify(i.geometry().asPoint(),
QgsRaster.IdentifyFormatValue).results()[b+1]
QgsRaster.IdentifyFormatValue).results()[b + 1]
)


attrs.append(
rr.dataProvider().identify(i.geometry().asPoint(),
QgsRaster.IdentifyFormatValue).results()[1]
QgsRaster.IdentifyFormatValue).results()[1]
)


i.setAttributes(attrs)

sink.addFeature(i, QgsFeatureSink.FastInsert)
feedback.setProgress(int(n * total))


return {self.OUTPUT: dest_id}
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ sampling_points.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>18.66907337319408</gml:X><gml:Y>45.78164855298462</gml:Y></gml:coord>
<gml:coord><gml:X>18.69811881698106</gml:X><gml:Y>45.80559559440474</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:sampling_points fid="sampling_points.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6716225743775,45.8055955944047</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6825918643183,45.8040506239905</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6905484619515,45.7973300026888</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6882310063302,45.7870559494343</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6778024560343,45.7857427245822</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6833643495254,45.7918453577183</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6974235802947,45.8035871328663</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6981188169811,45.7852019849373</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6690733731941,45.7816485529846</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_points fid="sampling_points.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6707728406497,45.7915363636355</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:sampling_points>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,23 @@
<?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="sampling_points" type="ogr:sampling_points_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="sampling_points_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

This file was deleted.

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ sampling_raster.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>18.6690733731941</gml:X><gml:Y>45.7816485529846</gml:Y></gml:coord>
<gml:coord><gml:X>18.6981188169811</gml:X><gml:Y>45.8055955944047</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6716225743775,45.8055955944047</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>91.9159927368164</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6825918643183,45.8040506239905</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>88.300178527832</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6905484619515,45.7973300026888</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>182.22380065918</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6882310063302,45.7870559494343</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>126.56761932373</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6778024560343,45.7857427245822</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>131.698287963867</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6833643495254,45.7918453577183</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>150</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6974235802947,45.8035871328663</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>123.953346252441</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6981188169811,45.7852019849373</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>188.614822387695</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6690733731941,45.7816485529846</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>168.492599487305</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
<gml:featureMember>
<ogr:sampling_raster fid="sampling_points.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>18.6707728406497,45.7915363636355</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:dem_1>96.8800735473633</ogr:dem_1>
</ogr:sampling_raster>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -10,19 +10,12 @@
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="raster_sampling" type="ogr:raster_sampling_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="raster_sampling_Type">
<xs:element name="sampling_raster" type="ogr:sampling_raster_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="sampling_raster_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="id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:long">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="dem_1" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
@@ -5729,10 +5729,10 @@ tests:
type: vector

- algorithm: qgis:rastersampling
name: Test (qgis:rastersampling)
name: Single band raster
params:
INPUT:
name: custom/points_over.shp
name: custom/sampling_points.gml
type: vector
RASTERCOPY:
params:
@@ -5741,8 +5741,12 @@ tests:
type: multi
results:
OUTPUT:
name: expected/raster_sampling.geojson
name: expected/sampling_raster.gml
type: vector
compare:
fields:
fid: skip



# See ../README.md for a description of the file format

0 comments on commit 22d7b6c

Please sign in to comment.
You can’t perform that action at this time.