Showing posts with label geospatial. Show all posts
Showing posts with label geospatial. Show all posts

Learning about "gie", a CLI tool for Geographic information Framework (PROJ) validation

 I recently happened across "gie" (a.k.a. "Geospatial Integrity Investigation Environment").

See below for a AI-generated sample use-case. This example was generated using the mods CLI tool from Charm. The LLM backend used in this example is gpt-4o.

 mods -f 'show an example of using the CLI "gie" tool for proj validation

 The "gie" command-line tool is used to validate transformations and commands 
 defined in the Geographic Information Framework (PROJ). Here's an example of  
 how to use the "gie" tool for proj validation:                               
                                                                              
 ### Step-by-Step Example                                                     
                                                                              
 1. Create a GIE File:                                                        
   • Write a GIE script that specifies the transformation you want to          
   validate. Save it as  example.gie .                                        
                                                                              
   <gie>                                                                      
   operation +proj=merc +lat_ts=56.5                                          
   coordinate 12dE 56dN                                                       
   expect    1335833.89       7514065.63                                      
                                                                              
   operation +proj=utm +zone=33 +ellps=WGS84                                  
   coordinate 12dE 56dN                                                       
   expect    500000           6219671.61                                      

                                                                              
 2. Run the GIE Command:                                                      
   • Open your terminal.                                                      
   • Navigate to the directory where the  example.gie  file is located.        
   • Run the validation using the  gie  tool.                                 
                                                                              
   gie example.gie                                                            
                                                                              
 3. Interpret the Output:                                                     
   • The  gie  tool will read the script and execute the transformations.     
   • It will compare the actual output with the expected output mentioned in  
   the  expect  lines.                                                        
   • If the actual results match the expectations, the tool will confirm the   
   validation.                                                                
   • Any discrepancies will be shown in the output for further investigation. 
                                                                              
                                                                              
 This example uses two different operations to transform geographical          
 coordinates and verify that the results are as expected. Adjust the          
 operation ,  coordinate , and  expect  lines according to your specific       
 validation needs.         
                                                   


Conversation saved:  9dc63cb  show an example of using the CLI "gie" tool for proj validation

QGIS Area of Availability Plugin

8/23/16

I'm working on a set of QGIS plugins, and one that I think should be out there for grabs is an area of availability calculator. (EDIT: you should be able to install the plugin via the public QGIS repository soon)

Given a start point and a maximum distance to travel, we want to find the boundary of accessible regions via a road network.

Boundary of area of availability, plotted as points


We build a road network graph and calculate the road distances using Dijkstra's algorithm. We can then find the points corresponding to the outer boundary of the area of availability.

The code for this calculation is below (taken from this page):

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
from qgis.gui import *
from qgis.networkanalysis import *

vl = qgis.utils.iface.mapCanvas().currentLayer()
director = QgsLineVectorLayerDirector(vl, -1, '', '', '', 3)
properter = QgsDistanceArcProperter()
director.addProperter(properter)
crs = qgis.utils.iface.mapCanvas().mapRenderer().destinationCrs()
builder = QgsGraphBuilder(crs)

pStart = QgsPoint(65.5462, 57.1509)
delta = qgis.utils.iface.mapCanvas().getCoordinateTransform().mapUnitsPerPixel() * 1

rb = QgsRubberBand(qgis.utils.iface.mapCanvas(), True)
rb.setColor(Qt.green)
rb.addPoint(QgsPoint(pStart.x() - delta, pStart.y() - delta))
rb.addPoint(QgsPoint(pStart.x() + delta, pStart.y() - delta))
rb.addPoint(QgsPoint(pStart.x() + delta, pStart.y() + delta))
rb.addPoint(QgsPoint(pStart.x() - delta, pStart.y() + delta))

tiedPoints = director.makeGraph(builder, [pStart])
graph = builder.graph()
tStart = tiedPoints[0]

idStart = graph.findVertex(tStart)

(tree, cost) = QgsGraphAnalyzer.dijkstra(graph, idStart, 0)

upperBound = []
r = 2000.0
i = 0
while i < len(cost):
  if cost[i] > r and tree[i] != -1:
    outVertexId = graph.arc(tree [i]).outVertex()
    if cost[outVertexId] < r:
      upperBound.append(i)
  i = i + 1

for i in upperBound:
  centerPoint = graph.vertex(i).point()
  rb = QgsRubberBand(qgis.utils.iface.mapCanvas(), True)
  rb.setColor(Qt.red)
  rb.addPoint(QgsPoint(centerPoint.x() - delta, centerPoint.y() - delta))
  rb.addPoint(QgsPoint(centerPoint.x() + delta, centerPoint.y() - delta))
  rb.addPoint(QgsPoint(centerPoint.x() + delta, centerPoint.y() + delta))
  rb.addPoint(QgsPoint(centerPoint.x() - delta, centerPoint.y() + delta))

I'm not quite finished with my plugin implementation, but you can check out the source code on my GitHub.

If you want to try your hand at developing a QGIS plugin, I strongly recommend starting with Plugin Builder.

Featured

Physiofunctional circadian metabolism...

PFun Glucose Demo Interactive simulation of circadian-ultradian glucose dynamics (over a 24-hour period) A ...