[Qgis-user] Edit vertex using DMS coordinates Plugin?

Alexandre Neto senhor.neto at gmail.com
Thu Nov 5 08:17:22 PST 2015


An update regarding this tread.

I have changed the code of Numerical Digitized (Yey for Open Source!) and
now it accepts all sort of DMS coordinate formats, things like:

9.50ºW
-9.50º
9º30'W
9º30.50'W
9º30'30"W
9º30'30.50"W

and even:

9º 30' 30.50" W

I'm trying to see if the autor of the plugin is interested in integrating
the changes in the original plugin.

Menwhile, if someone wants to see the code, I can send it by email.

Best Regards,

Alexandre Neto
http://gisunchained.wordpress.com


Tudorache, Marian <Marian.Tudorache at navcanada.ca> escreveu no dia sex,
11/09/2015 às 23:00:

> Hi again,
>
>
>
> I think I sent the code with a small bug.
>
>
>
> Replace this  line:
>
>         self.__transformation = qgis.core.QgsCoordinateTransform(self.__
> prs  , self.__ crs)
>
>
>
> with
>
>
>
> self.__transformation = qgis.core.QgsCoordinateTransform(self.__ crs ,
> self.__ prs  )
>
>
>
> let me know if it works.
>
>
>
> Thanks,
>
> Marian
>
>
>
> *From:* Tudorache, Marian
> *Sent:* September-11-15 5:32 PM
> *To:* 'Alexandre Neto'; Pedro Venâncio
> *Cc:* QGIS User
> *Subject:* RE: [Qgis-user] Edit vertex using DMS coordinates Plugin?
>
>
>
> Hi Alexandre,
>
>
>
> It is actually not a plugin.
>
> It is part of an application which launched aside of QGIS to help the
> users to draw airspaces.
>
> Their requirements are to work on the projected coordinate system with the
> data stored in world coordinate system but when they add geometries they
> want to input points in DMS format.
>
>
>
> I build a Widget GUI using QtDesigner (see the picture)
>
>
>
> The user enters start point of the line as: *DD MM SS.XXX H, DD MM SS.XXX
> L*
>
> Where:
>
> DD - degrees
>
> MM - minutes
>
> SS - seconds
>
> XXX - decimals for seconds
>
> H - is the hemisphere N or S
>
> L - is the W for West and E for East
>
>
>
> Then the drawLine is called  and executes the drawing of the line.
>
>
>
> If I have time I will make a plugin. You are welcome to do it if you have
> more time than me.
>
>
>
> Thanks,
>
> Marian
>
>
>
>
>
> *From:* Alexandre Neto [mailto:senhor.neto at gmail.com
> <senhor.neto at gmail.com>]
>
> *Sent:* September-11-15 3:58 PM
>
> *To:* Tudorache, Marian; Pedro Venâncio
>
>
> *Cc:* QGIS User
> *Subject:* Re: [Qgis-user] Edit vertex using DMS coordinates Plugin?
>
>
>
> Making a plugin might be an idea. Or some improve the numericalvertexedit
> and numerical digitize plugins.
>
> I will have a look into all your code.
>
> Meanwhile, what is the name of your plugin? It sound useful fot mem.
>
> Thanks
>
>
>
> A 19h34 Sex, 11 de Set de 2015, Tudorache, Marian <
> Marian.Tudorache at navcanada.ca> escreveu:
>
> Hi,
>
>
>
> I am sorry to interfere in this thread but I think my findings will help
> you.
>
> I also want to report a possible bug.
>
>
>
> I have worked to a plugin which display the coordinate in DMS when the
> user execute a mouse left click on the map.
>
> When the geometries are displayed on the projection, the conversion on the
> fly to DMS does not work properly.
>
> To have properly displayed the coordinate in DMS or Decimal degree you
> need to re-project your data to a coordinate reference system (WGS84 or
> GRS80, or other).
>
>
>
> For example:
>
> If data is displayed in projection reference system (stereographic in my
> case) and data is stored in world coordinates system (X and Y).
>
> X = -1081940.67048 and Y = 2561405.89514 will be displayed as 140040’13.726
> W. *There is not such latitude2561405053’42.489 N*
>
> *This is the projection: *+proj=sterea +lat_0=53.5 +lon_0=-76.0 +k=1
> +x_0=0 +y_0=0 +a=6381816.160744 +b=6381816.160744 +units=m +no_defs
>
>
>
>
>
> The conversion is done by the function toDegreesMinutesSeconds from
> QsgPoint class.
>
> It looks the function is not able to do to re-projection back to the
> spheroid. I think this is a bug.
>
>
>
> The function toDegreesMinutesSeconds works properly if it is applied to
> Decimal degree coordinate.
>
>
>
> What to be done!
>
> First you need to reproject your data by using QgsCoordinateTransform .
>
> Ex.
>
> crs = qgis.core.QgsCoordinateRefernceSystem(<idCRS>, qgis.core.
> QgsCoordinateRefernceSystem.InternalCrsId) # if you use a customized
> coordinate reference system
>
> prs = qgis.core.QgsCoordinateRefernceSystem(<idPRS>, qgis.core.
> QgsCoordinateRefernceSystem.InternalCrsId) # if you use a customized
> projected reference system
>
> transformation = = qgis.core. QgsCoordinateTransform(crs, prs)
>
>
>
> #transformation object is used to re-project your coordinates.
>
> For example:
>
> point = qgis.core.QgsPoint(X, Y) # X and Y are in world coordinate system
> meters
>
> #apply transformation to reproject your point
>
> reprojectedPoint = transformation.transform(point,
> QgsCoordinateTransform.ForwardTransform)
>
> print reprojectedPoint #you will get the point in decimal degrees.
>
> pointDMS = reprojectedPoint. toDegreesMinutesSeconds(3, True, True) #your
> will get the point in degrees minutes seconds with respect to crs
>
>
>
> if you want to input DMS data then you have to do the same steps but in
> reverse:
>
> 1.       Convert DMS to decimal degrees;
>
> 2.       Apply QgsCoordinateTransform to decimal degrees so you get X and
> Y.
>
>
>
> You can build a plugin based on this class. Check out the function
> drawLine where I input a lat and long in DMS format and write the line
> geometry in x/y format. If you have write your geometry in lat and long
> decimal degrees you do not have to apply QgsCoordinateTransform.
>
>
>
> #spam_activate_map_background
>
> import qgis
>
> from PyQt4 import QtGui, QtCore
>
>
>
>
>
> class LineGeometryDMSInput:
>
>     def __init__(self):
>
>         self.__prs  = qgis.core.QgsCoordinateReferenceSystem(100006,
> qgis.core.QgsCoordinateReferenceSystem.InternalCrsId)
>
>         self.__crs = qgis.core.QgsCoordinateReferenceSystem(100000,
> qgis.core.QgsCoordinateReferenceSystem.InternalCrsId)
>
>         self.__transformation = qgis.core.QgsCoordinateTransform(self.__
> prs  , self.__ crs)
>
>
>
>
>
>     def drawLine(self, lineStartDMS, lineEndDMS):
>
>         start_Point = lineStartDMS.split(',')
>
>         end_Point = lineEndDMS.split(',')
>
>
>
>         startLine = (self.fromDmsToDecimal(start_Point[0], 5),
> self.fromDmsToDecimal(start_Point[1], 5))
>
>         endLine = (self.fromDmsToDecimal(end_Point[0], 5),
> self.fromDmsToDecimal(end_Point[1], 5))
>
>
>
>         line_start = qgis.core.QgsPoint(startLine[1], startLine[0])
>
>         line_end = qgis.core.QgsPoint(endLine[1], endLine[0])
>
>
>
>         pointGeomStartTransformed = self.__
> transformation.transform(line_start,
> qgis.core.QgsCoordinateTransform.ForwardTransform)
>
>         pointGeomEndTransformed = self.__
> transformation.transform(line_end,
> qgis.core.QgsCoordinateTransform.ForwardTransform)
>
>
>
>         layer = qgis.utils.iface.activeLayer()
>
>         latestID = int(layer.featureCount())
>
>         layer.startEditing()
>
>         caps = layer.dataProvider().capabilities()
>
>
>
>         if caps & qgis.core.QgsVectorDataProvider.AddFeatures:
>
>             featureLine = qgis.core.QgsFeature(layer.pendingFields())
>
>             geom =
> qgis.core.QgsGeometry.fromPolyline([pointGeomStartTransformed,
> pointGeomEndTransformed])
>
>             #if your data is stored in geographical coordinate use this
>
>             #geom = qgis.core.QgsGeometry.fromPolyline([line_start,
> line_end])
>
>
>
>             featureLine.setGeometry(geom)
>
>             layer.dataProvider().addFeatures([featureLine])
>
>
>
>         layer.commitChanges()
>
>         layer.updateExtents()
>
>         layer.startEditing()
>
>         qgis.utils.iface.zoomToActiveLayer()
>
>
>
>
>
>     def fromDmsToDecimal(self, dmsString, precision):
>
>         degree = float(dmsString.strip()[:2])
>
>         decimal_minutes = float(dmsString.strip()[2:-9])
>
>         decimal_seconds = float(dmsString.strip()[5:-2])
>
>
>
>         decimal = round(degree + decimal_minutes/60 +
> decimal_seconds/3600, precision)
>
>         if 'S' in dmsString or 'W' in dmsString:
>
>             decimal = decimal * (-1.0)
>
>         return decimal
>
>
>
>
>
> Thanks,
>
> Marian
>
>
>
>
>
> *From:* qgis-user-bounces at lists.osgeo.org [mailto:
> qgis-user-bounces at lists.osgeo.org] *On Behalf Of *Alexandre Neto
> *Sent:* September-09-15 8:24 AM
> *To:* Pedro Venâncio
> *Cc:* QGIS User
> *Subject:* Re: [Qgis-user] Edit vertex using DMS coordinates Plugin?
>
>
>
> I know NumericalDigitize and NumericalVertexEdit, but none of them allows
> the user to input coordinates in DMS formats.
>
> We receive coordinates in many formats, and mostly in some form of Degree,
> minutes and deciimal Seconds, or Degree, and decimal minutes.
> Normally I put the coordinates in a CSV and open it in QGIS to import the
> coordinates. But It would be nicer the be able to add/edit them directly in
> one of those format instead.
>
> I did not know the node edit widget, looks interesting.
>
> Thanks,
>
> Alexandre
>
> Em qua, 9 de set de 2015 às 12:22, Pedro Venâncio <
> pedrongvenancio at gmail.com> escreveu:
>
> Hi Alexandre,
>
> Anyone know if it's possible or if there is a plugin that allow one to
> introduce
>
>
> Have you tried NumericalDigitize plugin?
>
>
>
>
> and modify vertex using introducing Degree, Minutes and Seconds (or any
> other variation) values.
>
>
>
>
> For editing, we have in QGIS master the new Node editor widget [0], which
> has the Vertex editor list (i).
>
> I don't know if you can work with Degrees, Minutes and Seconds in any of
> them, but with decimal degrees they work well.
>
> Best regards,
>
> Pedro Venâncio
>
> [0] https://github.com/qgis/QGIS/pull/2217
>
>
> ------------------------------
>
> This electronic message, as well as any transmitted files included in the
> electronic message, may contain privileged or confidential information and
> is intended solely for the use of the individual(s) or entity to which it
> is addressed. If you have received this electronic message in error please
> notify the sender immediately and delete the electronic message. Any
> unauthorized copying, disclosure or distribution of the electronic message
> is strictly forbidden. NAV CANADA accepts no liability for any damage
> caused by any virus and/or other malicious code transmitted by this
> electronic communication.
>
> Le présent message électronique et tout fichier qui peut y être joint
> peuvent contenir des renseignements privilégiés ou confidentiels destinés à
> l’usage exclusif des personnes ou des organismes à qui ils s’adressent. Si
> vous avez reçu ce message électronique par erreur, veuillez en informer
> l’expéditeur immédiatement et supprimez le. Toute reproduction, divulgation
> ou distribution du présent message électronique est strictement interdite.
> NAV CANADA n’assume aucune responsabilité en cas de dommage causé par tout
> virus ou autre programme malveillant transmis par ce message électronique.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20151105/6a3e583c/attachment.html>


More information about the Qgis-user mailing list