本文整理汇总了Python中qgis.core.QgsCoordinateTransform类的典型用法代码示例。如果您正苦于以下问题:Python QgsCoordinateTransform类的具体用法?Python QgsCoordinateTransform怎么用?Python QgsCoordinateTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsCoordinateTransform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: proj4Utm
def proj4Utm(self, p):
mapCrs = self.canvas.mapSettings().destinationCrs()
if not mapCrs.geographicFlag():
# if not geographic transform it to a geographic crs
geographicCrs = QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
ct = QgsCoordinateTransform(mapCrs, geographicCrs)
p = ct.transform(p)
x = p.x()
y = p.y()
z = math.floor((x + 180) / 6) + 1
if y >= 56.0 and y < 64.0 and x >= 3.0 and x < 12.0:
ZoneNumber = 32
# Special zones for Svalbard
if y >= 72.0 and y < 84.0:
if y >= 0.0 and y < 9.0:
z = 31
elif y >= 9.0 and y < 21.0:
z = 33
elif y >= 21.0 and y < 33.0:
z = 35
elif y >= 33.0 and y < 42.0:
z = 37
return "+proj=utm +zone={0} +datum=WGS84 +units=m +no_defs".format(int(z))
开发者ID:APIS-Luftbildarchiv,项目名称:APIS,代码行数:28,代码来源:apis_map_tools.py
示例2: selectVisibleRasters
def selectVisibleRasters(self):
self.refreshRasterList()
self.selectingVisibleRasters = True
extCanvas = self.iface.mapCanvas().extent()
#alle raster in den einstellunge deselektieren
for r in self.settings.mapData.rasters.rasters():
r.selected = False
#alle raster in der ListView deselektieren
for idx in range(self.ui.IDC_listRasters.count()):
item = self.ui.IDC_listRasters.item(idx)
item.setCheckState(Qt.Unchecked)
#Raster im Extent selektieren
canvasCrs = self.iface.mapCanvas().mapSettings().destinationCrs()
for idx in range(self.ui.IDC_listRasters.count()):
item = self.ui.IDC_listRasters.item(idx)
raster = item.data(Qt.UserRole)
for r in self.settings.mapData.rasters.rasters():
layerCrs = r.grid.crs()
ct = QgsCoordinateTransform(layerCrs, canvasCrs, QgsProject.instance())
extent = ct.transform(r.grid.extent())
if extCanvas.intersects(extent):
if r.id == raster.id:
r.selected = True
item.setCheckState(Qt.Checked)
self.selectingVisibleRasters = False
开发者ID:BergWerkGIS,项目名称:VoGIS-Profil-Tool,代码行数:25,代码来源:vogisprofiltoolmaindialog.py
示例3: clicked
def clicked(self, pt, b):
'''Capture the coordinate when the mouse button has been released,
format it, and copy it to the clipboard.'''
if settings.captureShowLocation:
if self.marker is None:
self.marker = QgsVertexMarker(self.canvas)
self.marker.setIconSize(18)
self.marker.setPenWidth(2)
self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
self.marker.setCenter(pt)
else:
self.removeMarker();
try:
if self.capture4326:
canvasCRS = self.canvas.mapSettings().destinationCrs()
transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
pt4326 = transform.transform(pt.x(), pt.y())
self.capturesig.emit(pt4326)
return
msg = self.formatCoord(pt, self.settings.delimiter)
formatString = self.coordFormatString()
if msg != None:
clipboard = QApplication.clipboard()
clipboard.setText(msg)
self.iface.messageBar().pushMessage("", "{} coordinate {} copied to the clipboard".format(formatString, msg), level=Qgis.Info, duration=4)
except Exception as e:
self.iface.messageBar().pushMessage("", "Invalid coordinate: {}".format(e), level=Qgis.Warning, duration=4)
开发者ID:NationalSecurityAgency,项目名称:qgis-latlontools-plugin,代码行数:28,代码来源:copyLatLonTool.py
示例4: getCoordinatesByAddress
def getCoordinatesByAddress(address,crs=None):
# In: Country, City, Postal Address or Parts of it
# Target Coordinate Reference System as EPSG Code
# Out: dict of all informations delivered by googlemaps
if isinstance(address, unicode):
address = address.encode('utf-8')
urlParams = {'q': address,
'format': 'json',
'addressdetails': '1',
}
url='http://nominatim.openstreetmap.org/search?'+urllib.urlencode(urlParams)
response = urllib2.urlopen(url)
result = json.load(response)
#print result['results']
# try:
addrlist = []
for addrrecord in result:
dataset = {}
dataset['latitude'] = addrrecord['lat']
dataset['longitude'] = addrrecord['lon']
if crs:
targetCRS = QgsCoordinateReferenceSystem(crs, QgsCoordinateReferenceSystem.EpsgCrsId)
googleMapsCRS = QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
location = QgsCoordinateTransform(googleMapsCRS, targetCRS).transform(QgsPoint(dataset['longitude'], dataset['latitude']))
dataset['latitude'] = location.y()
dataset['longitude'] = location.x()
addrlist.append(complete_google_dataset(dataset))
# except:
# return []
return addrlist
开发者ID:uvchik,项目名称:Open_eQuarter,代码行数:35,代码来源:nominatim.py
示例5: doGeocoding
def doGeocoding(self, address):
address = unicodedata.normalize('NFKD', unicode(address)).encode('ASCII', 'ignore')
url = "http://api-adresse.data.gouv.fr/search/?q="+address.replace(" ", "%20")
result = self.request(url)
try:
data = json.loads(result)
features = data["features"]
if len(features) > 0:
feature_list = []
for feature in features:
feature_list.append(feature["properties"]["label"]+" - "+str(round(feature["properties"]["score"]*100))+"%")
feature, ok = QInputDialog.getItem(self.iface.mainWindow(), self.tr("Result"), "", feature_list)
if ok:
index = feature_list.index(feature)
x = features[index]["geometry"]["coordinates"][0]
y = features[index]["geometry"]["coordinates"][1]
point_4326 = QgsPoint(x, y)
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem(4326),
self.canvas.mapSettings().destinationCrs())
point_2154 = transform.transform(point_4326)
self.rb.addPoint(point_2154)
self.iface.mapCanvas().setCenter(point_2154)
self.iface.mapCanvas().refresh()
else:
QMessageBox.information(self.iface.mainWindow(), self.tr("Result"), self.tr("No result."))
except ValueError:
QMessageBox.critical(self.iface.mainWindow(), self.tr("Error"), self.tr("An error occured. Check your network settings (proxy)."))
开发者ID:jeremyk6,项目名称:gban,代码行数:29,代码来源:gban.py
示例6: josm_remote
def josm_remote(self):
map_settings = self.iface.mapCanvas().mapSettings()
extent = map_settings.extent()
crs_map = map_settings.destinationCrs()
if crs_map.authid() != 'EPSG:4326':
crs_4326 = QgsCoordinateReferenceSystem(4326)
transform = QgsCoordinateTransform(crs_map, crs_4326, QgsProject.instance())
extent = transform.transform(extent)
url = 'http://localhost:8111/load_and_zoom?'
query_string = 'left=%f&right=%f&top=%f&bottom=%f' % (
extent.xMinimum(), extent.xMaximum(), extent.yMaximum(),
extent.yMinimum())
url += query_string
try:
request = urllib.request.Request(url)
result_request = urllib.request.urlopen(request)
result = result_request.read()
result = result.decode('utf8')
if result.strip().upper() != 'OK':
self.iface.messageBar().pushCritical(
tr('JOSM Remote'), result)
else:
self.iface.messageBar().pushSuccess(
tr('JOSM Remote'), tr('Import done, check JOSM'))
except IOError:
self.iface.messageBar().pushCritical(
tr('JOSM Remote'), tr('Is the remote enabled?'))
开发者ID:3liz,项目名称:QuickOSM,代码行数:28,代码来源:quick_osm.py
示例7: show_exposure
def show_exposure(self, hostname, username, password):
selected_extent = self.selectedExtent()
if selected_extent is None:
QtGui.QMessageBox.warning(
self, 'Exposure Download Error', 'No region selected')
return
self.enableBusyCursor()
try:
crs = self.iface.mapCanvas().mapRenderer().destinationCrs()
xform = QgsCoordinateTransform(
crs, QgsCoordinateReferenceSystem(4326))
extent = xform.transform(selected_extent)
lon_min, lon_max = extent.xMinimum(), extent.xMaximum()
lat_min, lat_max = extent.yMinimum(), extent.yMaximum()
# download data
ed = ExposureDownloader(hostname)
ed.login(username, password)
try:
fname, msg = ed.download(lat_min, lon_min, lat_max, lon_max)
except ExposureDownloadError as e:
QtGui.QMessageBox.warning(
self, 'Exposure Download Error', str(e))
return
QgsMessageLog.logMessage(msg, 'GEM Exposure Downloader')
# don't remove the file, otherwise there will concurrency problems
uri = 'file://%s?delimiter=%s&xField=%s&yField=%s&crs=epsg:4326&' \
'skipLines=25&trimFields=yes' % (fname, ',', 'lon', 'lat')
vlayer = QgsVectorLayer(uri, 'exposure_export', 'delimitedtext')
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
finally:
self.disableBusyCursor()
开发者ID:gem,项目名称:qt-experiments,代码行数:32,代码来源:exposuretool.py
示例8: writeTmpLayer
def writeTmpLayer(layer, restrictToExtent, iface, extent):
fields = layer.fields()
usedFields = []
for count, field in enumerate(fields):
fieldIndex = fields.indexFromName(unicode(field.name()))
editorWidget = layer.editorWidgetSetup(fieldIndex).type()
addField = False
try:
if layer.renderer().classAttribute() == field.name():
addField = True
except:
pass
if layer.customProperty("labeling/fieldName") == field.name():
addField = True
if (editorWidget != 'Hidden'):
addField = True
if addField:
usedFields.append(count)
uri = TYPE_MAP[layer.wkbType()]
crs = layer.crs()
if crs.isValid():
uri += '?crs=' + crs.authid()
for field in usedFields:
fieldIndex = layer.fields().indexFromName(unicode(
layer.fields().field(field).name()))
editorWidget = layer.editorWidgetSetup(fieldIndex).type()
fieldType = layer.fields().field(field).type()
fieldName = layer.fields().field(field).name()
if (editorWidget == 'Hidden'):
fieldName = "q2wHide_" + fieldName
fieldType = "double" if (fieldType == QVariant.Double or
fieldType == QVariant.Int) else ("string")
uri += '&field=' + unicode(fieldName) + ":" + fieldType
newlayer = QgsVectorLayer(uri, layer.name(), 'memory')
writer = newlayer.dataProvider()
outFeat = QgsFeature()
if restrictToExtent and extent == "Canvas extent":
canvas = iface.mapCanvas()
extent = canvas.extent()
canvasCRS = canvas.mapSettings().destinationCrs()
layerCRS = layer.crs()
try:
transform = QgsCoordinateTransform(canvasCRS, layerCRS,
QgsProject.instance())
except:
transform = QgsCoordinateTransform(canvasCRS, layerCRS)
projectedExtent = transform.transformBoundingBox(extent)
request = QgsFeatureRequest(projectedExtent)
request.setFlags(QgsFeatureRequest.ExactIntersect)
features = layer.getFeatures(request)
else:
features = layer.getFeatures()
for feature in features:
if feature.geometry() is not None:
outFeat.setGeometry(feature.geometry())
attrs = [feature[f] for f in usedFields]
if attrs:
outFeat.setAttributes(attrs)
writer.addFeatures([outFeat])
return newlayer
开发者ID:Tomacorcoran,项目名称:qgis2web,代码行数:60,代码来源:utils.py
示例9: test_province_for_point
def test_province_for_point(self):
"""Test for province for point function."""
# Point falls in South Africa
point = QgsPoint(21, -30)
expected_province = 'Free State'
province = province_for_point(self.database_manager, point)
message = 'Should be %s but got %s' % (expected_province, province)
self.assertEqual(expected_province, province, message)
# Point falls in Indonesia
point = QgsPoint(109, -7)
expected_province = None
province = province_for_point(self.database_manager, point)
message = 'Should be %s but got %s' % (expected_province, province)
self.assertEqual(expected_province, province, message)
# Point falls in South Africa but uses different CRS
point = QgsPoint(2265216.874, -3952469.869)
expected_province = None
province = province_for_point(self.database_manager, point)
message = 'Should be %s but got %s' % (expected_province, province)
self.assertEqual(expected_province, province, message)
# Point falls in South Africa but uses different CRS, reproject to 4326
osm_crs = QgsCoordinateReferenceSystem(3857)
wgs84_crs = QgsCoordinateReferenceSystem(4326)
transformer = QgsCoordinateTransform(osm_crs, wgs84_crs)
point = QgsPoint(2265216.874, -3952469.869)
point_transformed = transformer.transform(point)
expected_province = 'Western Cape'
province = province_for_point(self.database_manager, point_transformed)
message = 'Should be %s but got %s' % (expected_province, province)
self.assertEqual(expected_province, province, message)
开发者ID:kartoza,项目名称:sg-diagram-downloader,代码行数:35,代码来源:test_sg_utilities.py
示例10: load_layer_features
def load_layer_features(self, point=None, layers=None):
# TODO Move this logic into the viewer and let it track it's position
if point is None and self.marker.map_pos is None:
return
if point is None:
point = self.marker.map_pos
area, units = self.distancearea()
rect = search_area(units, area, point)
if layers is None:
layers = self.visible_layers()
for layer in layers:
transform = self.coordinatetransform(layer)
# Transform the rect
source = self.canvas.mapRenderer().destinationCrs()
dest = layer.crs()
recttransform = QgsCoordinateTransform(source, dest)
rect = recttransform.transformBoundingBox(rect)
features = list(get_features_in_area(layer, rect, transform, self.canvas.mapSettings()))
geomtype = layer.geometryType()
layerdata = dict(id=layer.id(), geomtype=QGis.vectorGeometryType(geomtype))
self.viewer.load_features(layerdata, features)
开发者ID:michaelborck,项目名称:earthmine-qgis,代码行数:26,代码来源:earthmine_qgis.py
示例11: EPSG
def EPSG(self):
currentEPSG = self.canvas.mapRenderer().destinationCrs().authid()
if currentEPSG != 'EPSG:4326':
crsSrc = QgsCoordinateReferenceSystem(int(currentEPSG[5:]))
crsDest = QgsCoordinateReferenceSystem(4326) ## WGS-84
xform = QgsCoordinateTransform(crsSrc, crsDest)
self.coordsClick = xform.transform(self.pntGeom.asPoint())
开发者ID:adamczi,项目名称:Skobbler-API,代码行数:7,代码来源:epsg.py
示例12: rasterScript
def rasterScript(layer, safeLayerName):
out_raster = 'data/' + safeLayerName + '.png'
pt2 = layer.extent()
crsSrc = layer.crs()
crsDest = QgsCoordinateReferenceSystem(4326)
try:
xform = QgsCoordinateTransform(crsSrc, crsDest, QgsProject.instance())
except:
xform = QgsCoordinateTransform(crsSrc, crsDest)
pt3 = xform.transformBoundingBox(pt2)
bbox_canvas2 = [pt3.yMinimum(), pt3.yMaximum(),
pt3.xMinimum(), pt3.xMaximum()]
bounds = '[[' + unicode(pt3.yMinimum()) + ','
bounds += unicode(pt3.xMinimum()) + '],['
bounds += unicode(pt3.yMaximum()) + ','
bounds += unicode(pt3.xMaximum()) + ']]'
raster = """
var img_{safeLayerName} = '{out_raster}';
var img_bounds_{safeLayerName} = {bounds};
var overlay_{safeLayerName} = """.format(safeLayerName=safeLayerName,
out_raster=out_raster,
bounds=bounds)
raster += "new L.imageOverlay(img_"
raster += """{safeLayerName}, img_bounds_{safeLayerName});
bounds_group.addLayer(overlay_{safeLayerName});""".format(
safeLayerName=safeLayerName)
return raster
开发者ID:boesiii,项目名称:qgis2web,代码行数:27,代码来源:leafletScriptStrings.py
示例13: extent_to_geoarray
def extent_to_geoarray(extent, source_crs):
"""Convert the supplied extent to geographic and return as as array.
:param extent: QgsRectangle to be transformed to geocrs.
:type extent:
:param source_crs: QgsCoordinateReferenceSystem representing the
original extent's CRS.
:type source_crs:
:returns: Transformed extents in EPSG:4326 in the form
[xmin, ymin, xmax, ymax]
"""
myGeoCrs = QgsCoordinateReferenceSystem()
myGeoCrs.createFromId(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
myXForm = QgsCoordinateTransform(
source_crs,
myGeoCrs)
# Get the clip area in the layer's crs
myTransformedExtent = myXForm.transformBoundingBox(extent)
myGeoExtent = [myTransformedExtent.xMinimum(),
myTransformedExtent.yMinimum(),
myTransformedExtent.xMaximum(),
myTransformedExtent.yMaximum()]
return myGeoExtent
开发者ID:vdeparday,项目名称:inasafe,代码行数:28,代码来源:clipper.py
示例14: _calc_north
def _calc_north(self):
extent = self.canvas.extent()
if self.canvas.layerCount() == 0 or extent.isEmpty():
print "No layers or extent"
return 0
outcrs = self.canvas.mapSettings().destinationCrs()
if outcrs.isValid() and not outcrs.geographicFlag():
crs = QgsCoordinateReferenceSystem()
crs.createFromOgcWmsCrs("EPSG:4326")
transform = QgsCoordinateTransform(outcrs, crs)
p1 = QgsPoint(extent.center())
p2 = QgsPoint(p1.x(), p1.y() + extent.height() * 0.25)
try:
pp1 = transform.transform(p1)
pp2 = transform.transform(p2)
except QgsCsException:
roam.utils.warning("North arrow. Error transforming.")
return None
area = QgsDistanceArea()
area.setEllipsoid(crs.ellipsoidAcronym())
area.setEllipsoidalMode(True)
area.setSourceCrs(crs)
distance, angle, _ = area.computeDistanceBearing(pp1, pp2)
angle = math.degrees(angle)
return angle
else:
return 0
开发者ID:loongfee,项目名称:Roam,代码行数:33,代码来源:mapwidget.py
示例15: set_bbox_from_map
def set_bbox_from_map(self):
"""set bounding box from map extent"""
crs = self.map.mapRenderer().destinationCrs()
crsid = int(crs.authid().split(':')[1])
extent = self.map.extent()
if crsid != 4326: # reproject to EPSG:4326
src = QgsCoordinateReferenceSystem(crsid)
dest = QgsCoordinateReferenceSystem(4326)
xform = QgsCoordinateTransform(src, dest)
minxy = xform.transform(QgsPoint(extent.xMinimum(),
extent.yMinimum()))
maxxy = xform.transform(QgsPoint(extent.xMaximum(),
extent.yMaximum()))
minx, miny = minxy
maxx, maxy = maxxy
else: # 4326
minx = extent.xMinimum()
miny = extent.yMinimum()
maxx = extent.xMaximum()
maxy = extent.yMaximum()
self.leNorth.setText(unicode(maxy)[0:9])
self.leSouth.setText(unicode(miny)[0:9])
self.leWest.setText(unicode(minx)[0:9])
self.leEast.setText(unicode(maxx)[0:9])
开发者ID:volaya,项目名称:QGIS,代码行数:28,代码来源:maindialog.py
示例16: bounds
def bounds(self):
"""
Function for recalculating the bounded extents of the
layers as they are processed. Under construction
:return:
"""
# Requires refinement for raster manipulation of bounds
selected_extent = unicode(self.getParameterValue(self.MAP_EXTENT)).split(',')
xMin = float(selected_extent[0])
xMax = float(selected_extent[1])
yMin = float(selected_extent[2])
yMax = float(selected_extent[3])
extent = QgsRectangle(xMin, yMin, xMax, yMax)
mapCRS = iface.mapCanvas().mapSettings().destinationCrs()
transform = QgsCoordinateTransform(
mapCRS,
QgsCoordinateReferenceSystem('EPSG:4326') # WGS84
# QgsCoordinateReferenceSystem('EPSG:3785') # Popular vis mercator
)
try:
layer_extent = transform.transform(extent)
except QgsCsException:
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING,
"exception in transform layer srs")
layer_extent = QgsRectangle(-180, -90, 180, 90)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, layer_extent.toString())
return layer_extent
开发者ID:SpatialVision,项目名称:QGIS2GISCloud_Publisher,代码行数:32,代码来源:giscloud_uploader_algorithm.py
示例17: set_bbox_from_map
def set_bbox_from_map(self):
"""set bounding box from map extent"""
crs = self.map.mapSettings().destinationCrs()
try:
crsid = int(crs.authid().split(':')[1])
except IndexError: # no projection
crsid = 4326
extent = self.map.extent()
if crsid != 4326: # reproject to EPSG:4326
src = QgsCoordinateReferenceSystem(crsid)
dest = QgsCoordinateReferenceSystem(4326)
xform = QgsCoordinateTransform(src, dest, QgsProject.instance())
minxy = xform.transform(QgsPointXY(extent.xMinimum(),
extent.yMinimum()))
maxxy = xform.transform(QgsPointXY(extent.xMaximum(),
extent.yMaximum()))
minx, miny = minxy
maxx, maxy = maxxy
else: # 4326
minx = extent.xMinimum()
miny = extent.yMinimum()
maxx = extent.xMaximum()
maxy = extent.yMaximum()
self.leNorth.setText(str(maxy)[0:9])
self.leSouth.setText(str(miny)[0:9])
self.leWest.setText(str(minx)[0:9])
self.leEast.setText(str(maxx)[0:9])
开发者ID:borysiasty,项目名称:QGIS,代码行数:31,代码来源:maindialog.py
示例18: __signal_pbCopyKml_clicked
def __signal_pbCopyKml_clicked(self, cheked):
# Extent Openlayers
action = "map.getExtent().toGeometry().toString();"
wkt = self.webViewMap.page().mainFrame().evaluateJavaScript(action)
rect = QgsGeometry.fromWkt(wkt).boundingBox()
srsGE = QgsCoordinateReferenceSystem(
4326, QgsCoordinateReferenceSystem.EpsgCrsId)
coodTrans = QgsCoordinateTransform(self.__srsOL, srsGE,
QgsProject.instance())
rect = coodTrans.transform(
rect, QgsCoordinateTransform.ForwardTransform)
line = QgsGeometry.fromRect(rect).asPolygon()[0]
wkt = str(QgsGeometry.fromPolylineXY(line).asWkt())
# Kml
proj4 = str(srsGE.toProj4())
kmlLine = bindogr.exportKml(wkt, proj4)
kml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"\
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" " \
"xmlns:gx=\"http://www.google.com/kml/ext/2.2\" " \
"xmlns:kml=\"http://www.opengis.net/kml/2.2\" " \
"xmlns:atom=\"http://www.w3.org/2005/Atom\">" \
"<Placemark>" \
"<name>KML from Plugin Openlayers Overview for QGIS</name>" \
"<description>Extent of openlayers map from Plugin Openlayers \
Overview for QGIS</description>"\
"%s" \
"</Placemark></kml>" % kmlLine
clipBoard = QApplication.clipboard()
clipBoard.setText(kml)
开发者ID:dongikjang,项目名称:qgis-tmsforkorea-plugin,代码行数:29,代码来源:openlayers_ovwidget.py
示例19: extent_to_geo_array
def extent_to_geo_array(extent, source_crs):
"""Convert the supplied extent to geographic and return as an array.
:param extent: Rectangle defining a spatial extent in any CRS.
:type extent: QgsRectangle
:param source_crs: Coordinate system used for extent.
:type source_crs: QgsCoordinateReferenceSystem
:returns: a list in the form [xmin, ymin, xmax, ymax] where all
coordinates provided are in Geographic / EPSG:4326.
:rtype: list
"""
myGeoCrs = QgsCoordinateReferenceSystem()
myGeoCrs.createFromId(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
myXForm = QgsCoordinateTransform(source_crs, myGeoCrs)
# Get the clip area in the layer's crs
myTransformedExtent = myXForm.transformBoundingBox(extent)
myGeoExtent = [myTransformedExtent.xMinimum(),
myTransformedExtent.yMinimum(),
myTransformedExtent.xMaximum(),
myTransformedExtent.yMaximum()]
return myGeoExtent
开发者ID:gsuhartono,项目名称:inasafe,代码行数:27,代码来源:utilities.py
示例20: gpsStateChanged
def gpsStateChanged(self, gpsInfo):
if gpsInfo.fixType == NMEA_FIX_BAD or gpsInfo.status == 0 or gpsInfo.quality == 0:
self.gpsfixed.emit(False, gpsInfo)
return
elif gpsInfo.fixType == NMEA_FIX_3D or NMEA_FIX_2D:
self.gpsfixed.emit(True, gpsInfo)
map_pos = QgsPoint(gpsInfo.longitude, gpsInfo.latitude)
self.latlong_position = map_pos
if self.crs:
transform = QgsCoordinateTransform(self.wgs84CRS, self.crs)
try:
map_pos = transform.transform(map_pos)
except QgsCsException:
log("Transform exception")
return
if self.postion is None:
self.firstfix.emit(map_pos, gpsInfo)
self.info = gpsInfo
if (datetime.now()-self._gpsupdate_last).total_seconds() > self._gpsupdate_frequency:
self.gpsposition.emit(map_pos, gpsInfo)
self._gpsupdate_last = datetime.now()
self.postion = map_pos
self.elevation = gpsInfo.elevation
开发者ID:skeenp,项目名称:Roam,代码行数:31,代码来源:gps.py
注:本文中的qgis.core.QgsCoordinateTransform类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论