GRASS Programmer's Manual
6.5.svn(2014)-r66266
|
Data Structures | |
class | Rect2D |
Class representing rectangle with floating point values. More... | |
class | Rect2DPP |
Rectangle specified by 2 points (with floating point values). More... | |
class | Rect2DPS |
Rectangle specified by point and size (with floating point values). More... | |
class | UnitConversion |
Class for converting units. More... | |
Functions | |
def | normalize_whitespace |
Remove redundant whitespace from a string. More... | |
def | split |
Platform spefic shlex.split. More... | |
def | GetTempfile |
Creates GRASS temporary file using defined prefix. More... | |
def | GetLayerNameFromCmd |
Get map name from GRASS command. More... | |
def | GetValidLayerName |
Make layer name SQL compliant, based on G_str_to_sql() More... | |
def | ListOfCatsToRange |
Convert list of category number to range(s) More... | |
def | ListOfMapsets |
Get list of available/accessible mapsets. More... | |
def | ListSortLower |
Sort list items (not case-sensitive) More... | |
def | GetVectorNumberOfLayers |
Get list of vector layers. More... | |
def | GetAllVectorLayers |
Returns list of all vector layers as strings. More... | |
def | Deg2DMS |
Convert deg value to dms string. More... | |
def | DMS2Deg |
Convert dms value to deg. More... | |
def | GetCmdString |
def | CmdToTuple |
Convert command list to tuple for gcmd.RunCommand() More... | |
def | PathJoin |
Check path created by os.path.join. More... | |
def | ReadEpsgCodes |
Read EPSG code from the file. More... | |
def | ReprojectCoordinates |
Reproject coordinates. More... | |
def | GetListOfLocations |
Get list of GRASS locations in given dbase. More... | |
def | GetListOfMapsets |
Get list of mapsets in given GRASS location. More... | |
def | GetColorTables |
Get list of color tables. More... | |
def | DecodeString |
Decode string using system encoding. More... | |
def | EncodeString |
Return encoded string using system locales. More... | |
def | GetFormats |
Get GDAL/OGR formats. More... | |
def | GetSettingsPath |
Get full path to the settings directory. More... | |
def | StoreEnvVariable |
Store environmental variable. More... | |
def | SetAddOnPath |
Set default AddOn path. More... | |
def | convertRGB |
Converts wx.Colour(r,g,b,a) to string 'r:g:b' or named color, or named color/r:g:b string to wx.Colour, depending on input. More... | |
def | PaperMapCoordinates |
Converts paper (inch) coordinates <-> map coordinates. More... | |
def | AutoAdjust |
Computes map scale, center and map frame rectangle to fit region (scale is not fixed) More... | |
def | SetResolution |
If resolution is too high, lower it. More... | |
def | ComputeSetRegion |
Computes and sets region from current scale, map center coordinates and map rectangle. More... | |
def | projInfo |
Return region projection and map units information, taken from render.py. More... | |
def | GetMapBounds |
Run ps.map -b to get information about map bounding box. More... | |
def | getRasterType |
Returns type of raster map (CELL, FCELL, DCELL) More... | |
def | PilImageToWxImage |
Convert PIL image to wx.Image. More... | |
def | BBoxAfterRotation |
Compute bounding box or rotated rectangle. More... | |
def | loadPSForWindows |
def | GhostscriptForWindows |
Variables | |
formats = None | |
havePILImage = True | |
unitConv | |
im | |
mode | |
size | |
tile | |
def utils.AutoAdjust | ( | self, | |
scaleType, | |||
rect, | |||
map = None , |
|||
mapType = None , |
|||
region = None |
|||
) |
Computes map scale, center and map frame rectangle to fit region (scale is not fixed)
Definition at line 196 of file psmap/utils.py.
Referenced by frame.PsMapBufferedWindow.OnLeftUp().
def utils.BBoxAfterRotation | ( | w, | |
h, | |||
angle | |||
) |
Compute bounding box or rotated rectangle.
w | rectangle width |
h | rectangle height |
angle | angle (0, 360) in degrees |
Definition at line 383 of file psmap/utils.py.
Referenced by instructions.Image.Read(), and dialogs.ImageDialog.update().
def utils.CmdToTuple | ( | cmd | ) |
Convert command list to tuple for gcmd.RunCommand()
Definition at line 527 of file core/utils.py.
Referenced by colorrules.VectorColorTable.CreateAttrTable(), colorrules.ColorTable.CreateColorTable(), colorrules.ColorTable.LoadTable(), model.Model.Run(), render.Layer.SetCmd(), and instructions.Instruction.SetRegion().
def utils.ComputeSetRegion | ( | self, | |
mapDict | |||
) |
Computes and sets region from current scale, map center coordinates and map rectangle.
Definition at line 272 of file psmap/utils.py.
References projInfo(), and gcmd.RunCommand().
Referenced by frame.PsMapBufferedWindow.OnLeftUp().
def utils.convertRGB | ( | rgb | ) |
Converts wx.Colour(r,g,b,a) to string 'r:g:b' or named color, or named color/r:g:b string to wx.Colour, depending on input.
Definition at line 136 of file psmap/utils.py.
References dialogs.type.
Referenced by frame.PsMapBufferedWindow.DrawGraphics(), frame.PsMapBufferedWindow.DrawRotText(), dialogs.update(), dialogs.MapinfoDialog.update(), dialogs.TextDialog.update(), dialogs.PointDialog.update(), and dialogs.updateRasterLegend().
def utils.DecodeString | ( | string | ) |
Decode string using system encoding.
string | string to be decoded |
Definition at line 704 of file core/utils.py.
def utils.Deg2DMS | ( | lon, | |
lat, | |||
string = True , |
|||
hemisphere = True , |
|||
precision = 3 |
|||
) |
Convert deg value to dms string.
lon | longitude (x) |
lat | latitude (y) |
string | True to return string otherwise tuple |
hemisphere | print hemisphere |
precision | seconds precision |
Definition at line 367 of file core/utils.py.
Referenced by statusbar.SbGoTo.GetCenterString(), statusbar.SbGoTo.OnGoTo(), statusbar.SbCoordinates.ReprojectENFromMap(), and statusbar.SbRegionExtent.ReprojectRegionFromMap().
def utils.DMS2Deg | ( | lon, | |
lat | |||
) |
Convert dms value to deg.
lon | longitude (x) |
lat | latitude (y) |
Definition at line 421 of file core/utils.py.
Referenced by statusbar.SbGoTo.ReprojectENToMap().
def utils.EncodeString | ( | string | ) |
Return encoded string using system locales.
string | string to be encoded |
Definition at line 721 of file core/utils.py.
Referenced by dialogs.ModelSearchDialog.GetCmd().
def utils.GetAllVectorLayers | ( | vector | ) |
Returns list of all vector layers as strings.
vector | name of vector map |
Definition at line 332 of file core/utils.py.
References gcmd.RunCommand().
Referenced by gselect.LayerSelect.InsertLayers().
def utils.GetCmdString | ( | cmd | ) |
Get GRASS command as string. @param cmd GRASS command given as dictionary @return command string
Definition at line 499 of file core/utils.py.
Referenced by render.Layer.GetCmd(), and instructions.Instruction.SetRegion().
def utils.GetColorTables | ( | ) |
Get list of color tables.
Definition at line 694 of file core/utils.py.
References gcmd.RunCommand().
Referenced by preferences.PreferencesDialog.__init__().
def utils.GetFormats | ( | ) |
Get GDAL/OGR formats.
Definition at line 796 of file core/utils.py.
Referenced by gselect.FormatSelect.__init__().
def utils.GetLayerNameFromCmd | ( | dcmd, | |
fullyQualified = False , |
|||
param = None , |
|||
layerType = None |
|||
) |
Get map name from GRASS command.
Parameter dcmd can be modified when first parameter is not defined.
dcmd | GRASS command (given as list) |
fullyQualified | change map name to be fully qualified |
param | params directory |
layerType | check also layer type ('raster', 'vector', '3d-raster', ...) |
Definition at line 73 of file core/utils.py.
References tools.range, and split().
Referenced by layertree.LayerTree.AddLayer(), layertree.LayerTree.ChangeLayer(), histogram.HistogramFrame.GetOptData(), layertree.LayerTree.GetOptData(), GetTempfile(), goutput.GMConsole.OnCmdDone(), frame.MapFrame.QueryMap(), layertree.LayerTree.RecreateItem(), goutput.GMConsole.RunCmd(), and manager.GrSettingsDialog.UpdateSettings().
def utils.GetListOfLocations | ( | dbase | ) |
Get list of GRASS locations in given dbase.
dbase | GRASS database path |
Definition at line 639 of file core/utils.py.
References ListSortLower().
Referenced by gselect.LocationSelect.UpdateItems(), and gis_set.GRASSStartup.UpdateLocations().
def utils.GetListOfMapsets | ( | dbase, | |
location, | |||
selectable = False |
|||
) |
Get list of mapsets in given GRASS location.
dbase | GRASS database path |
location | GRASS location |
selectable | True to get list of selectable mapsets, otherwise all |
Definition at line 662 of file core/utils.py.
References ListSortLower(), and gcmd.RunCommand().
Referenced by gselect.MapsetSelect.UpdateItems().
def utils.GetMapBounds | ( | filename, | |
portrait = True |
|||
) |
Run ps.map -b to get information about map bounding box.
filename | psmap input file |
portrait | page orientation |
Definition at line 331 of file psmap/utils.py.
References split().
Referenced by frame.getInitMap().
def utils.getRasterType | ( | map | ) |
Returns type of raster map (CELL, FCELL, DCELL)
Definition at line 349 of file psmap/utils.py.
Referenced by dialogs.OnRaster(), instructions.RasterLegend.Read(), and dialogs.updateRasterLegend().
def utils.GetSettingsPath | ( | ) |
Get full path to the settings directory.
Definition at line 807 of file core/utils.py.
References split().
Referenced by settings.Settings.SaveToFile().
def utils.GetTempfile | ( | pref = None | ) |
Creates GRASS temporary file using defined prefix.
pref | prefer the given path |
Definition at line 44 of file core/utils.py.
References GetLayerNameFromCmd(), and gcmd.RunCommand().
Referenced by colorrules.ColorTable.CreateColorTable(), manager.GCP.GetNewExtent(), colorrules.RasterColorTable.OnPreview(), colorrules.VectorColorTable.OnTablePreview(), manager.GCPWizard.SetSrcEnv(), and colorrules.VectorColorTable.UpdateColorColumn().
def utils.GetValidLayerName | ( | name | ) |
Make layer name SQL compliant, based on G_str_to_sql()
Definition at line 175 of file core/utils.py.
Referenced by gselect.GdalSelect.OnSetDsn(), and dialogs.DxfImportDialog.OnSetDsn().
def utils.GetVectorNumberOfLayers | ( | vector, | |
parent = None |
|||
) |
Get list of vector layers.
vector | name of vector map |
parent | parent window (to show dialog) or None |
Definition at line 291 of file core/utils.py.
References gcmd.RunCommand().
def utils.GhostscriptForWindows | ( | tile, | |
size, | |||
fp | |||
) |
Render an image using Ghostscript (Windows only)
Definition at line 436 of file psmap/utils.py.
def utils.ListOfCatsToRange | ( | cats | ) |
Convert list of category number to range(s)
Used for example for d.vect cats=[range]
cats | category list |
Definition at line 207 of file core/utils.py.
Referenced by frame.MapFrame.AddTmpVectorMapLayer(), manager.AttributeManager.OnDataItemDeleteAll(), manager.AttributeManager.OnDeleteSelected(), manager.AttributeManager.OnExtractSelected(), and mapwindow.VDigitWindow.OnLeftUpCopyLine().
def utils.ListOfMapsets | ( | get = 'ordered' | ) |
Get list of available/accessible mapsets.
get | method ('all', 'accessible', 'ordered') |
Definition at line 245 of file core/utils.py.
References ListSortLower(), and gcmd.RunCommand().
def utils.ListSortLower | ( | list | ) |
Sort list items (not case-sensitive)
Definition at line 287 of file core/utils.py.
Referenced by GetListOfLocations(), GetListOfMapsets(), ListOfMapsets(), manager.GroupPage.OnEnterPage(), prompt.TextCtrlAutoComplete.SetChoices(), and gselect.ProjSelect.UpdateItems().
def utils.loadPSForWindows | ( | self | ) |
Definition at line 427 of file psmap/utils.py.
def utils.normalize_whitespace | ( | text | ) |
Remove redundant whitespace from a string.
Definition at line 33 of file core/utils.py.
Referenced by forms.text_beautify().
def utils.PaperMapCoordinates | ( | mapInstr, | |
x, | |||
y, | |||
paperToMap = True |
|||
) |
Converts paper (inch) coordinates <-> map coordinates.
mapInstr | map frame instruction |
x,y | paper coords in inches or mapcoords in map units |
paperToMap | specify conversion direction |
Definition at line 159 of file psmap/utils.py.
References projInfo().
Referenced by instructions.Image.ChangeRefPoint(), instructions.Text.Read(), instructions.Image.Read(), instructions.Point.Read(), instructions.Line.Read(), instructions.Rectangle.Read(), frame.PsMapBufferedWindow.RecalculateEN(), dialogs.TextDialog.update(), dialogs.ImageDialog.update(), and dialogs.PointDialog.update().
def utils.PathJoin | ( | args | ) |
Check path created by os.path.join.
Definition at line 551 of file core/utils.py.
def utils.PilImageToWxImage | ( | pilImage, | |
copyAlpha = True |
|||
) |
Convert PIL image to wx.Image.
Based on http://wiki.wxpython.org/WorkingWithImages
Definition at line 360 of file psmap/utils.py.
Referenced by frame.PsMapBufferedWindow.DrawBitmap().
def utils.projInfo | ( | ) |
Return region projection and map units information, taken from render.py.
Definition at line 309 of file psmap/utils.py.
References gcmd.RunCommand().
Referenced by ComputeSetRegion(), instructions.Scalebar.EstimateSize(), frame.OnAddScalebar(), and PaperMapCoordinates().
def utils.ReadEpsgCodes | ( | path | ) |
Read EPSG code from the file.
path | full path to the file with EPSG codes |
Definition at line 560 of file core/utils.py.
Referenced by wizard.EPSGPage.OnBrowseCodes(), and preferences.PreferencesDialog.OnLoadEpsgCodes().
def utils.ReprojectCoordinates | ( | coord, | |
projOut, | |||
projIn = None , |
|||
flags = '' |
|||
) |
Reproject coordinates.
coord | coordinates given as tuple |
projOut | output projection |
projIn | input projection (use location projection settings) |
Definition at line 602 of file core/utils.py.
References gcmd.RunCommand(), and split().
Referenced by statusbar.SbGoTo.GetCenterString(), statusbar.SbCoordinates.ReprojectENFromMap(), statusbar.SbGoTo.ReprojectENToMap(), and statusbar.SbRegionExtent.ReprojectRegionFromMap().
def utils.SetAddOnPath | ( | addonPath = None | ) |
Set default AddOn path.
path to addons (None for default)
Definition at line 893 of file core/utils.py.
References split(), and StoreEnvVariable().
Referenced by extensions.InstallExtensionWindow.OnDone(), and frame.GMFrame.OnRunScript().
def utils.SetResolution | ( | dpi, | |
width, | |||
height | |||
) |
If resolution is too high, lower it.
dpi | max DPI |
width | map frame width |
height | map frame height |
Definition at line 259 of file psmap/utils.py.
References gcmd.RunCommand().
Referenced by frame.DialogDataChanged(), frame.PsMapBufferedWindow.OnLeftUp(), and frame.PsMapFrame.PSFile().
def utils.split | ( | s | ) |
Platform spefic shlex.split.
Definition at line 37 of file core/utils.py.
Referenced by gcmd.GError.__init__(), ghelp.AboutWindow.__init__(), instructions.Text.__str__(), instructions.VProperties.__str__(), colorrules.VectorColorTable.AddTemporaryColumn(), layertree.LayerTree.ChangeLayer(), globalvar.CheckForWx(), globalvar.CheckWxVersion(), render.Map.Clean(), profile.ProfileFrame.CreateDatalist(), python.db.db_select(), frame.DialogDataChanged(), prompt.GPromptSTC.EntityToComplete(), instructions.RasterLegend.EstimateHeight(), dialogs.ModelSearchDialog.GetCmd(), prompt.GPrompt.GetCommandItems(), dialogs.PageSetupDialog.getCtrl(), frame.PsMapFrame.getFile(), GetLayerNameFromCmd(), mapwindow.GLWindow.GetLegendRect(), GetMapBounds(), manager.GCP.GetNewExtent(), dialogs.GroupDialog.GetSelectedGroup(), GetSettingsPath(), widgets.GetValue(), colorrules.RulesPanel.LoadRules(), python.core.locn_is_latlong(), frame.makePSFont(), dialogs.NorthArrowDialog.OnConvergence(), manager.AttributeManager.OnDataItemDeleteAll(), prompt.TextCtrlAutoComplete.OnEnteredText(), statusbar.SbGoTo.OnGoTo(), prompt.GPromptSTC.OnItemSelected(), gselect.TreeCtrlComboPopup.OnKeyUp(), gselect.TreeCtrlComboPopup.OnLeftDown(), menu.MenuTreeWindow.OnRun(), dialogs.ProfileRasterDialog.OnSelection(), ghelp.SearchModuleWindow.OnSelectModule(), gselect.GdalSelect.OnSetDsn(), dialogs.DxfImportDialog.OnSetDsn(), gselect.GdalSelect.OnSettingsDelete(), tools.OnSurfaceModeAll(), menudata.MenuData.PrintStrings(), instructions.MapFrame.Read(), instructions.Mapinfo.Read(), instructions.VProperties.Read(), frame.PsMapBufferedWindow.RecalculatePosition(), ReprojectCoordinates(), statusbar.SbGoTo.ReprojectENToMap(), manager.GCP.RMSError(), goutput.CmdThread.run(), model.Model.Run(), SetAddOnPath(), instructions.Instruction.SetRegion(), profile.ProfileFrame.SetupProfile(), StoreEnvVariable(), dialogs.MapFramePanel.update(), globalvar.UpdateGRASSAddOnCommands(), frame.UpdateMapLabel(), tools.UpdateVectorPage(), python.vector.vector_db(), and python.vector.vector_db_select().
def utils.StoreEnvVariable | ( | key, | |
value = None , |
|||
envFile = None |
|||
) |
Store environmental variable.
If value is not given (is None) then environmental variable is unset.
key | env key |
value | env value |
envFile | path to the environmental file (None for default location) |
Definition at line 825 of file core/utils.py.
References split().
Referenced by SetAddOnPath().
utils.formats = None |
Definition at line 794 of file core/utils.py.
utils.havePILImage = True |
Definition at line 25 of file psmap/utils.py.
utils.im |
Definition at line 431 of file psmap/utils.py.
Referenced by chouse(), chousv(), class_discont(), and hconj().
utils.mode |
Definition at line 432 of file psmap/utils.py.
utils.size |
Definition at line 433 of file psmap/utils.py.
utils.tile |
Definition at line 434 of file psmap/utils.py.
Referenced by G3d_flushTile(), G3d_getBlockNocache(), G3d_getDoubleRegion(), G3d_getFloatRegion(), G3d_initIndex(), G3d_putDouble(), and G3d_putFloat().
utils.unitConv |
Definition at line 234 of file psmap/utils.py.