mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	This algorithm swaps the X and Y coordinate values in input geometries. It can be used to repair geometries which have accidentally had their latitude and longitude values reversed.
		
			
				
	
	
		
			59 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="utf-8" ?>
 | 
						|
<ogr:FeatureCollection
 | 
						|
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
						|
     xsi:schemaLocation="http://ogr.maptools.org/ swap_xy.xsd"
 | 
						|
     xmlns:ogr="http://ogr.maptools.org/"
 | 
						|
     xmlns:gml="http://www.opengis.net/gml">
 | 
						|
  <gml:boundedBy>
 | 
						|
    <gml:Box>
 | 
						|
      <gml:coord><gml:X>-3</gml:X><gml:Y>-1</gml:Y></gml:coord>
 | 
						|
      <gml:coord><gml:X>6</gml:X><gml:Y>10</gml:Y></gml:coord>
 | 
						|
    </gml:Box>
 | 
						|
  </gml:boundedBy>
 | 
						|
                                                                                                                                                             
 | 
						|
  <gml:featureMember>
 | 
						|
    <ogr:swap_xy fid="polys.0">
 | 
						|
      <ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-1,-1 3,-1 3,3 2,3 2,2 -1,2 -1,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
 | 
						|
      <ogr:name>aaaaa</ogr:name>
 | 
						|
      <ogr:intval>33</ogr:intval>
 | 
						|
      <ogr:floatval>44.123456</ogr:floatval>
 | 
						|
    </ogr:swap_xy>
 | 
						|
  </gml:featureMember>
 | 
						|
  <gml:featureMember>
 | 
						|
    <ogr:swap_xy fid="polys.1">
 | 
						|
      <ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 4,6 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
 | 
						|
      <ogr:name>Aaaaa</ogr:name>
 | 
						|
      <ogr:intval>-33</ogr:intval>
 | 
						|
      <ogr:floatval>0</ogr:floatval>
 | 
						|
    </ogr:swap_xy>
 | 
						|
  </gml:featureMember>
 | 
						|
  <gml:featureMember>
 | 
						|
    <ogr:swap_xy fid="polys.2">
 | 
						|
      <ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,2 6,2 6,3 5,3 5,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
 | 
						|
      <ogr:name>bbaaa</ogr:name>
 | 
						|
      <ogr:floatval>0.123</ogr:floatval>
 | 
						|
    </ogr:swap_xy>
 | 
						|
  </gml:featureMember>
 | 
						|
  <gml:featureMember>
 | 
						|
    <ogr:swap_xy fid="polys.3">
 | 
						|
      <ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,6 1,10 -3,10 -3,6 1,6</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>0,7 -2,7 -2,9 0,9 0,7</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></ogr:geometryProperty>
 | 
						|
      <ogr:name>ASDF</ogr:name>
 | 
						|
      <ogr:intval>0</ogr:intval>
 | 
						|
    </ogr:swap_xy>
 | 
						|
  </gml:featureMember>
 | 
						|
  <gml:featureMember>
 | 
						|
    <ogr:swap_xy fid="polys.4">
 | 
						|
      <ogr:intval>120</ogr:intval>
 | 
						|
      <ogr:floatval>-100291.43213</ogr:floatval>
 | 
						|
    </ogr:swap_xy>
 | 
						|
  </gml:featureMember>
 | 
						|
  <gml:featureMember>
 | 
						|
    <ogr:swap_xy fid="polys.5">
 | 
						|
      <ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,3 1,6 -3,6 -1,2 2,2 2,3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
 | 
						|
      <ogr:name>elim</ogr:name>
 | 
						|
      <ogr:intval>2</ogr:intval>
 | 
						|
      <ogr:floatval>3.33</ogr:floatval>
 | 
						|
    </ogr:swap_xy>
 | 
						|
  </gml:featureMember>
 | 
						|
</ogr:FeatureCollection>
 |