Overview
Scripts
Folder: JavaScript Projections
- ProjInfoToCSV.py - takes Proj4 data from the output.txt file and converts it into ProjInfoRAW.csv. This file is then edited to create ProjInfo4.
- ProjInfoToDatabase.py - Gets the data from the ProjInfo4.csv and puts it into the database tables methods, parameters, etc. (run to setup database)
- CreateGridFiles2.py - creates the default projection grid folders and files in Archive/ProjectionGrids. This should be run first to setup the ProjectionGrids folder.
- CreateProjectionImages.py - adds the images for the web pages to the ProjectionGrids folder in Archive
- WriteOutProjInfo.py - writes out the ProjInfo and VarProjInfo files based on the current contents of the database
Old
- ProfileCreateImages.py - old file to do performance profiling of the image rendering code
- ProjectionToDatabase.py - old file to look at adding specific projections with parameters to the database
- TestAitoffLockUp.py - file to isoalate the lockup found in the Aitoff projection method
Folder: PythonGISApp
- GISApp.py - attempt at a GIS application in Python
- ProjectionExplorerIIQt.py
Utilities
- DialogSaveToDatabase.py - creates a dialog to save data to the database
- GeographicCanvasWidget.py
- PostgreSQLUtil.py
- ProjectedCanvasWidget.py
- ProjectionsDatabaseUtil.py
Old
- ShapelyContainsDefect.py
- TestWriteProjectionFile.py
- TimingTests.py
- UpdateCopyright.py
-----------------------
Classes
SpaProjectorGrids is the top of the projection library.
Inheritance tree:
- SpaBase: Just stores settings (needed?)
- SpaTransform : Not used?
- SpaProjector: base class for projectors, defines project to and from geographic functions?
- SpaProj: Implements projection with the Proj library, contains high level functions for projecting vector and raster data
- SpaProjectorGrid: implements a grid-based projection based on proj projection coordinates
- SpaProjectorGrids: Contains one or more SpaProjectorGrid for each of the unique areas that are needed to correctly project any area on the earth
SpaProjector
- ProjectFromGeographic(TheObject)
SpaProj
- Also defined in SpaPy library documentation
Projects from a source to a destination osgeo CRS
- SetSettings()?
- SetCRSes(FromCRS,ToCRS): Can pass in EPSG codes, proj params, or osr.SpatialReferences
- InverseTransformCoordinate (self,X,Y):
- TransformCoordinate(self,X,Y):
- Transform(self,TheObject)
- TransformRaster(self,TheObject,OutputFilePath)
Static functions
- TransformRaster(Input1,OutputFilePath,CRS1,CRS2=None)
- Transform(Input1,CRS1,CRS2=None)
SpaProjectorGrid
Settings
- GeographicBoundingBox
- DegreeSpacing
- "AreaDistortionMin
- AreaDistortionMax
- DistanceDistortionMin
- DistanceDistortionMax
- AdjacentAreaDistortionChangeMin
- AdjacentAreaDistortionChangeMax
- DistanceToCombinePolarCoordinates
- DensifyDistanceInDegrees":1, # None to disable densify
Member Functions
- SetSettings
- SpaProjectorGridInitialize(self):
- ProjectCoordinateFromGeographic(self,Lon,Lat,Elevation=0):
- GetAreaDistortions(self):
- GetBackProjectedGrids(self):
- SetParent(self,TheParent):
Private Member Functions
- GetOptimizedBoundsArray
- _GetOptimizeddBoundingPolygon
- SpaOptimizedBounds
- _InsertPointsForFirstCellInNewBounds
- _CheckCell()
- _CheckCell_AreaDistortionOkay
- FindAdjacentOutsideCells
- _TargetCellValid
- _CheckCellIntersectsWithBounds
- _CheckDistanceDistortionForSides
- _DeleteBoundsPoint
- _MoveBoundsPoint
- _SegmentBetweenPointsIntersect
- _InsertBoundsPoint
SpaProjectorGrids
Settings (Additional on top of SpaProjectorGrid)
- "LongitudeShift":0, # Works the same as Longitude of Origin
"LongitudeWestPad":0.00001,
"LongitudeEastPad":0.00001
- SegmentIntersectionEndPointTolerance
- Debugging
- DumpCellsAsAdded
Drawing Settings
TheProjectorGrids.SetSettings(SpaProjectorGrids,ProjectorGridSettings)
- Saves some settings as object variables
Setup
Sets up the projection engine,
- Sets up the object variables:
- LongitudeOfOrigin: - always 0
- LatitudeOfOrigin: - 90 to -90
- LonNewPole: - 180 to -180
- .LatNewPole: - 90 to -90
- SpecifiedLongitudeOfOrigin: Original longitude of origin the user specified
- Sets up parameters for proj
- Adds parameters except for lon_0
- Initializes proj
- LatNewPole and LonNewPole are specified individuall as if these have changed from the defaults, the X transform will be called and passed the requested projection method.
- Gets the geographic bounding boxes as a MultiPolygon geometry
- Initilze the grid projectors
- Get the grid projectors bounds in projected coordinates
- Compute OriginalProjectedBoundingBox
- OriginalProjectedBoundingPolys
Projecting
The approach is to (this is from SpaProjectorGrids.ProjectDataset():
- Get the OriginalGeographicBoundingBoxes (may be shifted for longitude of origin !=0 )
- Densify the dataset
- For each ProjectorGrid
- Densify the dataset
- Get the ProjectedBoundsArray (this currnetly has just one entry)
- For each ProjectedBounds
- Get the Geographic Bouding Polugon
- Buffer(0) the polygon
- If ClipToFinalProjectedBounds
- For each GeographicBoundingBox
- Intersect the data with the GeographicBoundingBox (which may be shifted)
- Shift the data if needed
- Clip the data with the GeographicBoundingPolygon
- Densify the clipped data
- Project the data
- If this resulted in data,
- Buffer(0)
- Add to the new dataset
- Else
- Just project the data
- Return the array of datasets